DiscussionsIssue archiveOCCT:Visualization

Archived issue #0031547

Visualization - V3d_View creates V3d_Trihedron instance

Open CASCADEOCCT:Visualizationclosed18 public notes

Search issues

Description

In V3d_View constructor, we create an instance of V3d_Trihedron.

Reasons for avoiding this:
1. Each view gets an application memory for this object, though it might not be used until TriedronDisplay() is called.
2. There is an alternative presentation: AIS_Trihedron (more parameters to handle).

The proposal is to create V3d_Trihedron in V3d_View just by the first attempt to display it.

Steps to reproduce

Not required

Public activity

18 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Branch [archived branch] has been created by Participant.
 
0031547: Visualization - V3d_View creates V3d_Trihedron instance

- moved creating of V3d_Trihedron from constructor to first attempt of displaying or calling it.
02Commenter 3
Wouldn't V3d_View::TriedronErase() crash with your patch?
03Commenter 3
Please also try extending the patch to V3d_Viewer::myRGrid and V3d_Viewer::myCGrid, which could be also created on demand (see command vgrid).

04Commenter 4
Branch [archived branch] has been updated by Participant
 # kgv remarks
- added a check in V3d_View::TriedronErase()
- extended to V3d_Viewer::myRGrid and V3d_Viewer::myCGrid
05Commenter 5
Branch [archived branch] has been created by Participant.
 
0031547: Visualization - V3d_View creates V3d_Trihedron instance

- moved creating of V3d_View::myTrihedron from constructor to first attempt of displaying or calling it
- moved creating of V3d_Viewer::myRGrid and V3d_Viewer::myCGrid to first attempt of displaying or calling them
06Commenter 3
The patch makes grid practically always created, see AIS_ViewController:
  if (theView->Viewer()->Grid()->IsActive()
   && theView->Viewer()->GridEcho())


Please consider correcting AIS_ViewController.
07Commenter 3
-Standard_Boolean V3d_Viewer::IsActive() const
+Standard_Boolean V3d_Viewer::IsActive()
 {
   return Grid()->IsActive();
...
-Aspect_GridDrawMode V3d_Viewer::GridDrawMode() const
+Aspect_GridDrawMode V3d_Viewer::GridDrawMode()
 {
   return Grid()->DrawMode();

It will be better returning stub here (check default values from grid constructor) instead of creating a Grid object.
08Commenter 8
Branch [archived branch] has been updated by Participant

 # kgv remarks:
- returned const stub in IsActive and DrawMode
- corrected AIS_ViewController and V3d_View to not make grid
09Commenter 9
Branch [archived branch] has been created by Participant.
 
0031547: Visualization - V3d_View creates V3d_Trihedron instance

- moved creating of V3d_View::myTrihedron from constructor to first attempt of displaying or calling it
- moved creating of V3d_Viewer::myRGrid and V3d_Viewer::myCGrid to first attempt of displaying or calling them
10Commenter 3
Could you please rename V3d_Viewer::IsActive() to V3d_Viewer::IsGridActive() in scope of the patch (with keeping V3d_Viewer::IsActive() as deprecated alias)?
11Commenter 11
Branch [archived branch] has been updated by Participant

 # kgv remarks:
- renamed V3d_Viewer::IsActive() to V3d_Viewer::IsGridActive()
- kept V3d_Viewer::IsActive() as deprecated alias
12Commenter 12
Branch [archived branch] has been created by Participant.
 
0031547: Visualization - V3d_View creates V3d_Trihedron instance

- moved creating of V3d_View::myTrihedron from constructor to first attempt of displaying or calling it
- moved creating of V3d_Viewer::myRGrid and V3d_Viewer::myCGrid to first attempt of displaying or calling them
- renamed V3d_Viewer::IsActive() to V3d_Viewer::IsGridActive()
13Commenter 3
+    if (!(myRGrid.IsNull() && myCGrid.IsNull()))
+    {
+      anActiveViewIter.Value()->SetGrid (myPrivilegedPlane, Grid());
+    }
...
+Handle(Aspect_Grid) V3d_Viewer::Grid()
+    case Aspect_GT_Circular:
+    {
+      if (myCGrid.IsNull())
+      {
+        myCGrid = new V3d_CircularGrid(this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
+      }
+      return Handle(Aspect_Grid) (myCGrid);
+    }
+    case Aspect_GT_Rectangular: 
+    {
+      if (myRGrid.IsNull())
+      {
+        myRGrid = new V3d_RectangularGrid(this, Quantity_Color(Quantity_NOC_GRAY50), Quantity_Color(Quantity_NOC_GRAY70));
+      }
+      return Handle(Aspect_Grid) (myRGrid);
+    }

The logic looks confusing.
I propose defining
> Handle(Aspect_Grid) V3d_Viewer::Grid (bool toCreate = true) {}
instead and call it with FALSE in places where it is desired to check for grid existance.

14Commenter 3
The same for V3d_View::Trihedron(bool theToCreate)
15Commenter 15
Branch [archived branch] has been updated by Participant

 # kgv remarks:
- redefined V3d_View::Trihedron and V3d_Viewer::Grid by adding new argument toCreate for opportunity to check the existence of the objects without their recreating
16Commenter 16
Branch [archived branch] has been created by Participant.
 
0031547: Visualization - V3d_View creates V3d_Trihedron instance

- moved creating of V3d_View::myTrihedron from constructor to first attempt of displaying or calling it
- moved creating of V3d_Viewer::myRGrid and V3d_Viewer::myCGrid to to first attempt of displaying or calling them
- renamed V3d_Viewer::IsActive() to V3d_Viewer::IsGridActive()
- redefined V3d_View::Trihedron and V3d_Viewer::Grid by adding new argument toCreate for opportunity to check the existence of the objects without their recreating
17Commenter 3
Please raise the patch
- OCCT branch: [archived branch]
18Commenter 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: 17720.020000000055 / 17721.200000000135 [-0.01%]
Products
Total CPU difference: 12428.380000000123 / 12412.630000000105 [+0.13%]
Windows-64-VC14:
OCCT
Total CPU difference: 19367.234375 / 19300.265625 [+0.35%]
Products
Total CPU difference: 13821.875 / 13740.03125 [+0.60%]


Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

Related records