DiscussionsIssue archiveOCCT:Visualization

Archived issue #0031704

Visualization - add an interactive object AIS_LightSource representing a light source

Open CASCADEOCCT:Visualizationclosed88 public notes

Search issues

Description

It is desired providing an interactive object representing a light source.
Minimal requirements to the object:
- Should be bound to Graphic3d_CLight;
- Represent the basic properties of light source:
   * Position via icon of positional light sources (point, spot),
   * Vector of directional light sources,
   * Spot light source cone shape,
   * Name,
   * Light color,
   * Light intensity,
   * On/off state,
   * Headlight mark,
   * Cut-off range (distance);
- Assigning Local Transformation to interactive object should move corresponding light source;
- Headlight flag should define transformation-persistence mode.
- Advanced selection modes:
   * Ability to turn light on/off.

Testing:
- vlight should be extended with an option creating/removing presentation of defined light sources.
- A representable scene should be defined for playing with multiple light sources of different type.

Steps to reproduce

pload MODELING VISUALIZATION
vclear
vinit View1 -width 1280 -height 720
vviewcube vc
box r -2500 -2000 0 5000 4000 3000
explode r FACE
vdisplay -noupdate -dispMode 1 r_1 r_2 r_4 r_5 r_6
vsetmaterial -noupdate r_1 STONE
vsetmaterial -noupdate r_2 STONE
vsetmaterial -noupdate r_4 STONE
vsetmaterial -noupdate r_5 STONE
vsetmaterial -noupdate r_6 STONE
vfit
vtrihedron t 0 0 0

box b1 0 0 0 1000 1000 1000
psphere s1 500
vdisplay -noupdate -dispMode 1 b1 s1
vsetmaterial -noupdate b1 PLASTIC
vsetmaterial -noupdate s1 GOLD
vlocation b1 -location -2000 0   0
vlocation s1 -location  1500 500 500

vrenderparams -shadingModel PBR
#vrenderparams -shadingModel PHONG
vlight -clear
vlight -add AMBIENT -intensity 0.1

set pg {-1500 500 1500}
vlight -add POSITIONAL -intensity 1000000 -pos {*}$pg -color GREEN -constAtten 1 -linearAtten 0.01 -display POSITIONAL_LIGHT -showName
#vlight -add POSITIONAL -intensity 1000000 -pos {*}$pg -color GREEN -range 1000 # KO range for Phong
vpoint pgp {*}$pg; vsetcolor pgp GREEN
psphere pgs 100; vdisplay -noupdate -dispMode 0 pgs; vlocation pgs -location {*}$pg; vsetcolor pgs GREEN

set sr {0 0 500}
vlight -add SPOT -intensity 100000000 -pos {*}$sr -dir 1 0 0 -color RED -display SPOT_RED -showallaspects
vpoint srp {*}$sr; vsetcolor srp RED
vpoint srp2 [expr [lindex $sr 0] + 100] [lindex $sr 1] [lindex $sr 2]; vsegment srd srp srp2; vsetcolor srd RED; verase srp2

vlight -add SPOT -intensity 100000000 -pos 0 0 0 -dir 0 0.2 -1 -color WHITE -head 1
vmanipulator manipulator -attach POSITIONAL_LIGHT -adjustPosition location

Public activity

88 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Added an alternative function vlight, that manage the light by AIS_LightSource tools
02Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
03Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Added an alternative function vlight, that manage the light by AIS_LightSource tools
    - Added ability to turn on/off light interactively
    - Extended vlight_lightsource by opportunity to display light attributes
04Commenter 3
Dear Maria,

desired presentation!
But, how can you use class from AIS package in low-level V3d?

[signature removed]Natalia
05Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Wed Oct 14 17:41:34 2020 +0300

    krv remarks:
    - delete mentions of AIS_LightSource in V3d_View
    - delete a clone method of vlight
    - update method vlight with possibilities of presentation via AIS_LightSource tools
    - move all presentation to method Compute

06Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Updated function vlight with opportunities of presentation via AIS_LightSource tools
    - Added ability to turn on/off light intera
07Author
+void AIS_LightSource::SetName (const TCollection_AsciiString& theName, Standard_Boolean theIsDisplay)
+{
+  myLightSource->SetName (theName);
+  isNameDisplayed = theIsDisplay;
+  // redisplay presentation
+  myCTXPtr->Display(this, Standard_True);
+  myCTXPtr->Redisplay(this, Standard_True);

This logic contradicts to AIS design - presentation itself is not supposed to redisplay itself on assigning some properties.

Use SetToUpdate() method to invalidate presentation and (re)display object outside (e.g. within vlight command, if needed).
08Author
+  //! Alias for IsHeadlight().
+  Standard_Boolean Headlight() const { return myLightSource->Headlight(); }
+
+  //! Setup headlight flag.
+  void SetHeadlight (Standard_Boolean theValue) 
+  { 
+    myLightSource->SetHeadlight (theValue);
+  }

These is no point duplicating all Light properties within Interactive Object - it would be enough providing a getter to Light source itself.
09Author
+      if (++anArgIt < theArgsNb)
+        if (Atof (theArgVec[anArgIt]) == 1)

Please never omit brackets within if statement.
10Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Updated function vlight with opportunities of presentation via AIS_LightSource tools
    - Added ability to turn on/off light
    - Added Transformation-persistence mode
11Author
Maria, could you please put a detailed textual description (as well as a couple of screenshors) of the current patch as a comment to this bug?
- Presentation aspects of each light source type;
- Implemented interaction mechanisms.

Please also put test cases for testing new functionality.
12Commenter 12
This patch provides the opportunity for presentation of light sources. Presentation of directional light source consists of the name of light and a line that is co-directed with the light direction.
Presentation of positional light source is made of the name of light, position and three circles radius of which is equal to range of light.
Presentation of spot light consists of the name and position of light source, direction like in directional light presentation, 2 segments starting at the light source’s position, the length of which is equal to the range of light source. The angle between these segments is equal to the angle of the light source. The ends of these segments are connected by a third segment, which is the diameter of the circle, indicating the spot from the light source.
Similar presentation is used in light sources presentation with head light mark that activates transformation-persistence mode.
In addition, this patch extended function vlight. First, two new commands were added, they are –display and –del_pres, these commands add and delete presentations of light sources respectively. These commands without any arguments are applied to all the light sources, but the user can specify the light to which he wants to display/delete the presentation by adding the number of light as an argument to –display/-del_pres. Also, to show/hide a specific presentation element, new arguments were added to -name, -range, -pos, -dir, -angle commands. Now the user can put 1 or 0 after all the arguments describing the light source characteristic, if the user wants to display or hide this element accordingly. By default, the item is not displayed.
One more feature that is provided in this patch is the ability to turn on/off the specific light source interactively in Viewer3d by clicking on its position.
To manage the light source interactively a user can use vmanipulator command. To attach light source to manipulator use the light source id that is specified in the vlight command.
13Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Wed Oct 28 16:51:09 2020 +0300

    - fix code style mistakes
    - fix transformation for directional light sources

14Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Thu Oct 29 15:51:58 2020 +0300

    - added comments
    - fixed displaying mistakes
    - fixed code style

15Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Updated function vlight with opportunities of presentation via AIS_LightSource tools
    - Added ability to turn on/off light
    - Added Transformation-persistence mode
16Commenter 16
+ Graphic3d_TMF_CameraFullPers = Graphic3d_TMF_ZoomRotatePers
+ | Graphic3d_TMF_CameraPers, //!< object is in front of the camera and doesn't resize and rotate

Unexpected comma at the end of last enum item.
17Commenter 17
if ((!IsZoomOrRotate (theMode)) && (theMode != Graphic3d_TMF_None))
Redundant parentheses.

18Commenter 18
+class AIS_LightSource : public AIS_InteractiveObject
+{
+ //! constructors
=> //! Constructors

+ //! light properties
=> //! Light properties

+ //! Setup headlight flag.
+ //! Setup location of positional/spot light. theIsDisplay - should the position be displayed (Standard_True by default).
+ //! Setup location of positional/spot light. theIsDisplay - should the position be displayed (Standard_True by default).
=> Use "Sets".

+ if (theValue)
+ {
+ SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_CameraFullPers, myLightSource->Position()));
+ }
+ else
+ {
+ SetTransformPersistence(new Graphic3d_TransformPers(Graphic3d_TMF_None, gp_Pnt(0., 0., 0.)));
+ }
Add one space before parenthesis.

+ //! Angle in radians of the cone created by the spot, should be within range (0.0, M_PI). theIsDisplay - should the position be displayed (Standard_True by default).
=> "Sets angle"

+ //! Delete all displayed attributes from Viewer.
=> "Deletes"

+ //! Show all attributes of lights in Viewer.
=> "Shows"

+ //! Return bounding box.
=> "Returns"

+ Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer /*aMode*/) Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode) Standard_OVERRIDE;
Add comments.

+ Standard_Boolean isNameDisplayed;
+ Standard_Boolean isPositionDisplayed;
+ Standard_Boolean isDirectionDisplayed;
+ Standard_Boolean isConeShapeDisplayed;
+ Standard_Boolean isRangeDisplayed;
=>myIs...
Move these fields to the end of all class fields.

+ myDirectionBeforeTransformation(0.0f, 0.0f, 0.0f, 0.0f),
Vec4 is zero vector by default

+ //! Initializes the light source.
+ Standard_EXPORT AIS_LightSource (Graphic3d_TypeOfLightSource theType, Handle(AIS_InteractiveContext) theContext);
+
+ //! Initializes the light source by copying Graphic3d_CLight settings.
+ Standard_EXPORT AIS_LightSource (const Handle(Graphic3d_CLight) & theLightSource, Handle(AIS_InteractiveContext) theContext);
=> const Handle(AIS_InteractiveContext)& theContext
But it is better to use base SetContext() method.

+ myCTXPtr = &*theContext;
myCTXPtr = theCtx.get();

19Commenter 19
+ myDirectionBeforeTransformation = Graphic3d_Vec4(float(theDir.X()), float(theDir.Y()), float(theDir.Z()), 0.0);
=> 0.f

+ SelectMgr_Vec3 mde (aMinPoint);
Bad variable name.
20Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
21Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Updated function vlight with opportunities of presentation via AIS_LightSource tools
    - Added ability to turn on/off light
    - Added Transformation-persistence mode
22Commenter 22
+ aMap.Bind (aLightNew->GetId(), new AIS_LightSource(aLightNew));
+ aMap.Find (aLightNew->GetId())->SetContext (ViewerTest::GetAISContext());
+ GetMapOfAIS().Bind (aMap.Find (aLightNew->GetId()), aLightNew->GetId());

Please avoid Find() method usage. It is not good by performance. You can save new object to additional variable instead of.
23Commenter 23
+ Standard_Boolean isNameDisplayed;
+ Standard_Boolean isPositionDisplayed;
+ Standard_Boolean isDirectionDisplayed;
+ Standard_Boolean isConeShapeDisplayed;
+ Standard_Boolean isRangeDisplayed;
Please rename. Use my***
24Commenter 24
+ //! Sets context.
+ //void SetContext(const Handle(AIS_InteractiveContext)& theContext) {myCTXPtr}
Remove unused code
25Commenter 25
+ if (theValue)
+ {
+ SetTransformPersistence (new Graphic3d_TransformPers(Graphic3d_TMF_CameraFullPers, myLightSource->Position()));
+ }
+ else
+ {
+ SetTransformPersistence (new Graphic3d_TransformPers(Graphic3d_TMF_None, gp_Pnt(0., 0., 0.)));
+ }

Maybe is it better to save input parameter to some temporary variable and call SetTransformPersistence() method only once?
26Author
+ Standard_Boolean isNameDisplayed;
+ Standard_Boolean isPositionDisplayed;
+ Standard_Boolean isDirectionDisplayed;
+ Standard_Boolean isConeShapeDisplayed;
+ Standard_Boolean isRangeDisplayed;
> Please rename. Use my*** 

myToDisplayName and ToDisplayName()/SetDisplayName() will sound more natural for theses properties.
27Commenter 2
Branch [archived branch] has been updated by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Fri Nov 6 15:30:17 2020 +0300

    osa and kgv remarks

28Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    - Added new class AIS_LightSource - object representing a light source
    - Represented position, name, direction, Cut-off range and spot light source cone shape
    - Assigned Local Transformation to interactive object
    - Updated function vlight with opportunities of presentation via AIS_LightSource tools
    - Added ability to turn on/off light
    - Added Transformation-persistence mode
29Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    Added new class AIS_LightSource representing a light source presentation.
    
    Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
    defining 3D point relative to camera Eye position.
30Author
Several remarks have been pushed to branch CR31704_7.

Please push test case(s) to the branch testing new functionality.
Please proceed with the following:

    Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
    Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (1);
    aPoints->AddVertex (myLightSource->Position());
    aGroup->AddPrimitiveArray (aPoints);

Presentation group is created with undefined attributes.

    Handle(Geom_Line) aLine = new Geom_Line (myLightSource->Position(), myLightSource->Direction());
    GeomAdaptor_Curve aCurve (aLine, 0.0, myLightSource->Range() != 0.0 ? myLightSource->Range() : Precision::Infinite());
    StdPrs_Curve::Add (thePrs, aCurve, myDrawer)

This is certainly an overkill creating Geom_Line for displaying a line segment.

Handle(Geom_Circle) aCircle = new Geom_Circle(anAxes, aRadius);
    GeomAdaptor_Curve aCircleCurv (aCircle);
    const Standard_Real aPrevDev = myDrawer->DeviationCoefficient();
    myDrawer->SetDeviationCoefficient (1.e-5);
    StdPrs_DeflectionCurve::Add (thePrs, aCircleCurv, myDrawer);
    myDrawer->SetDeviationCoefficient (aPrevDev);

This is overcomplication computing circle presentation through general tool StdPrs_DeflectionCurve.
Please simplify code to avoid Geom classes.

+    else if (anArgCase.IsEqual ("DELETE_PRESENTATION")
...
+            aLightSourceIter->DeleteAllDisplayedAttributes();
+            aLightSourceIter->SetToUpdate();
...
+      Handle(AIS_LightSource) aLightSourceCurr = new AIS_LightSource (aLight);
+      aMap.Bind (aLight->GetId(), aLightSourceCurr);
+      aLightSourceCurr->SetContext (ViewerTest::GetAISContext());
+      GetMapOfAIS().Bind (aLightSourceCurr, aLight->GetId());

This is not how show/hide works in AIS.
Please use AIS_InteractiveContext::Remove()/AIS_InteractiveContext::Display() for presentation management and try to remove unexpected AIS_LightSource::SetContext() calls.
31Author
+Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveContext)& ,

Within the current implementation, overriding AIS_InteractiveObject::HandleMouseClick() might be straightforward.
32Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
33Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    Added new class AIS_LightSource representing a light source presentation.
    
    Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
    defining 3D point relative to camera Eye position
34Author
+    GeomAdaptor_Curve aCurve (new Geom_Line (myLightSource->Position(), myLightSource->Direction()),
+                              0.0, myLightSource->HasRange() ? myLightSource->Range() : Precision::Infinite());
+    StdPrs_Curve::Add (thePrs, aCurve, myDrawer);

Adaptors and Geom are still used in the code.
35Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
36Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    Added new class AIS_LightSource representing a light source presentation.
    
    Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
    defining 3D point relative to camera Eye position
37Author
Please don't forget pushing a squashed branch.
I've put a couple of corrections into CR31704_9.

@@ -438,6 +438,8 @@ void AIS_Manipulator::Detach()
   if (!aContext.IsNull())
   {
     aContext->Remove (this, Standard_False);
+    aContext->Display (anObject, true);
+    aContext->Redisplay (anObject, true);

This is unexpected hack, please consider fixing an issue (if any) in other way.

+# --------------------------------------
+# display presentations of light sources
+# --------------------------------------

Please print description using "puts".

+set anImage1 $imagedir/${casename}_1.png

These additional variables are not very useful for a single-time usage.
Please just call "vdump $imagedir/${casename}_1.png" in place.
Replacing numbers with some meaningful text would be also helpful.

--- /dev/null
+++ b/tests/v3d/light_source/display_all

New tests will not be executed without putting them into tests/v3d/grids.list

+    const Standard_Real aRadius = myLightSource->HasRange() ? myLightSource->Range() : UnitsAPI::AnyToLS (250000., "mm");

Please avoid using UnitsAPI. Make 250000 a user-configurable parameter.
If this is an infinite line - you may use Prs3d_Drawer::MaximalParameterValue() / 2.0 instead of hard-coded number.

It might be also reasonable setting myInfiniteState=true in constructor as light sources are not expected to be affected by fit all.

    const Handle(Prs3d_ShadingAspect)& anAspect = myDrawer->ShadingAspect();
+    anAspect->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);

This is not how it is supposed to work - aspects should not be modified by ::Compute().
Moreover, there are no Prs3d_Drawer::SetShadingAspect() calls, so that the code modifies global AIS_InteractiveContext aspects instead of local to object.
Please define necessary aspects in constructor.

+    Prs3d_ToolSphere aSphere (aRadius, THE_NB_SLICES, THE_NB_STACKS);
+    gp_Trsf aTrsf;
+    aTrsf.SetTranslation (gp_Vec(gp::Origin(), myLightSource->Position()));
+    Handle(Graphic3d_ArrayOfTriangles) aCenterArray;
+    aSphere.FillArray (aCenterArray, aTrsf);

Prs3d_ToolSphere::Create() will be more straight-forward here.

+    Prs3d_ToolCylinder aConus (aRadius, 0.0, aDistance, THE_NB_SLICES, THE_NB_STACKS);

conus -> cone.

+  static NCollection_DataMap<TCollection_AsciiString, Handle(AIS_LightSource)> aMap;

aLightPrsMap.

+    Handle(V3d_Light) aLight = aLightIter.Value();
+    if (!aMap.IsBound (aLight->GetId()))

It looks redundant relying on additional identifier - Handle(V3d_Light) can be used directly as a key.

+      ViewerTest::GetAISContext()->Display (anIter.Value(), true);
+      ViewerTest::GetAISContext()->Redisplay (anIter.Value(), true);

There should be no need calling Redisplay() right after Display() - make sure you've put necessary SetToUpdate() calls on modification of presentable object.
Moreover, Display() shouldn't be called with "true" flag requiring to redraw a view on iterating over each light source in a loop.

+      GetMapOfAIS().Bind (aLightSourceNew, aLightNew->GetId());

Please avoid using internal GetMapOfAIS() when possible - use ViewerTest::Display() instead.

+    else if (anArgCase.IsEqual ("DELETE_PRESENTATION")
...
+          aLightSourceIter->DeleteAllDisplayedAttributes();

Once again - AIS_InteractiveContext::Remove() is expected to be used instead.

+    else if (anArgCase.IsEqual ("DISPLAY")
+          || anArgCase.IsEqual ("-DISPLAY"))
+    {
+        for (V3d_ListOfLightIterator aLightIter(aView->ActiveLightIterator()); aLightIter.More(); aLightIter.Next())
+        {
+          Handle(AIS_LightSource) aLightSourceIter = aMap.Find (aLightIter.Value()->GetId());
+          aLightSourceIter->SetDisplayName (true);

So far it doesn't look reasonable performing Display/Remove action directly in the loop.
Instead, code may remember action and perform it after main loop (in the same place, where you try recomputing presentations).

38Commenter 38
Branch [archived branch] has been updated by Participant
# kgv remarks:
- deleted last changes in AIS_Manipulator
- fixed tests
- added tests in grids.list
- replaced UnitsAPI::AnyTools (250000., "mm") by Prs3d_Drawer::MaximalParameterValue()
- added new variables for aspects
- fixed map stored light sources
- replaced DeleteAllDisplayedAttributes() by Remove()
- fixed performing "-DISPLAY" action
- fixed code style
39Commenter 39
Branch [archived branch] has been created by Participant.

0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
Added new class AIS_LightSource representing a light source presentation.
    
Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
defining 3D point relative to camera Eye position
40Author
Some remarks have been pushed to CR31704_10.

Extra questions:
- It seems DIRECTIONAL light sources are not displayed, do they?

testgrid v3d light_source
> vlight -clear 
> Error: no active viewer

Test cases are expected to pass, not to fail.

+          Handle(AIS_LightSource) aLightSourceIter = aLightPrsMap.Find (aLightIter.Value());
+          aLightSourceIter->SetDisplayName (true);
+          aLightSourceIter->SetDisplayPosition (true);
+          aLightSourceIter->SetDisplayDirection (true);
+          aLightSourceIter->SetDisplayAngle (true);
+          aLightSourceIter->SetDisplayRange (true);

Setting/unsetting options should not be done like this.

-      aLightCurr->SetDirection (anXYZ[0], anXYZ[1], anXYZ[2]);
+      aLightSourceCurr->SetDirection (gp_Dir (anXYZ[0], anXYZ[1], anXYZ[2]));

This is not how it is supposed to work.
You should set properties to Graphic3d_CLight and just invalidate presentation, so that AIS_InteractiveContext::Display() will do necessary staff.

+      ViewerTest::Display (anIter.Value()->Light()->GetId(), anIter.Value(), false);

This will produce a weirdly named presentations "0", "1", etc.
It will be better asking user to enter presentation name.
E.g.:
> vlight -change 0 -display "light0"
-prs/-presentation/-display could be aliases.

+  static NCollection_DataMap<Handle(V3d_Light), Handle(AIS_LightSource)> aLightPrsMap;

I propose removing this map altogether.
User will have to explicitly display each light source and he will be able to removed it from AIS_InteractiveContext at any time via "vremove" command.
It can be kept responsibility of user removing light source presentation right after removing light source itself via "vlight -delete" command,
or alternatively, command may iterate over all presentations in context and remove related light presentations.

-    "\n        -angle angleDeg"
+    "\n        -angle angleDeg {0|1} (display or not the angle of spot light source; 0 by default)"

Let's do not overload existing parameters setting light source properties.
It is better introducing a dedicated parameter(s) defining presentation style like -showAngle {0|1}/-showRange {0|1}/-showName {0|1}.
If "-display prsName" argument is not given, command can try to find related presentations in context to invalidate them or just report a syntax error.
Consider overriding AIS_KindOfInteractive property of AIS_LightSource object to filter out most of irrelevant presentations.
AIS_KOI_Datum and AIS_KOI_Object do not seems represent light source object well, so maybe it could be a new type AIS_KOI_LightSource.
41Commenter 41
Branch [archived branch] has been updated by Participant
# kgv remarks:
- overrode AIS_KindOfInteractive property of AIS_LightSource object
- introduced new parameters in vlight
- fixed vlight
- removed SetPosition, SetDirection and BoundingBox from AIS_LightSource
- removed myPositionBeforeTransformation and myDirBeforeTrsf from AIS_LightSource
- fixed tests
42Commenter 42
Branch [archived branch] has been created by Participant.

0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
Added new class AIS_LightSource representing a light source presentation.
    
Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
defining 3D point relative to camera Eye position
43Author
Current implementation looks unusable for several cases.
Please consider the following improvements (on top of minor corrections pushed to CR31704_11):

0. More attributes enabled by default.
AIS_LightSource constructor hides direction and name.
This makes default presentation of directional light useless.

1. Non-headlight Directional Light: position.
Current behavior is displaying such light at (0,0,0) point, which is kind of frustrating as normally this is a center of the scene.
It is proposed to compute default position of such light source basing on bounding box of the scene Graphic3d_CView::MinMaxValues().
The position will be computed as an intersection point of directional light with bounding sphere from crossing the center of this sphere.
This will be an initial position - setting location transformation externally (e.g. by using manipulator or other means) will allow moving it.

2. Non-headlight Directional Light: arrow length.
Current behavior is computing enormously long "infinite" arrow.
This looks too messy in the scene.
It is proposed computing arrow length as a configurable fraction of on bounding box of the scene (try 10% by default to see how it looks) and as absolute length value.
The same for an arrow length of Spot Light.

2. Non-headlight Directional Light: number of arrows.
Currently directional light is represented by a single arrow.
This looks like a weak association to the directional light having no real position in space.
It is proposed drawing several parallel arrows around displaying position, with configurable number.

3. Positional Light: infinite range.
Current implementation displays enormously large sphere for representing infinite range.
Practically speaking, this is probably not useful representation of infinite range - it would be better drawing a sphere of a small fixed (configurable) radius.

4. Ambient Light.
It seems the current implementation has no representation for such light.
It is proposed displaying it as a sphere filled in with source color (probably with several arrows toward the sphere) at a corner of view via Graphic3d_TMF_TriedronPers persistence.
Enabling/disabling light source should work fine as in case of other types.

5. vlight command improvements.
It is proposed adding "-set"/"-replace" commands behaving the same as "-add" (e.g. creating a new light source) but replacing existing light with specified index.
Specifying index of non-existing light source would automatically extends the list of lights (with empty lights in-between - to be checked what would not cause crashes in existing code).
This would allow simpler scripting instead of repetitive -clear, -add, -add.

N. TODO: check positional light first display.
In my tests (-2,0,0) positional light first appeared at (0,0,0) position, which has been fixed only after redisplaying / modifying the light.

N. TODO: check head-light behavior / consider improvements.
It looks like it is often clipped by camera frustum or objects...

N. TODO: icons [to be considered later]
Embed markers representing point light sources instead of a cross.
44Commenter 2
Branch [archived branch] has been updated forcibly by Participant.

[revision removed]
45Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    Added new class AIS_LightSource representing a light source presentation.
    
    Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
    defining 3D point relative to camera Eye position
46Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
47Commenter 2
Branch [archived branch] has been created by Participant.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Thu Feb 4 12:48:52 2021 +0300

    # remarks
    - updated directional light source presentation
    - updated direction presentation
    - fixed insensitivity of light source after changing headlight state
48Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Fri Feb 5 11:50:38 2021 +0300

    # remarks 1

49Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Fri Feb 5 14:40:05 2021 +0300

    # remarks 2

50Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
51Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
52Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
53Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
54Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
55Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
56Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
57Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
58Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
59Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 00:20:38 2021 +0300

    # positional

60Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 01:00:22 2021 +0300

    # highlight

Author: Author
Date: Sat Feb 6 00:49:57 2021 +0300

    # spotlight

61Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 01:22:53 2021 +0300

    # label shift

62Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 01:41:57 2021 +0300

    # display stacked sources

63Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 02:56:28 2021 +0300

    # ambient light source - add arrows

64Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 03:17:22 2021 +0300

    # docs

65Commenter 2
Branch [archived branch] has been updated by Author.

[revision removed]


Detailed log of new commits:

Author: Author
Date: Sat Feb 6 03:49:09 2021 +0300

    # fix tests

Author: Author
Date: Sat Feb 6 03:46:01 2021 +0300

    # vlight - remove non-working option -set

Author: Author
Date: Sat Feb 6 03:40:04 2021 +0300

    # vlight fixes

66Commenter 2
Branch [archived branch] has been created by Author.

[revision removed]


Detailed log of new commits:

Author: mkrylova
Date: Tue Sep 8 17:50:28 2020 +0300

    0031704: Visualization - add an interactive object AIS_LightSource representing a light source
    
    Added new class AIS_LightSource representing a light source presentation.
    
    Graphic3d_TMF_CameraPers - added new mode to Graphic3d_TransformPers
    defining 3D point relative to camera Eye position
67Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
68Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
69Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
70Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
71Author
Please raise the patch
- OCCT branch: [archived branch]

http://jenkins-test-12.nnov.opencascade.com:8080/view/CR31704_14-master-KGV/
72Commenter 2
Branch [archived branch] has been updated forcibly by Author.

[revision removed]
73Commenter 1
Combination -
OCCT branch : [archived branch]
master SHA - [revision removed]
[revision removed]
Products branch : [archived branch] SHA - [revision removed]
was compiled on Linux, MacOS and Windows platforms and tested in optimize mode.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
Debian80-64:
OCCT
Total CPU difference: 17805.430000000237 / 17802.420000000013 [+0.02%]
Products
Total CPU difference: 11513.250000000124 / 11523.070000000105 [-0.09%]
Windows-64-VC14:
OCCT
Total CPU difference: 19375.296875 / 19372.265625 [+0.02%]
Products
Total CPU difference: 12857.265625 / 12882.921875 [-0.20%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention
74Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
75Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
76Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
77Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
78Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
79Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
80Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
81Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
82Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
83Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
84Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
85Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
86Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
87Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]
88Commenter 2
Branch [archived branch] has been deleted by Participant.

[revision removed]

Related records