MantisBT
Mantis Bug Tracker Workflow

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0031704Open CASCADE[OCCT] OCCT:Visualizationpublic2020-08-11 09:392021-01-13 22:21
Reporterkgv 
Assigned Tomkrylova 
PrioritynormalSeverityfeature 
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version[OCCT] 7.6.0*Fixed in Version 
Summary0031704: Visualization - add an interactive object AIS_LightSource representing a light source
DescriptionIt 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
#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
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
vlight -change 1 -name POSITIONAL_LIGHT 1
vlight -display
vmanipulator manipulator -attach Graphic3d_CLight_pos5
TagsNo tags attached.
Test case number
Attached Filespng file icon display_all.png (18,934 bytes) 2020-12-29 17:06
png file icon manipulator.png (16,931 bytes) 2020-12-29 17:08
png file icon head_light.png (43,089 bytes) 2020-12-29 17:14

- Relationships
related to 0031705verifiedbugmaster Open CASCADE Visualization - move out construction of predefined markers from OpenGl_AspectsSprite to Graphic3d_MarkerImage 
related to 0032055reviewedbugmaster Open CASCADE Draw Harness, ViewerTest - add more vmanipulator position adjusting options 

-  Notes
(0095600)
git (administrator)
2020-10-02 18:26

Branch CR31704 has been created by mkrylova.

SHA-1: 449cb897fd43a804147007dceb93e3ee22622cfa


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
(0095879)
git (administrator)
2020-10-09 19:03

Branch CR31704 has been updated forcibly by mkrylova.

SHA-1: cec6ad406877f31bc45292c94fc5307e12457774
(0095880)
git (administrator)
2020-10-09 19:06

Branch CR31704_1 has been created by mkrylova.

SHA-1: 43f03af5b8e1517a7dc485129b90fae304ae82da


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
(0095885)
nds (developer)
2020-10-12 12:34

Dear Maria,

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

Best regards, Natalia
(0095980)
git (administrator)
2020-10-14 18:33

Branch CR31704_1 has been updated by mkrylova.

SHA-1: 72b0666c5e2712df930500993cf28fa96d803b2d


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

(0095981)
git (administrator)
2020-10-14 18:38

Branch CR31704_2 has been created by mkrylova.

SHA-1: 5ad480ce0af5a44b1570235dbe39c1f7ddd3f56a


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
(0095982)
kgv (developer)
2020-10-14 19:15

+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).
(0095983)
kgv (developer)
2020-10-14 19:17

+  //! 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.
(0095984)
kgv (developer)
2020-10-14 19:19

+      if (++anArgIt < theArgsNb)
+        if (Atof (theArgVec[anArgIt]) == 1)

Please never omit brackets within if statement.
(0096305)
git (administrator)
2020-10-27 17:32

Branch CR31704_3 has been created by mkrylova.

SHA-1: c91df6ae54a18b45278e151f8a87bff72e249b0f


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
(0096323)
kgv (developer)
2020-10-28 08:13

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.
(0096336)
mkrylova (developer)
2020-10-28 15:33

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.
(0096339)
git (administrator)
2020-10-28 16:46

Branch CR31704_3 has been updated by mkrylova.

SHA-1: 14f3ac93de797bcff084ca9f750d8aa9cde9e1fb


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

(0096372)
git (administrator)
2020-10-29 15:47

Branch CR31704_3 has been updated by mkrylova.

SHA-1: ccb542c25a688aa9e7875b019d98379c62ab005c


Detailed log of new commits:

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

    - added comments
    - fixed displaying mistakes
    - fixed code style

(0096375)
git (administrator)
2020-10-29 15:48

Branch CR31704_4 has been created by mkrylova.

SHA-1: 05aef6c35868126415104ff8fec707e37afae5a1


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
(0096434)
osa (developer)
2020-11-02 09:39

+ 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.
(0096435)
osa (developer)
2020-11-02 09:44
edited on: 2020-11-02 10:23

if ((!IsZoomOrRotate (theMode)) && (theMode != Graphic3d_TMF_None))
Redundant parentheses.

(0096436)
osa (developer)
2020-11-02 10:08
edited on: 2020-11-02 10:24

+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();

(0096437)
osa (developer)
2020-11-02 10:15

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

+ SelectMgr_Vec3 mde (aMinPoint);
Bad variable name.
(0096450)
git (administrator)
2020-11-02 13:17

Branch CR31704_4 has been updated forcibly by mkrylova.

SHA-1: 11c645005b1e6aa4c268b8f3e8a09ddf17ce1b1d
(0096452)
git (administrator)
2020-11-02 13:24

Branch CR31704_5 has been created by mkrylova.

SHA-1: 119d554496104effd2c2473c210c57b1490d53b3


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
(0096544)
osa (developer)
2020-11-05 15:33

+ 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.
(0096545)
osa (developer)
2020-11-05 15:37

+ Standard_Boolean isNameDisplayed;
+ Standard_Boolean isPositionDisplayed;
+ Standard_Boolean isDirectionDisplayed;
+ Standard_Boolean isConeShapeDisplayed;
+ Standard_Boolean isRangeDisplayed;
Please rename. Use my***
(0096546)
osa (developer)
2020-11-05 15:38

+ //! Sets context.
+ //void SetContext(const Handle(AIS_InteractiveContext)& theContext) {myCTXPtr}
Remove unused code
(0096547)
osa (developer)
2020-11-05 15:40

+ 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?
(0096548)
kgv (developer)
2020-11-05 15:42

+ 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.
(0096594)
git (administrator)
2020-11-06 15:29

Branch CR31704_5 has been updated by mkrylova.

SHA-1: 3423eb5436b2c186be29fb0d86c80b0b1b8173bd


Detailed log of new commits:

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

    osa and kgv remarks

(0096614)
git (administrator)
2020-11-09 11:51

Branch CR31704_6 has been created by mkrylova.

SHA-1: 4e647c8f85c3ef1c8503d23b1be8b6f371af1b51


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
(0097602)
git (administrator)
2020-12-15 12:00

Branch CR31704_7 has been created by kgv.

SHA-1: 6523a50b3c76aa8bb19931c8000dc99ff9c72b34


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.
(0097603)
kgv (developer)
2020-12-15 12:08

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.
(0097604)
kgv (developer)
2020-12-15 12:19

+Standard_Boolean AIS_LightSource::ProcessDragging (const Handle(AIS_InteractiveContext)& ,

Within the current implementation, overriding AIS_InteractiveObject::HandleMouseClick() might be straightforward.
(0097896)
git (administrator)
2020-12-24 17:08

Branch CR31704_7 has been updated forcibly by mkrylova.

SHA-1: d1d5f8bc3c0c5bfda5873039169333c81ae3424f
(0097897)
git (administrator)
2020-12-24 17:12

Branch CR31704_8 has been created by mkrylova.

SHA-1: e09a1c45b2640e8ce9602381f700313efb66374f


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
(0097899)
kgv (developer)
2020-12-24 17:25

+    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.
(0097980)
git (administrator)
2020-12-29 17:01

Branch CR31704_8 has been updated forcibly by mkrylova.

SHA-1: dbcce6ac59514d34969783c2f462e09317e9d66c
(0097988)
git (administrator)
2020-12-30 12:27

Branch CR31704_9 has been created by kgv.

SHA-1: 2bad57193efe66dfe8c9cab13ca6afe91e3ea005


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
(0097989)
kgv (developer)
2020-12-30 13:22
edited on: 2020-12-30 13:24

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).

(0098101)
mkrylova (developer)
2021-01-13 13:07

Branch CR31704_8 has been updated by mkrylova
# 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
(0098102)
mkrylova (developer)
2021-01-13 13:08

Branch CR31704_10 has been created by mkrylova.

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
(0098105)
kgv (developer)
2021-01-13 15:54

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.

- Issue History
Date Modified Username Field Change
2020-08-11 09:39 kgv New Issue
2020-08-11 09:39 kgv Assigned To => kgv
2020-08-11 09:39 kgv Assigned To kgv => mkrylova
2020-08-11 09:39 kgv Status new => assigned
2020-08-11 09:42 kgv Relationship added related to 0031705
2020-09-21 17:42 kgv Target Version 7.5.0 => 7.6.0*
2020-10-02 18:26 git Note Added: 0095600
2020-10-09 19:03 git Note Added: 0095879
2020-10-09 19:06 git Note Added: 0095880
2020-10-12 12:34 nds Note Added: 0095885
2020-10-12 14:41 kgv Relationship added child of 0029290
2020-10-14 18:33 git Note Added: 0095980
2020-10-14 18:38 git Note Added: 0095981
2020-10-14 19:15 kgv Note Added: 0095982
2020-10-14 19:17 kgv Note Added: 0095983
2020-10-14 19:19 kgv Note Added: 0095984
2020-10-26 11:33 kgv Steps to Reproduce Updated View Revisions
2020-10-26 11:46 kgv Steps to Reproduce Updated View Revisions
2020-10-27 17:32 git Note Added: 0096305
2020-10-28 08:13 kgv Note Added: 0096323
2020-10-28 15:33 mkrylova Note Added: 0096336
2020-10-28 15:35 mkrylova File Added: presentation of light with headlight mark.png
2020-10-28 15:35 mkrylova File Added: different light sources.png
2020-10-28 15:35 mkrylova File Added: manipulator.png
2020-10-28 16:46 git Note Added: 0096339
2020-10-29 13:42 mkrylova Steps to Reproduce Updated View Revisions
2020-10-29 15:47 git Note Added: 0096372
2020-10-29 15:48 git Note Added: 0096375
2020-10-29 15:49 mkrylova Assigned To mkrylova => osa
2020-10-29 15:49 mkrylova Status assigned => resolved
2020-11-02 09:39 osa Note Added: 0096434
2020-11-02 09:44 osa Note Added: 0096435
2020-11-02 10:08 osa Note Added: 0096436
2020-11-02 10:15 osa Note Added: 0096437
2020-11-02 10:15 osa Assigned To osa => mkrylova
2020-11-02 10:15 osa Status resolved => assigned
2020-11-02 10:23 osa Note Edited: 0096435 View Revisions
2020-11-02 10:24 osa Note Edited: 0096436 View Revisions
2020-11-02 13:17 git Note Added: 0096450
2020-11-02 13:24 git Note Added: 0096452
2020-11-02 14:20 mkrylova Assigned To mkrylova => osa
2020-11-02 14:20 mkrylova Status assigned => resolved
2020-11-05 15:33 osa Note Added: 0096544
2020-11-05 15:37 osa Note Added: 0096545
2020-11-05 15:38 osa Note Added: 0096546
2020-11-05 15:40 osa Note Added: 0096547
2020-11-05 15:42 kgv Note Added: 0096548
2020-11-06 13:51 osa Assigned To osa => mkrylova
2020-11-06 13:51 osa Status resolved => assigned
2020-11-06 15:29 git Note Added: 0096594
2020-11-09 11:31 mkrylova Assigned To mkrylova => osa
2020-11-09 11:31 mkrylova Status assigned => resolved
2020-11-09 11:51 git Note Added: 0096614
2020-12-06 18:13 kgv Description Updated View Revisions
2020-12-15 12:00 git Note Added: 0097602
2020-12-15 12:08 kgv Note Added: 0097603
2020-12-15 12:08 kgv Assigned To osa => mkrylova
2020-12-15 12:08 kgv Status resolved => assigned
2020-12-15 12:19 kgv Note Added: 0097604
2020-12-24 17:08 git Note Added: 0097896
2020-12-24 17:12 git Note Added: 0097897
2020-12-24 17:12 mkrylova Assigned To mkrylova => kgv
2020-12-24 17:12 mkrylova Status assigned => resolved
2020-12-24 17:25 kgv Note Added: 0097899
2020-12-24 17:25 kgv Assigned To kgv => mkrylova
2020-12-24 17:25 kgv Status resolved => assigned
2020-12-29 17:01 git Note Added: 0097980
2020-12-29 17:04 mkrylova File Deleted: different light sources.png
2020-12-29 17:06 mkrylova File Added: display_all.png
2020-12-29 17:08 mkrylova File Deleted: manipulator.png
2020-12-29 17:08 mkrylova File Added: manipulator.png
2020-12-29 17:14 mkrylova File Deleted: presentation of light with headlight mark.png
2020-12-29 17:14 mkrylova File Added: head_light.png
2020-12-29 17:14 mkrylova Assigned To mkrylova => kgv
2020-12-29 17:14 mkrylova Status assigned => resolved
2020-12-30 12:27 git Note Added: 0097988
2020-12-30 13:22 kgv Note Added: 0097989
2020-12-30 13:22 kgv Assigned To kgv => mkrylova
2020-12-30 13:22 kgv Status resolved => assigned
2020-12-30 13:24 kgv Note Edited: 0097989 View Revisions
2021-01-13 13:07 mkrylova Note Added: 0098101
2021-01-13 13:08 mkrylova Note Added: 0098102
2021-01-13 13:08 mkrylova Assigned To mkrylova => kgv
2021-01-13 13:08 mkrylova Status assigned => resolved
2021-01-13 15:54 kgv Note Added: 0098105
2021-01-13 15:54 kgv Assigned To kgv => mkrylova
2021-01-13 15:54 kgv Status resolved => assigned
2021-01-13 22:21 kgv Relationship added related to 0032055


Copyright © 2000 - 2021 MantisBT Team
Powered by Mantis Bugtracker