21854: Add persistent dimensions

- Final commit: help documents, preferences.
This commit is contained in:
apl 2014-01-21 12:51:45 +00:00
parent ac4bdd2286
commit fca35298c7
28 changed files with 1557 additions and 224 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

@ -0,0 +1,44 @@
/*!
\page add_dimension_page Add Dimension
\image html add_dimension.png
The dialog is opened from \ref managing_dimensions_page "Manage Dimensions" dialog when "Add" button is clicked.
This dialog allows creating measurement dimension for the selected geometrical object.
The following types of dimensions can be constructed:
<ul>
<li>Length.</li>
<li>Diameter.</li>
<li>Angle.</li>
</ul>
Being constructed, the dimension is positioned by application such that the user is able to see it from the most appropriate angle of view.
The application selects one of the best matching planes allowed for the dimension. If extending the dimension by increasing length of flyouts
make sense, then the application extends the flyouts for a default value specified on the \ref geometry_preferences_page "geometry preference dialog".
Once constructed, the geometrical properties of dimension preview (flyout, plane) become interactively editable in OCC viewer.
For the description of interactive operations please refer to corresponding section at \ref managing_dimensions_page "Manage Dimensions" page.
The legnth dimension can be constructed in three ways: as length on edge, as length between two points and as length between two parallel lines.
In order to construct the dimension, the selected geometry should met the following conditions:
<ul>
<li>Edge length - only the line edges are accepted. E.g. constructed from line segment, on two points.</li>
<li>Two points - any two points.</li>
<li>Parallel edges - only the parallel line edges are accepted.</li>
</ul>
The diameter dimension can be constructed for the following geometry types:
<ul>
<li>Arc and circle. The selected geometry should be an arc, a circular edge or a circular face.</li>
<li>Sphere, cylinder, cone, torus.</li>
</ul>
The angle dimension can be constructed in two ways: as angle between two edges, as angle by three points.
The following conditions should be met:
<ul>
<li>Two edges. The edges should be located in same plane.
<li>Three points. Any three points, with the second point being the center of the angle.
</ul>
*/

View File

@ -49,6 +49,20 @@ predefined materials.</li>
</ul> </ul>
</ul> </ul>
<ul>
<li><b>Dimensions (Measurements)</b></li>
<ul>
<li><b>Color</b> - allows to define color for persistent dimension presentations.</li>
<li><b>Line width</b> - allows to define pixel width of dimension lines.</li>
<li><b>Font height</b> - allows to define height of dimension text.</li>
<li><b>Length of arrows</b> - allows to define length of dimension arrows.</li>
<li><b>Length measurement units</b> - allows to define units of measurement for lengths dimensions.</li>
<li><b>Angle measurement units</b> - allows to define units of measurement for angles dimensions.</li>
<li><b>Show units of measurements</b> - when this option is on, the measurement units are added as prefix to value label of dimension.</li>
<li><b>Default flyout length</b> - allows to define default flyout length used when creating the dimensions. The length can be interactively changed after creation by moving the flyouts.</li>
</ul>
</ul>
<ul> <ul>
<li><b>Number of isolines</b> - allows to specify the number of isolines along <b>Along U</b> and <b>Along V</b> coordinate axes. They are shown on each selected face. For example: <li><b>Number of isolines</b> - allows to specify the number of isolines along <b>Along U</b> and <b>Along V</b> coordinate axes. They are shown on each selected face. For example:

View File

@ -0,0 +1,64 @@
/*!
\page managing_dimensions_page Manage Dimensions
\image html dimensions_preview.png
Dimensions of sub-elements can be measured for a geometrical object representing a shape.
There are three types of dimensions available
<ul>
<li>Length.</li>
<li>Diameter.</li>
<li>Angle.</li>
</ul>
Measurement units and group of presentation attributes for the measurement dimensions can be seen and changed from the \ref geometry_preferences_page "geometry preference dialog".
The application entities, representing the dimensions, are associated with the geometrical object for which its elements are measured. The dimensions follow their associated object on show/hide, transformation and deletion operations.
Each dimension instance has its <i>local visibility</i> flag intended for showing/hiding it among other dimensions of the associated object.
\image html manage_dimensions.png
This dialog allows managing list of dimensions for the selected geometrical object.
It shows the list and provides dimension creation and removal, modification of name and visibility, along with the interactive modification of dimension's geometrical properties.
The list view groups dimension objects by their type: "Distances", "Diameters", "Angles". This view allows selection of the dimensions and lets user to change the dimension's name and visibility.
The buttons located at the right side of the dialog have the following purposes:
<ul>
<li>"Add" - opens \ref add_dimension_page "Add Dimension" dialog for interactive specification of a new dimension for the selected object.</li>
<li>"Remove" - removes selected instance of dimension.</li>
<li>"Show All" / "Hide All" - turn on/off local visibility flags of all dimensions presented in the list.</li>
</ul>
\image html interact_with_dimensions.png
Geometrical properties of the selected dimension become interactively editable in viewer.
When hovering with mouse, the element of dimension become highlighted.
This means that the element is ready for interactive operations.
The following interactive operations are allowed:
<ul>
<li>Modification of flyout length. By dragging the flyout with left mouse button the user is allowed to change its length without changing its plane (direction).</li>
<li>Modification of flyout length & plane (direction). If dimension is viewed at least slightly from side, then dragging the flyout with holding <i>ctrl</i> key additionally enables modification of the flyout plane.</li>
<li>Modification of label alignment. By dragging the label the user is allowed to change its alignment. </li>
</ul>
The following horizontally aligned positions can be specified:
<ul>
<li>Left. Label is located outside of the left flyout line.</li>
<li>Right. Label is located outside of the right flyout line.</li>
<li>Center. Label is centered among of the flyout lines.</li>
</ul>
The following vertically aligned positions can be specified:
<ul>
<li>On flyout line. The label is located at the side of flyout line, which is farther from the measured geometry.</li>
<li>Under flyout line. The label is located at the side of flyout line, which is closer to the measured geometry.</li>
<li>In center of flyout line.</li>
</ul>
All of the modifications to the dimensions, until applied, are temporary. The "Apply" and "Apply and Close" buttons save the changes.
*/

View File

@ -19,7 +19,7 @@
<li>\subpage whatis_page "WhatIs"</li> <li>\subpage whatis_page "WhatIs"</li>
</ul> </ul>
\n Or to check their integrity: \n To check their integrity:
<ul> <ul>
<li>\subpage boundaries_page "Check Free Boundaries"</li> <li>\subpage boundaries_page "Check Free Boundaries"</li>
@ -30,6 +30,13 @@
<li>\subpage check_self_intersections_page "Detect Self-intersections"</li> <li>\subpage check_self_intersections_page "Detect Self-intersections"</li>
</ul> </ul>
\n Or to measure dimensions of the shape elements:
<ul>
<li>\subpage managing_dimensions_page "Manage Dimensions"</li>
<li>\subpage add_dimension_page "Add Dimension"</li>
</ul>
\n Our <b>TUI Scripts</b> show how to use \n Our <b>TUI Scripts</b> show how to use
\ref tui_measurement_tools_page "Measurement Tools" with <b>TUI \ref tui_measurement_tools_page "Measurement Tools" with <b>TUI
commands</b>. commands</b>.

View File

@ -59,6 +59,8 @@ geometrical object. TUI Command: <em>sg.DisplayOnly(ID)</em></li>
\image html image33.png \image html image33.png
<li><b>Show all dimensions</b> - shows all of the persistent dimensions created for the selected geometrical object.</li>
<li><b>Hide all dimensions</b> - hides all of the persistent dimensions created for the selected geometrical object.</li>
<li><b>Dump view</b> - exports an object from the viewer in bmp, png, <li><b>Dump view</b> - exports an object from the viewer in bmp, png,
jpg or jpeg image format.</li> jpg or jpeg image format.</li>
<li><b>Change background</b> - allows to redefine the background <li><b>Change background</b> - allows to redefine the background

View File

@ -69,13 +69,14 @@
<parameter name="iso_number_v" value="0" /> <parameter name="iso_number_v" value="0" />
<!-- Dimension presentation properties --> <!-- Dimension presentation properties -->
<parameter name="dimensions_color" value="#00ff21" /> <parameter name="dimensions_color" value="#ffffff" />
<parameter name="dimensions_line_width" value="1" /> <parameter name="dimensions_line_width" value="1" />
<parameter name="dimensions_font_height" value="10" /> <parameter name="dimensions_font_height" value="10" />
<parameter name="dimensions_arrow_length" value="5" /> <parameter name="dimensions_arrow_length" value="5" />
<parameter name="dimensions_show_units" value="0" /> <parameter name="dimensions_show_units" value="0" />
<parameter name="dimensions_length_units" value="m" /> <parameter name="dimensions_length_units" value="m" />
<parameter name="dimensions_angle_units" value="deg" /> <parameter name="dimensions_angle_units" value="deg" />
<parameter name="dimensions_default_flyout" value="20" />
<!-- Scalar bar for field step presentation --> <!-- Scalar bar for field step presentation -->
<parameter name="scalar_bar_x_position" value="0.05" /> <parameter name="scalar_bar_x_position" value="0.05" />

View File

@ -47,6 +47,7 @@ void GEOMGUI_DimensionProperty::Length::Init( const Handle(AIS_LengthDimension)&
Flyout = theIO->GetFlyout(); Flyout = theIO->GetFlyout();
TextHPos = theIO->DimensionAspect()->TextHorizontalPosition(); TextHPos = theIO->DimensionAspect()->TextHorizontalPosition();
TextVPos = theIO->DimensionAspect()->TextVerticalPosition(); TextVPos = theIO->DimensionAspect()->TextVerticalPosition();
ArrowPos = theIO->DimensionAspect()->ArrowOrientation();
} }
//================================================================================= //=================================================================================
@ -68,6 +69,7 @@ void GEOMGUI_DimensionProperty::Length::Update( Handle(AIS_LengthDimension)& the
Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect(); Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
aStyle->SetTextHorizontalPosition( TextHPos ); aStyle->SetTextHorizontalPosition( TextHPos );
aStyle->SetTextVerticalPosition( TextVPos ); aStyle->SetTextVerticalPosition( TextVPos );
aStyle->SetArrowOrientation( ArrowPos );
theIO->SetDimensionAspect( aStyle ); theIO->SetDimensionAspect( aStyle );
} }
@ -99,7 +101,8 @@ bool GEOMGUI_DimensionProperty::Length::operator == (const Length& theOther) con
if ( Flyout != theOther.Flyout if ( Flyout != theOther.Flyout
|| TextHPos != theOther.TextHPos || TextHPos != theOther.TextHPos
|| TextVPos != theOther.TextVPos ) || TextVPos != theOther.TextVPos
|| ArrowPos != theOther.ArrowPos )
{ {
return false; return false;
} }
@ -121,6 +124,7 @@ void GEOMGUI_DimensionProperty::Diameter::Init( const Handle(AIS_DiameterDimensi
Flyout = theIO->GetFlyout(); Flyout = theIO->GetFlyout();
TextHPos = theIO->DimensionAspect()->TextHorizontalPosition(); TextHPos = theIO->DimensionAspect()->TextHorizontalPosition();
TextVPos = theIO->DimensionAspect()->TextVerticalPosition(); TextVPos = theIO->DimensionAspect()->TextVerticalPosition();
ArrowPos = theIO->DimensionAspect()->ArrowOrientation();
} }
//================================================================================= //=================================================================================
@ -154,6 +158,7 @@ void GEOMGUI_DimensionProperty::Diameter::Update( Handle(AIS_DiameterDimension)&
Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect(); Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
aStyle->SetTextHorizontalPosition( TextHPos ); aStyle->SetTextHorizontalPosition( TextHPos );
aStyle->SetTextVerticalPosition( TextVPos ); aStyle->SetTextVerticalPosition( TextVPos );
aStyle->SetArrowOrientation( ArrowPos );
theIO->SetDimensionAspect( aStyle ); theIO->SetDimensionAspect( aStyle );
} }
@ -189,7 +194,8 @@ bool GEOMGUI_DimensionProperty::Diameter::operator == (const Diameter& theOther)
if ( Flyout != theOther.Flyout if ( Flyout != theOther.Flyout
|| TextHPos != theOther.TextHPos || TextHPos != theOther.TextHPos
|| TextVPos != theOther.TextVPos ) || TextVPos != theOther.TextVPos
|| ArrowPos != theOther.ArrowPos )
{ {
return false; return false;
} }
@ -212,6 +218,7 @@ void GEOMGUI_DimensionProperty::Angle::Init( const Handle(AIS_AngleDimension)& t
Flyout = theIO->GetFlyout(); Flyout = theIO->GetFlyout();
TextHPos = theIO->DimensionAspect()->TextHorizontalPosition(); TextHPos = theIO->DimensionAspect()->TextHorizontalPosition();
TextVPos = theIO->DimensionAspect()->TextVerticalPosition(); TextVPos = theIO->DimensionAspect()->TextVerticalPosition();
ArrowPos = theIO->DimensionAspect()->ArrowOrientation();
} }
//================================================================================= //=================================================================================
@ -233,6 +240,7 @@ void GEOMGUI_DimensionProperty::Angle::Update( Handle(AIS_AngleDimension)& theIO
Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect(); Handle(Prs3d_DimensionAspect) aStyle = new Prs3d_DimensionAspect();
aStyle->SetTextHorizontalPosition( TextHPos ); aStyle->SetTextHorizontalPosition( TextHPos );
aStyle->SetTextVerticalPosition( TextVPos ); aStyle->SetTextVerticalPosition( TextVPos );
aStyle->SetArrowOrientation( ArrowPos );
theIO->SetDimensionAspect( aStyle ); theIO->SetDimensionAspect( aStyle );
} }
@ -257,7 +265,8 @@ bool GEOMGUI_DimensionProperty::Angle::operator == (const Angle& theOther) const
if ( Flyout != theOther.Flyout if ( Flyout != theOther.Flyout
|| TextHPos != theOther.TextHPos || TextHPos != theOther.TextHPos
|| TextVPos != theOther.TextVPos ) || TextVPos != theOther.TextVPos
|| ArrowPos != theOther.ArrowPos )
{ {
return false; return false;
} }
@ -311,6 +320,15 @@ GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( const GEOMGUI_DimensionPro
} }
} }
//=================================================================================
// function : Init constructor
// purpose :
//=================================================================================
GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( SalomeApp_Study* theStudy, const std::string& theEntry )
{
LoadFromAttribute( theStudy, theEntry );
}
//================================================================================= //=================================================================================
// function : Destructor // function : Destructor
// purpose : // purpose :
@ -463,6 +481,8 @@ void GEOMGUI_DimensionProperty::AddRecord( const RecordPtr& theRecord )
//================================================================================= //=================================================================================
void GEOMGUI_DimensionProperty::RemoveRecord( const int theIndex ) void GEOMGUI_DimensionProperty::RemoveRecord( const int theIndex )
{ {
myNames.remove( theIndex );
myVisibility.remove( theIndex );
myRecords.remove( theIndex ); myRecords.remove( theIndex );
} }
@ -472,6 +492,8 @@ void GEOMGUI_DimensionProperty::RemoveRecord( const int theIndex )
//================================================================================= //=================================================================================
void GEOMGUI_DimensionProperty::Clear() void GEOMGUI_DimensionProperty::Clear()
{ {
myNames.clear();
myVisibility.clear();
myRecords.clear(); myRecords.clear();
} }
@ -647,13 +669,16 @@ void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
aLength->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++]; aLength->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
aLength->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++]; aLength->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
// point 1 [9,10,11] // arrow flags [9]
aLength->ArrowPos = (Prs3d_DimensionArrowOrientation) (int)aPacked[it++];
// point 1 [10,11,12]
Standard_Real aFirstX = aPacked[it++]; Standard_Real aFirstX = aPacked[it++];
Standard_Real aFirstY = aPacked[it++]; Standard_Real aFirstY = aPacked[it++];
Standard_Real aFirstZ = aPacked[it++]; Standard_Real aFirstZ = aPacked[it++];
aLength->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ ); aLength->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
// point 2 [12,13,14] // point 2 [13,14,15]
Standard_Real aSecondX = aPacked[it++]; Standard_Real aSecondX = aPacked[it++];
Standard_Real aSecondY = aPacked[it++]; Standard_Real aSecondY = aPacked[it++];
Standard_Real aSecondZ = aPacked[it++]; Standard_Real aSecondZ = aPacked[it++];
@ -681,22 +706,25 @@ void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
aDiam->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++]; aDiam->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
aDiam->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++]; aDiam->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
// circle location [9,10,11] // arrow flags [9]
aDiam->ArrowPos = (Prs3d_DimensionArrowOrientation) (int)aPacked[it++];
// circle location [10,11,12]
Standard_Real aLocX = (Standard_Real) aPacked[it++]; Standard_Real aLocX = (Standard_Real) aPacked[it++];
Standard_Real aLocY = (Standard_Real) aPacked[it++]; Standard_Real aLocY = (Standard_Real) aPacked[it++];
Standard_Real aLocZ = (Standard_Real) aPacked[it++]; Standard_Real aLocZ = (Standard_Real) aPacked[it++];
// circle normal [12,13,14] // circle normal [13,14,15]
Standard_Real aNormX = (Standard_Real) aPacked[it++]; Standard_Real aNormX = (Standard_Real) aPacked[it++];
Standard_Real aNormY = (Standard_Real) aPacked[it++]; Standard_Real aNormY = (Standard_Real) aPacked[it++];
Standard_Real aNormZ = (Standard_Real) aPacked[it++]; Standard_Real aNormZ = (Standard_Real) aPacked[it++];
// x-direction [15,16,17] // x-direction [16,17,18]
Standard_Real aXDirX = (Standard_Real) aPacked[it++]; Standard_Real aXDirX = (Standard_Real) aPacked[it++];
Standard_Real aXDirY = (Standard_Real) aPacked[it++]; Standard_Real aXDirY = (Standard_Real) aPacked[it++];
Standard_Real aXDirZ = (Standard_Real) aPacked[it++]; Standard_Real aXDirZ = (Standard_Real) aPacked[it++];
// radius [18] // radius [19]
Standard_Real aRadius = (Standard_Real) aPacked[it++]; Standard_Real aRadius = (Standard_Real) aPacked[it++];
gp_Ax2 anAx( gp_Pnt( aLocX, aLocY, aLocZ ), gp_Ax2 anAx( gp_Pnt( aLocX, aLocY, aLocZ ),
@ -720,22 +748,24 @@ void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
anAngle->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++]; anAngle->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
anAngle->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++]; anAngle->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
// point 1 [5,6,7] // arrow flags [5]
anAngle->ArrowPos = (Prs3d_DimensionArrowOrientation) (int)aPacked[it++];
// point 1 [6,7,8]
Standard_Real aFirstX = (Standard_Real) aPacked[it++]; Standard_Real aFirstX = (Standard_Real) aPacked[it++];
Standard_Real aFirstY = (Standard_Real) aPacked[it++]; Standard_Real aFirstY = (Standard_Real) aPacked[it++];
Standard_Real aFirstZ = (Standard_Real) aPacked[it++]; Standard_Real aFirstZ = (Standard_Real) aPacked[it++];
// point 2 [8,9,10] // point 2 [9,10,11]
Standard_Real aSecondX = (Standard_Real) aPacked[it++]; Standard_Real aSecondX = (Standard_Real) aPacked[it++];
Standard_Real aSecondY = (Standard_Real) aPacked[it++]; Standard_Real aSecondY = (Standard_Real) aPacked[it++];
Standard_Real aSecondZ = (Standard_Real) aPacked[it++]; Standard_Real aSecondZ = (Standard_Real) aPacked[it++];
// center [11,12,13] // center [12,13,14]
Standard_Real aCenterX = (Standard_Real) aPacked[it++]; Standard_Real aCenterX = (Standard_Real) aPacked[it++];
Standard_Real aCenterY = (Standard_Real) aPacked[it++]; Standard_Real aCenterY = (Standard_Real) aPacked[it++];
Standard_Real aCenterZ = (Standard_Real) aPacked[it++]; Standard_Real aCenterZ = (Standard_Real) aPacked[it++];
// points point 1 [4-6], point 2 [7-9], center [10-12]
anAngle->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ ); anAngle->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
anAngle->SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ ); anAngle->SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
anAngle->CenterPoint = gp_Pnt( aCenterX, aCenterY, aCenterZ ); anAngle->CenterPoint = gp_Pnt( aCenterX, aCenterY, aCenterZ );
@ -806,12 +836,15 @@ void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
aPacked.push_back( (double) aProps->TextHPos ); aPacked.push_back( (double) aProps->TextHPos );
aPacked.push_back( (double) aProps->TextVPos ); aPacked.push_back( (double) aProps->TextVPos );
// point 1 [9,10,11] // arrow flags [9]
aPacked.push_back( (double) aProps->ArrowPos );
// point 1 [10,11,12]
aPacked.push_back( (double) aProps->FirstPoint.X() ); aPacked.push_back( (double) aProps->FirstPoint.X() );
aPacked.push_back( (double) aProps->FirstPoint.Y() ); aPacked.push_back( (double) aProps->FirstPoint.Y() );
aPacked.push_back( (double) aProps->FirstPoint.Z() ); aPacked.push_back( (double) aProps->FirstPoint.Z() );
// point 2 [12,13,14] // point 2 [13,14,15]
aPacked.push_back( (double) aProps->SecondPoint.X() ); aPacked.push_back( (double) aProps->SecondPoint.X() );
aPacked.push_back( (double) aProps->SecondPoint.Y() ); aPacked.push_back( (double) aProps->SecondPoint.Y() );
aPacked.push_back( (double) aProps->SecondPoint.Z() ); aPacked.push_back( (double) aProps->SecondPoint.Z() );
@ -837,22 +870,25 @@ void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
aPacked.push_back( (double) aProps->TextHPos ); aPacked.push_back( (double) aProps->TextHPos );
aPacked.push_back( (double) aProps->TextVPos ); aPacked.push_back( (double) aProps->TextVPos );
// circle location [9,10,11] // arrow flags [9]
aPacked.push_back( (double) aProps->ArrowPos );
// circle location [10,11,12]
aPacked.push_back( (double) aProps->Circle.Location().X() ); aPacked.push_back( (double) aProps->Circle.Location().X() );
aPacked.push_back( (double) aProps->Circle.Location().Y() ); aPacked.push_back( (double) aProps->Circle.Location().Y() );
aPacked.push_back( (double) aProps->Circle.Location().Z() ); aPacked.push_back( (double) aProps->Circle.Location().Z() );
// circle normal [12,13,14] // circle normal [13,14,15]
aPacked.push_back( (double) aProps->Circle.Axis().Direction().X() ); aPacked.push_back( (double) aProps->Circle.Axis().Direction().X() );
aPacked.push_back( (double) aProps->Circle.Axis().Direction().Y() ); aPacked.push_back( (double) aProps->Circle.Axis().Direction().Y() );
aPacked.push_back( (double) aProps->Circle.Axis().Direction().Z() ); aPacked.push_back( (double) aProps->Circle.Axis().Direction().Z() );
// x-direction [15,16,17] // x-direction [16,17,18]
aPacked.push_back( (double) aProps->Circle.XAxis().Direction().X() ); aPacked.push_back( (double) aProps->Circle.XAxis().Direction().X() );
aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Y() ); aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Y() );
aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Z() ); aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Z() );
// radius [18] // radius [19]
aPacked.push_back( (double) aProps->Circle.Radius() ); aPacked.push_back( (double) aProps->Circle.Radius() );
break; break;
} }
@ -868,17 +904,20 @@ void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
aPacked.push_back( (double) aProps->TextHPos ); aPacked.push_back( (double) aProps->TextHPos );
aPacked.push_back( (double) aProps->TextVPos ); aPacked.push_back( (double) aProps->TextVPos );
// point 1 [5,6,7] // arrow flags [5]
aPacked.push_back( (double) aProps->ArrowPos );
// point 1 [6,7,8]
aPacked.push_back( (double) aProps->FirstPoint.X() ); aPacked.push_back( (double) aProps->FirstPoint.X() );
aPacked.push_back( (double) aProps->FirstPoint.Y() ); aPacked.push_back( (double) aProps->FirstPoint.Y() );
aPacked.push_back( (double) aProps->FirstPoint.Z() ); aPacked.push_back( (double) aProps->FirstPoint.Z() );
// point 2 [8,9,10] // point 2 [9,10,11]
aPacked.push_back( (double) aProps->SecondPoint.X() ); aPacked.push_back( (double) aProps->SecondPoint.X() );
aPacked.push_back( (double) aProps->SecondPoint.Y() ); aPacked.push_back( (double) aProps->SecondPoint.Y() );
aPacked.push_back( (double) aProps->SecondPoint.Z() ); aPacked.push_back( (double) aProps->SecondPoint.Z() );
// center [11,12,13] // center [12,13,14]
aPacked.push_back( (double) aProps->CenterPoint.X() ); aPacked.push_back( (double) aProps->CenterPoint.X() );
aPacked.push_back( (double) aProps->CenterPoint.Y() ); aPacked.push_back( (double) aProps->CenterPoint.Y() );
aPacked.push_back( (double) aProps->CenterPoint.Z() ); aPacked.push_back( (double) aProps->CenterPoint.Z() );

View File

@ -53,9 +53,9 @@ class SalomeApp_Study;
* (name);(is_visible);(dimension type);(dimension property list); * (name);(is_visible);(dimension type);(dimension property list);
* *
* The following packing scheme is used to store dimension data: * The following packing scheme is used to store dimension data:
* Length: (plane)[0-3] (flyout)[4] (text flags)[5-6] (p1)[7-9] (pnt2)[10-12] * Length: (plane)[0-3] (flyout)[4] (text flags)[5-6] (arrow flag)[7] (p1)[8-10] (pnt2)[11-13]
* Diam: (plane)[0-3] (flyout)[4] (text flags)[5-6] (circle loc, xdir, ydir, rad)[7-16] * Diam: (plane)[0-3] (flyout)[4] (text flags)[5-6] (arrow flag)[7] (circle loc, xdir, ydir, rad)[8-17]
* Angle: (flyout)[0] (text flags)[1-2] (p1)[3-5] (p2)[6-8] (center)[9-11] * Angle: (flyout)[0] (text flags)[1-2] (arrow flag)[3] (p1)[4-6] (p2)[7-9] (center)[10-12]
*/ */
class Standard_EXPORT GEOMGUI_DimensionProperty class Standard_EXPORT GEOMGUI_DimensionProperty
{ {
@ -109,7 +109,8 @@ public:
Plane( gp::XOY() ), Plane( gp::XOY() ),
Flyout( 0.0 ), Flyout( 0.0 ),
TextHPos( Prs3d_DTHP_Fit ), TextHPos( Prs3d_DTHP_Fit ),
TextVPos( Prs3d_DTVP_Center ) TextVPos( Prs3d_DTVP_Center ),
ArrowPos( Prs3d_DAO_Fit )
{} {}
Length( const Length& theOther ) : Length( const Length& theOther ) :
@ -119,7 +120,8 @@ public:
Plane( theOther.Plane ), Plane( theOther.Plane ),
Flyout( theOther.Flyout ), Flyout( theOther.Flyout ),
TextHPos( theOther.TextHPos ), TextHPos( theOther.TextHPos ),
TextVPos( theOther.TextVPos ) TextVPos( theOther.TextVPos ),
ArrowPos( theOther.ArrowPos )
{} {}
~Length() {} ~Length() {}
@ -150,6 +152,7 @@ public:
double Flyout; double Flyout;
Prs3d_DimensionTextHorizontalPosition TextHPos; Prs3d_DimensionTextHorizontalPosition TextHPos;
Prs3d_DimensionTextVerticalPosition TextVPos; Prs3d_DimensionTextVerticalPosition TextVPos;
Prs3d_DimensionArrowOrientation ArrowPos;
}; };
/*! /*!
@ -162,7 +165,8 @@ public:
Plane( gp::XOY() ), Plane( gp::XOY() ),
Flyout( 0.0 ), Flyout( 0.0 ),
TextHPos( Prs3d_DTHP_Fit ), TextHPos( Prs3d_DTHP_Fit ),
TextVPos( Prs3d_DTVP_Center ) TextVPos( Prs3d_DTVP_Center ),
ArrowPos( Prs3d_DAO_Fit )
{} {}
Diameter( const Diameter& theOther ) : Diameter( const Diameter& theOther ) :
@ -171,7 +175,8 @@ public:
Plane( theOther.Plane ), Plane( theOther.Plane ),
Flyout( theOther.Flyout ), Flyout( theOther.Flyout ),
TextHPos( theOther.TextHPos ), TextHPos( theOther.TextHPos ),
TextVPos( theOther.TextVPos ) TextVPos( theOther.TextVPos ),
ArrowPos( theOther.ArrowPos )
{} {}
~Diameter() {} ~Diameter() {}
@ -201,6 +206,7 @@ public:
double Flyout; double Flyout;
Prs3d_DimensionTextHorizontalPosition TextHPos; Prs3d_DimensionTextHorizontalPosition TextHPos;
Prs3d_DimensionTextVerticalPosition TextVPos; Prs3d_DimensionTextVerticalPosition TextVPos;
Prs3d_DimensionArrowOrientation ArrowPos;
}; };
/*! /*!
@ -215,7 +221,8 @@ public:
CenterPoint( gp::Origin() ), CenterPoint( gp::Origin() ),
Flyout( 0.0 ), Flyout( 0.0 ),
TextHPos( Prs3d_DTHP_Fit ), TextHPos( Prs3d_DTHP_Fit ),
TextVPos( Prs3d_DTVP_Center ) TextVPos( Prs3d_DTVP_Center ),
ArrowPos( Prs3d_DAO_Fit )
{} {}
Angle( const Angle& theOther ) : Angle( const Angle& theOther ) :
@ -225,7 +232,8 @@ public:
CenterPoint( theOther.CenterPoint ), CenterPoint( theOther.CenterPoint ),
Flyout( theOther.Flyout ), Flyout( theOther.Flyout ),
TextHPos( theOther.TextHPos ), TextHPos( theOther.TextHPos ),
TextVPos( theOther.TextVPos ) TextVPos( theOther.TextVPos ),
ArrowPos( theOther.ArrowPos )
{} {}
~Angle() {} ~Angle() {}
@ -256,6 +264,7 @@ public:
double Flyout; double Flyout;
Prs3d_DimensionTextHorizontalPosition TextHPos; Prs3d_DimensionTextHorizontalPosition TextHPos;
Prs3d_DimensionTextVerticalPosition TextVPos; Prs3d_DimensionTextVerticalPosition TextVPos;
Prs3d_DimensionArrowOrientation ArrowPos;
}; };
typedef QSharedPointer<Record> RecordPtr; typedef QSharedPointer<Record> RecordPtr;
@ -272,6 +281,11 @@ public:
*/ */
GEOMGUI_DimensionProperty( const GEOMGUI_DimensionProperty& theOther ); GEOMGUI_DimensionProperty( const GEOMGUI_DimensionProperty& theOther );
/*!
* \brief Constructor. Inits property from attribute.
*/
GEOMGUI_DimensionProperty( SalomeApp_Study* theStudy, const std::string& theEntry );
/*! /*!
* \brief Destructor. * \brief Destructor.
*/ */
@ -287,6 +301,14 @@ public:
*/ */
bool operator == (const GEOMGUI_DimensionProperty &theOther) const; bool operator == (const GEOMGUI_DimensionProperty &theOther) const;
/*!
* \brief Overload comparsion.
*/
bool operator != (const GEOMGUI_DimensionProperty &theOther) const
{
return !(operator == (theOther));
}
public: public:
/*! /*!

View File

@ -24,6 +24,7 @@
// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com) // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
#include "GEOMGUI_Selection.h" #include "GEOMGUI_Selection.h"
#include <GEOMGUI_DimensionProperty.h>
#include "GeometryGUI.h" #include "GeometryGUI.h"
#include "GEOM_Displayer.h" #include "GEOM_Displayer.h"
@ -178,6 +179,10 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
v = isPhysicalMaterial(idx); v = isPhysicalMaterial(idx);
else if ( p == "isFolder" ) else if ( p == "isFolder" )
v = isFolder(idx); v = isFolder(idx);
else if ( p == "hasHiddenDimensions" )
v = hasHiddenDimensions(idx);
else if ( p == "hasVisibleDimensions" )
v = hasVisibleDimensions(idx);
else else
v = LightApp_Selection::parameter( idx, p ); v = LightApp_Selection::parameter( idx, p );
@ -682,3 +687,59 @@ bool GEOMGUI_Selection::isFolder( const int index ) const
return res; return res;
} }
bool GEOMGUI_Selection::hasDimensions( const int theIndex, bool& theHidden, bool& theVisible ) const
{
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( study() );
if ( !appStudy )
{
return false;
}
QString anEntry = entry( theIndex );
_PTR(Study) aStudy = appStudy->studyDS();
if ( !aStudy || anEntry.isNull() )
{
return false;
}
GEOMGUI_DimensionProperty aDimensions( appStudy, anEntry.toStdString() );
theHidden = false;
theVisible = false;
for ( int it = 0; it < aDimensions.GetNumber(); ++it )
{
if ( aDimensions.IsVisible( it ) )
theVisible = true;
else
theHidden = true;
}
return aDimensions.GetNumber() > 0;
}
bool GEOMGUI_Selection::hasHiddenDimensions( const int theIndex ) const
{
bool isAnyVisible = false;
bool isAnyHidden = false;
if ( !hasDimensions( theIndex, isAnyHidden, isAnyVisible ) )
{
return false;
}
return isAnyHidden;
}
bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const
{
bool isAnyVisible = false;
bool isAnyHidden = false;
if ( !hasDimensions( theIndex, isAnyHidden, isAnyVisible ) )
{
return false;
}
return isAnyVisible;
}

View File

@ -78,6 +78,11 @@ private:
bool isComponent( const int ) const; bool isComponent( const int ) const;
bool isFolder( const int ) const; bool isFolder( const int ) const;
bool hasDimensions( const int, bool&, bool& ) const;
bool hasHiddenDimensions( const int ) const;
bool hasVisibleDimensions( const int ) const;
GEOM::GEOM_Object_ptr getObject( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const;
GEOM::GEOM_BaseObject_ptr getBaseObject( const int ) const; GEOM::GEOM_BaseObject_ptr getBaseObject( const int ) const;

View File

@ -1100,6 +1100,7 @@ void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& t
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown ); aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
aStyle->MakeText3d( Standard_True ); aStyle->MakeText3d( Standard_True );
aStyle->MakeTextShaded( Standard_True ); aStyle->MakeTextShaded( Standard_True );
aStyle->SetExtensionSize( aFontHeight * 0.5 );
aStyle->TextAspect()->SetHeight( aFontHeight ); aStyle->TextAspect()->SetHeight( aFontHeight );
aStyle->ArrowAspect()->SetLength( anArrowLength ); aStyle->ArrowAspect()->SetLength( anArrowLength );
aStyle->LineAspect()->SetWidth( aLineWidth ); aStyle->LineAspect()->SetWidth( aLineWidth );
@ -1107,6 +1108,28 @@ void GEOM_Displayer::updateDimensions( const Handle(SALOME_InteractiveObject)& t
aStyle->SetTextVerticalPosition( aPrs->DimensionAspect()->TextVerticalPosition() ); aStyle->SetTextVerticalPosition( aPrs->DimensionAspect()->TextVerticalPosition() );
aPrs->SetDimensionAspect( aStyle ); aPrs->SetDimensionAspect( aStyle );
aPrs->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 ); aPrs->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );
aPrs->Attributes()->SetDimLengthDisplayUnits( aUnitsLength.toLatin1().data() );
aPrs->Attributes()->SetDimAngleDisplayUnits( aUnitsAngle.toLatin1().data() );
if ( aPrs->IsKind( STANDARD_TYPE(AIS_AngleDimension) ) )
{
// show degree symbol for dimension instead of label "deg"
if ( aUnitsAngle == "deg" )
{
aPrs->SetSpecialSymbol(0xB0);
aPrs->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
aStyle->MakeUnitsDisplayed(Standard_False);
}
else
{
aPrs->SetDisplaySpecialSymbol(AIS_DSS_No);
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
}
}
else
{
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
}
aListOfIO.Append( aPrs ); aListOfIO.Append( aPrs );
} }

View File

@ -3276,6 +3276,10 @@ Please, select face, shell or solid and try again</translation>
<source>PREF_DIMENSIONS_ANGLE_UNITS</source> <source>PREF_DIMENSIONS_ANGLE_UNITS</source>
<translation>Angle measurement units</translation> <translation>Angle measurement units</translation>
</message> </message>
<message>
<source>PREF_DIMENSIONS_DEFAULT_FLYOUT</source>
<translation>Default flyout length</translation>
</message>
<message> <message>
<source>PREF_DIMENSIONS_SHOW_UNITS</source> <source>PREF_DIMENSIONS_SHOW_UNITS</source>
<translation>Show units of measurement</translation> <translation>Show units of measurement</translation>
@ -4732,6 +4736,30 @@ Please, select face, shell or solid and try again</translation>
<source>STB_MANAGE_DIMENSIONS</source> <source>STB_MANAGE_DIMENSIONS</source>
<translation>Manage measurement dimensions of an object</translation> <translation>Manage measurement dimensions of an object</translation>
</message> </message>
<message>
<source>MEN_POP_SHOW_ALL_DIMENSIONS</source>
<translation>Show all dimensions</translation>
</message>
<message>
<source>STB_POP_SHOW_ALL_DIMENSIONS</source>
<translation>Show all hidden measures (dimension) created for the object</translation>
</message>
<message>
<source>TOP_POP_SHOW_ALL_DIMENSIONS</source>
<translation>Show all hidden measures (dimension) created for the object</translation>
</message>
<message>
<source>MEN_POP_HIDE_ALL_DIMENSIONS</source>
<translation>Hide all dimensions</translation>
</message>
<message>
<source>STB_POP_HIDE_ALL_DIMENSIONS</source>
<translation>Show all visible measures (dimension) created for the object</translation>
</message>
<message>
<source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
<translation>Show all visible measures (dimension) created for the object</translation>
</message>
<message> <message>
<source>TOP_POP_AUTO_COLOR</source> <source>TOP_POP_AUTO_COLOR</source>
<translation>Auto color</translation> <translation>Auto color</translation>
@ -6166,6 +6194,16 @@ Number of sketch points too small</translation>
<source>WRN_TITLE_UNSAVED</source> <source>WRN_TITLE_UNSAVED</source>
<translation>Unsaved changes</translation> <translation>Unsaved changes</translation>
</message> </message>
<message>
<source>WRN_MSG_CHANGES_LOST</source>
<translation>The unsaved changes will be lost.
Do you wish to continue?</translation>
</message>
<message>
<source>WRN_MSG_CHANGES_SAVE</source>
<translation>The unsaved changes will be lost.
Do you wish to save them?</translation>
</message>
<message> <message>
<source>WRN_MSG_UNSAVED</source> <source>WRN_MSG_UNSAVED</source>
<translation>The unsaved changes will be lost. <translation>The unsaved changes will be lost.

View File

@ -3276,6 +3276,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>PREF_DIMENSIONS_ANGLE_UNITS</source> <source>PREF_DIMENSIONS_ANGLE_UNITS</source>
<translation type="unfinished">Angle measurement units</translation> <translation type="unfinished">Angle measurement units</translation>
</message> </message>
<message>
<source>PREF_DIMENSIONS_DEFAULT_FLYOUT</source>
<translation type="unfinished">Default flyout length</translation>
</message>
<message> <message>
<source>PREF_DIMENSIONS_SHOW_UNITS</source> <source>PREF_DIMENSIONS_SHOW_UNITS</source>
<translation type="unfinished">Show units of measurement</translation> <translation type="unfinished">Show units of measurement</translation>
@ -4732,6 +4736,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>STB_MANAGE_DIMENSIONS</source> <source>STB_MANAGE_DIMENSIONS</source>
<translation type="unfinished">Manage measurement dimensions of an object</translation> <translation type="unfinished">Manage measurement dimensions of an object</translation>
</message> </message>
<message>
<source>MEN_POP_SHOW_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all dimensions</translation>
</message>
<message>
<source>STB_POP_SHOW_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all hidden measures (dimension) created for the object</translation>
</message>
<message>
<source>TOP_POP_SHOW_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all hidden measures (dimension) created for the object</translation>
</message>
<message>
<source>MEN_POP_HIDE_ALL_DIMENSIONS</source>
<translation type="unfinished">Hide all dimensions</translation>
</message>
<message>
<source>STB_POP_HIDE_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all visible measures (dimension) created for the object</translation>
</message>
<message>
<source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all visible measures (dimension) created for the object</translation>
</message>
<message> <message>
<source>TOP_POP_AUTO_COLOR</source> <source>TOP_POP_AUTO_COLOR</source>
<translation>Couleur automatique</translation> <translation>Couleur automatique</translation>
@ -6166,6 +6194,16 @@ Le nombre de points n&apos;est pas suffisant</translation>
<source>WRN_TITLE_UNSAVED</source> <source>WRN_TITLE_UNSAVED</source>
<translation type="unfinished">Unsaved changes</translation> <translation type="unfinished">Unsaved changes</translation>
</message> </message>
<message>
<source>WRN_MSG_CHANGES_LOST</source>
<translation type="unfinished">The unsaved changes will be lost.
Do you wish to continue?</translation>
</message>
<message>
<source>WRN_MSG_CHANGES_SAVE</source>
<translation type="unfinished">The unsaved changes will be lost.
Do you wish to save them?</translation>
</message>
<message> <message>
<source>WRN_MSG_UNSAVED</source> <source>WRN_MSG_UNSAVED</source>
<translation type="unfinished">The unsaved changes will be lost. <translation type="unfinished">The unsaved changes will be lost.

View File

@ -3271,6 +3271,10 @@
<source>PREF_DIMENSIONS_ANGLE_UNITS</source> <source>PREF_DIMENSIONS_ANGLE_UNITS</source>
<translation type="unfinished">Angle measurement units</translation> <translation type="unfinished">Angle measurement units</translation>
</message> </message>
<message>
<source>PREF_DIMENSIONS_DEFAULT_FLYOUT</source>
<translation type="unfinished">Default flyout length</translation>
</message>
<message> <message>
<source>PREF_DIMENSIONS_SHOW_UNITS</source> <source>PREF_DIMENSIONS_SHOW_UNITS</source>
<translation type="unfinished">Show units of measurement</translation> <translation type="unfinished">Show units of measurement</translation>
@ -4727,6 +4731,30 @@
<source>STB_MANAGE_DIMENSIONS</source> <source>STB_MANAGE_DIMENSIONS</source>
<translation type="unfinished">Manage measurement dimensions of an object</translation> <translation type="unfinished">Manage measurement dimensions of an object</translation>
</message> </message>
<message>
<source>MEN_POP_SHOW_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all dimensions</translation>
</message>
<message>
<source>STB_POP_SHOW_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all hidden measures (dimension) created for the object</translation>
</message>
<message>
<source>TOP_POP_SHOW_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all hidden measures (dimension) created for the object</translation>
</message>
<message>
<source>MEN_POP_HIDE_ALL_DIMENSIONS</source>
<translation type="unfinished">Hide all dimensions</translation>
</message>
<message>
<source>STB_POP_HIDE_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all visible measures (dimension) created for the object</translation>
</message>
<message>
<source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
<translation type="unfinished">Show all visible measures (dimension) created for the object</translation>
</message>
<message> <message>
<source>TOP_POP_AUTO_COLOR</source> <source>TOP_POP_AUTO_COLOR</source>
<translation></translation> <translation></translation>
@ -6158,6 +6186,16 @@
<source>WRN_TITLE_UNSAVED</source> <source>WRN_TITLE_UNSAVED</source>
<translation type="unfinished">Unsaved changes</translation> <translation type="unfinished">Unsaved changes</translation>
</message> </message>
<message>
<source>WRN_MSG_CHANGES_LOST</source>
<translation type="unfinished">The unsaved changes will be lost.
Do you wish to continue?</translation>
</message>
<message>
<source>WRN_MSG_CHANGES_SAVE</source>
<translation type="unfinished">The unsaved changes will be lost.
Do you wish to save them?</translation>
</message>
<message> <message>
<source>WRN_MSG_UNSAVED</source> <source>WRN_MSG_UNSAVED</source>
<translation type="unfinished">The unsaved changes will be lost. <translation type="unfinished">The unsaved changes will be lost.

View File

@ -635,6 +635,8 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES
case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS
case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS case GEOMOp::OpManageDimensions: // MENU MEASURE - MANAGE DIMENSIONS
case GEOMOp::OpShowAllDimensions: // POPUP MENU - SHOW ALL DIMENSIONS
case GEOMOp::OpHideAllDimensions: // POPUP MENU - HIDE ALL DIMENSIONS
libName = "MeasureGUI"; libName = "MeasureGUI";
break; break;
case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE case GEOMOp::OpGroupCreate: // MENU GROUP - CREATE
@ -1071,6 +1073,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" ); createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" ); createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" ); createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
// Create actions for increase/decrease transparency shortcuts // Create actions for increase/decrease transparency shortcuts
createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false, createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
@ -1588,6 +1592,14 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children mgr->insert( action(GEOMOp::OpShowOnlyChildren ), -1, -1 ); // display only children
mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule ); mgr->setRule(action(GEOMOp::OpShowOnlyChildren ), (canDisplay + "and ($type in {%1}) and client='ObjectBrowser' and hasChildren=true").arg( types ), QtxPopupMgr::VisibleRule );
QString aDimensionRule = "($component={'GEOM'}) and selcount=1 and isVisible and type='Shape' and %1";
mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpShowAllDimensions ), -1, -1 ); // show all dimensions
mgr->setRule( action( GEOMOp::OpShowAllDimensions ), aDimensionRule.arg( "hasHiddenDimensions" ), QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpHideAllDimensions ), -1, -1 ); // hide all dimensions
mgr->setRule( action( GEOMOp::OpHideAllDimensions ), aDimensionRule.arg( "hasVisibleDimensions" ), QtxPopupMgr::VisibleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object mgr->insert( action( GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpUnpublishObject ), QString("client='ObjectBrowser' and $type in {'Shape' 'Group' 'Field' 'FieldStep'} and selcount>0"), QtxPopupMgr::VisibleRule );
@ -2375,11 +2387,19 @@ void GeometryGUI::createPreferences()
setPreferenceProperty( aDimLineWidthId, "min", 1 ); setPreferenceProperty( aDimLineWidthId, "min", 1 );
setPreferenceProperty( aDimLineWidthId, "max", 5 ); setPreferenceProperty( aDimLineWidthId, "max", 5 );
addPreference( tr( "PREF_DIMENSIONS_FONT_HEIGHT" ), aDimGroupId, int aDimFontHeightId = addPreference( tr( "PREF_DIMENSIONS_FONT_HEIGHT" ), aDimGroupId,
LightApp_Preferences::DblSpin, "Geometry", "dimensions_font_height" ); LightApp_Preferences::DblSpin, "Geometry", "dimensions_font_height" );
addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId, setPreferenceProperty( aDimFontHeightId, "min", 1e-9 );
LightApp_Preferences::IntSpin, "Geometry", "dimensions_arrow_length" ); setPreferenceProperty( aDimFontHeightId, "max", 1e+9 );
setPreferenceProperty( aDimFontHeightId, "precision", 9 );
int aDimArrLengthId = addPreference( tr( "PREF_DIMENSIONS_ARROW_LENGTH" ), aDimGroupId,
LightApp_Preferences::DblSpin, "Geometry", "dimensions_arrow_length" );
setPreferenceProperty( aDimArrLengthId, "min", 1e-9 );
setPreferenceProperty( aDimArrLengthId, "max", 1e+9 );
setPreferenceProperty( aDimArrLengthId, "precision", 9 );
int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId, int aLengthUnitsId = addPreference( tr( "PREF_DIMENSIONS_LENGTH_UNITS" ), aDimGroupId,
LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" ); LightApp_Preferences::Selector, "Geometry", "dimensions_length_units" );
@ -2404,6 +2424,13 @@ void GeometryGUI::createPreferences()
setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits ); setPreferenceProperty( aLengthUnitsId, "strings", aListOfLengthUnits );
setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits ); setPreferenceProperty( anAngUnitsId, "strings", aListOfAngUnits );
int aDimDefFlyout = addPreference( tr( "PREF_DIMENSIONS_DEFAULT_FLYOUT" ), aDimGroupId,
LightApp_Preferences::DblSpin, "Geometry", "dimensions_default_flyout" );
setPreferenceProperty( aDimDefFlyout, "min", 1e-9 );
setPreferenceProperty( aDimDefFlyout, "max", 1e+9 );
setPreferenceProperty( aDimDefFlyout, "precision", 9 );
int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId ); int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
setPreferenceProperty( isoGroup, "columns", 2 ); setPreferenceProperty( isoGroup, "columns", 2 );
int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup, int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,

View File

@ -190,6 +190,8 @@ namespace GEOMOp {
OpCheckSelfInters = 5012, // MENU MEASURES - CHECK SELF INTERSECTIONS OpCheckSelfInters = 5012, // MENU MEASURES - CHECK SELF INTERSECTIONS
OpGetNonBlocks = 5013, // MENU MEASURES - GET NON BLOCKS OpGetNonBlocks = 5013, // MENU MEASURES - GET NON BLOCKS
OpManageDimensions = 5014, // MENU MEASURES - MANAGE DIMENSIONS OpManageDimensions = 5014, // MENU MEASURES - MANAGE DIMENSIONS
OpShowAllDimensions = 5015, // POPUP MENU - SHOW ALL DIMENSIONS
OpHideAllDimensions = 5016, // POPUP MENU - HIDE ALL DIMENSIONS
// GroupGUI --------------------//-------------------------------- // GroupGUI --------------------//--------------------------------
OpGroupCreate = 6000, // MENU GROUP - CREATE OpGroupCreate = 6000, // MENU GROUP - CREATE
OpGroupEdit = 6001, // MENU GROUP - EDIT OpGroupEdit = 6001, // MENU GROUP - EDIT

View File

@ -28,8 +28,14 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include "GeometryGUI_Operations.h" #include "GeometryGUI_Operations.h"
#include <GEOMGUI_DimensionProperty.h>
#include <LightApp_SelectionMgr.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include "MeasureGUI_PropertiesDlg.h" // Method PROPERTIES #include "MeasureGUI_PropertiesDlg.h" // Method PROPERTIES
#include "MeasureGUI_CenterMassDlg.h" // Method CENTER MASS #include "MeasureGUI_CenterMassDlg.h" // Method CENTER MASS
@ -124,6 +130,12 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
case GEOMOp::OpManageDimensions: case GEOMOp::OpManageDimensions:
dlg = new MeasureGUI_ManageDimensionsDlg( getGeometryGUI(), parent ); dlg = new MeasureGUI_ManageDimensionsDlg( getGeometryGUI(), parent );
break; // MANAGE DIMENSIONS break; // MANAGE DIMENSIONS
case GEOMOp::OpShowAllDimensions:
ChangeDimensionsVisibility( true );
break; // SHOW ALL DIMENSIONS
case GEOMOp::OpHideAllDimensions:
ChangeDimensionsVisibility( false );
break; // HIDE ALL DIMENSIONS
default: default:
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
break; break;
@ -136,6 +148,56 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
return true; return true;
} }
//=======================================================================
// function : ChangeDimensionsVisibility
// purpose :
//=======================================================================
void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible )
{
SalomeApp_Application* anApp = getGeometryGUI()->getApp();
if (!anApp)
{
return;
}
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
if ( !anActiveStudy )
{
return;
}
LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr();
if ( !aSelMgr )
{
return;
}
SALOME_ListIO aListIO;
aSelMgr->selectedObjects( aListIO );
if ( aListIO.Extent() != 1 )
{
return;
}
Handle(SALOME_InteractiveObject) anIObject = aListIO.First();
if ( !anIObject->hasEntry() )
{
return;
}
SUIT_OverrideCursor();
GEOMGUI_DimensionProperty aDimensions( anActiveStudy, anIObject->getEntry() );
for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt )
{
aDimensions.SetVisible( anIt, theIsVisible );
}
aDimensions.SaveToAttribute( anActiveStudy, anIObject->getEntry() );
GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true );
}
//===================================================================================== //=====================================================================================
// EXPORTED METHODS // EXPORTED METHODS

View File

@ -46,6 +46,9 @@ public:
~MeasureGUI(); ~MeasureGUI();
bool OnGUIEvent( int, SUIT_Desktop* ); bool OnGUIEvent( int, SUIT_Desktop* );
// Show/hide all dimension created for object
void ChangeDimensionsVisibility( const bool theIsVisible );
}; };
#endif // MEASUREGUI_H #endif // MEASUREGUI_H

View File

@ -34,6 +34,9 @@
#include <GEOMUtils.hxx> #include <GEOMUtils.hxx>
#include <GEOMGUI_DimensionProperty.h> #include <GEOMGUI_DimensionProperty.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewPort3d.h>
#include <LightApp_SelectionMgr.h> #include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <SalomeApp_DataObject.h> #include <SalomeApp_DataObject.h>
@ -127,7 +130,13 @@ MeasureGUI_CreateDimensionDlg::MeasureGUI_CreateDimensionDlg( const GEOM::GeomOb
myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent ); myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent );
myDiameterArgs->setVisible( false );
myAngleArgs ->setVisible( false );
myLengthArgs ->setVisible( true );
Init(); Init();
setHelpFileName("add_dimension_page.html");
} }
//================================================================================= //=================================================================================
@ -404,6 +413,7 @@ void MeasureGUI_CreateDimensionDlg::StartLocalEditing()
anAISContext->SetZLayer( myDimension, myEditingLayer ); anAISContext->SetZLayer( myDimension, myEditingLayer );
anAISContext->Activate( myDimension, AIS_DSM_Line ); anAISContext->Activate( myDimension, AIS_DSM_Line );
anAISContext->Activate( myDimension, AIS_DSM_Text ); anAISContext->Activate( myDimension, AIS_DSM_Text );
anAISContext->Redisplay( myDimension );
} }
//================================================================================= //=================================================================================
@ -434,14 +444,15 @@ void MeasureGUI_CreateDimensionDlg::StopLocalEditing()
//================================================================================= //=================================================================================
void MeasureGUI_CreateDimensionDlg::Init() void MeasureGUI_CreateDimensionDlg::Init()
{ {
myDimension = NULL;
StopLocalEditing(); StopLocalEditing();
erasePreview(); erasePreview();
myDiameterArgs->setVisible( false ); myDiameterArgs->Reset();
myAngleArgs ->setVisible( false );
myLengthArgs ->setVisible( true );
myLengthArgs->Reset(); myLengthArgs->Reset();
myAngleArgs->Reset();
myRBGroup->button( TypeButtonID_Length )->click(); myRBGroup->button( TypeButtonID_Length )->click();
} }
@ -461,11 +472,28 @@ Handle(AIS_Dimension) MeasureGUI_CreateDimensionDlg::CreateDimension()
int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 ); int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 ); double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 ); double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
double aDefFlyout = aResMgr->doubleValue ( "Geometry", "dimensions_default_flyout", 20 );
bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false ); bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" ); QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" ); QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
MeasureGUI_DimensionCreateTool aTool( myGeomGUI ); OCCViewer_ViewWindow* anActiveView = NULL;
SalomeApp_Application* anApp = myGeomGUI->getApp();
if ( anApp )
{
OCCViewer_ViewManager* aViewMgr = (OCCViewer_ViewManager*) anApp->getViewManager( OCCViewer_Viewer::Type(), false );
if ( aViewMgr )
{
anActiveView = (OCCViewer_ViewWindow*) aViewMgr->getActiveView();
}
}
MeasureGUI_DimensionCreateTool aTool;
aTool.Settings.DefaultFlyout = aDefFlyout;
aTool.Settings.ActiveView = anActiveView ? anActiveView->getViewPort()->getView() : NULL;
switch ( getConstructorId() ) switch ( getConstructorId() )
{ {
@ -559,9 +587,33 @@ Handle(AIS_Dimension) MeasureGUI_CreateDimensionDlg::CreateDimension()
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown ); aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
aStyle->MakeText3d( Standard_True ); aStyle->MakeText3d( Standard_True );
aStyle->MakeTextShaded( Standard_True ); aStyle->MakeTextShaded( Standard_True );
aStyle->SetExtensionSize( aFontHeight * 0.5 );
aStyle->TextAspect()->SetHeight( aFontHeight ); aStyle->TextAspect()->SetHeight( aFontHeight );
aStyle->ArrowAspect()->SetLength( anArrowLength ); aStyle->ArrowAspect()->SetLength( anArrowLength );
aStyle->LineAspect()->SetWidth( aLineWidth ); aStyle->LineAspect()->SetWidth( aLineWidth );
if ( aDimensionIO->IsKind( STANDARD_TYPE(AIS_AngleDimension) ) )
{
// show degree symbol for dimension instead of label "deg"
if ( aUnitsAngle == "deg" )
{
aDimensionIO->SetSpecialSymbol(0xB0);
aDimensionIO->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
aStyle->MakeUnitsDisplayed(Standard_False);
}
else
{
aDimensionIO->SetDisplaySpecialSymbol(AIS_DSS_No);
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
}
}
else
{
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
}
aDimensionIO->Attributes()->SetDimLengthDisplayUnits( aUnitsLength.toLatin1().data() );
aDimensionIO->Attributes()->SetDimAngleDisplayUnits( aUnitsAngle.toLatin1().data() );
aDimensionIO->SetDimensionAspect( aStyle ); aDimensionIO->SetDimensionAspect( aStyle );
aDimensionIO->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 ); aDimensionIO->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );

File diff suppressed because it is too large Load Diff

View File

@ -47,60 +47,96 @@
//================================================================================= //=================================================================================
class MeasureGUI_DimensionCreateTool class MeasureGUI_DimensionCreateTool
{ {
struct Segment
{
gp_Pnt First;
gp_Pnt Last;
};
typedef NCollection_Sequence<gp_Dir> SeqOfDirs;
typedef NCollection_Sequence<gp_Pln> SeqOfPlanes;
typedef NCollection_Sequence<Segment> SeqOfSegments;
public: public:
MeasureGUI_DimensionCreateTool( GeometryGUI* ); MeasureGUI_DimensionCreateTool();
struct
{
Standard_Real DefaultFlyout;
Handle(V3d_View) ActiveView;
} Settings;
/* construction methods */ /* construction methods */
public: public:
Handle(AIS_LengthDimension) LengthOnEdge( const GEOM::GeomObjPtr& ); Handle(AIS_LengthDimension) LengthOnEdge( const GEOM::GeomObjPtr& ) const;
Handle(AIS_LengthDimension) LengthByPoints( const GEOM::GeomObjPtr&, Handle(AIS_LengthDimension) LengthByPoints( const GEOM::GeomObjPtr&,
const GEOM::GeomObjPtr& ); const GEOM::GeomObjPtr& ) const;
Handle(AIS_LengthDimension) LengthByParallelEdges( const GEOM::GeomObjPtr&, Handle(AIS_LengthDimension) LengthByParallelEdges( const GEOM::GeomObjPtr&,
const GEOM::GeomObjPtr& ); const GEOM::GeomObjPtr& ) const;
Handle(AIS_DiameterDimension) Diameter( const GEOM::GeomObjPtr& ); Handle(AIS_DiameterDimension) Diameter( const GEOM::GeomObjPtr& ) const;
Handle(AIS_AngleDimension) AngleByTwoEdges( const GEOM::GeomObjPtr&, Handle(AIS_AngleDimension) AngleByTwoEdges( const GEOM::GeomObjPtr&,
const GEOM::GeomObjPtr& ); const GEOM::GeomObjPtr& ) const;
Handle(AIS_AngleDimension) AngleByThreePoints( const GEOM::GeomObjPtr&, Handle(AIS_AngleDimension) AngleByThreePoints( const GEOM::GeomObjPtr&,
const GEOM::GeomObjPtr&, const GEOM::GeomObjPtr&,
const GEOM::GeomObjPtr& ); const GEOM::GeomObjPtr& ) const;
/* selecting flyout direction for length dimensions */ /* selecting flyout direction for length dimensions */
protected: protected:
void ChooseLengthFlyoutsFromShape( TColgp_SequenceOfDir&, void ChooseLengthFlyoutsFromBnd( SeqOfDirs&,
const TopoDS_Vertex&,
const TopoDS_Vertex&,
const TopoDS_Shape& );
void ChooseLengthFlyoutsFromShape( TColgp_SequenceOfDir&,
const TopoDS_Edge&,
const TopoDS_Shape& );
void ChooseLengthFlyoutsFromBnd( TColgp_SequenceOfDir&,
const gp_Pnt&, const gp_Pnt&,
const gp_Pnt&, const gp_Pnt&,
const Bnd_Box& ); const Bnd_Box& ) const;
gp_Dir ChooseDirFromBnd( const SeqOfDirs&,
const gp_Pnt&,
const Bnd_Box& ) const;
/* selecting best flyout direction taking into account view projection */ /* selecting best flyout direction taking into account view projection */
protected: protected:
gp_Pln SelectPlaneForProjection( const NCollection_Sequence<gp_Pln>&, template <typename TPlane>
const Handle(V3d_View)& ); TPlane SelectPlaneForProjection( const NCollection_Sequence<TPlane>&,
const Handle(V3d_View)& ) const;
/* positioning */
protected:
void PositionLength( const Bnd_Box&,
const gp_Vec&,
const gp_Vec&,
const gp_Vec&,
const gp_Vec&,
const gp_Pnt&,
const gp_Pnt&,
gp_Pln& ) const;
void PositionDiameter( const Bnd_Box&,
const gp_Vec&,
const gp_Circ&,
gp_Pnt&,
gp_Pnt&,
gp_Pln& ) const;
void PositionDiameter( const Bnd_Box&,
const gp_Vec&,
const gp_Circ&,
const Standard_Real&,
gp_Pln& ) const;
/* utility */ /* utility */
protected: protected:
GEOM::GeomObjPtr GetMainShape( const GEOM::GeomObjPtr& ); GEOM::GeomObjPtr GetMainShape( const GEOM::GeomObjPtr& ) const;
bool GetFaceSide( const TopoDS_Face&, bool GetFaceSide( const TopoDS_Face&,
const TopoDS_Edge&, const TopoDS_Edge&,
gp_Dir& ); gp_Dir& ) const;
SeqOfSegments GetInPlaneSegments( const gp_Circ&,
private: const SeqOfDirs& ) const;
GeometryGUI* myGeomGUI;
}; };
#endif #endif

View File

@ -520,6 +520,7 @@ void MeasureGUI_DimensionInteractor::MoveText( const Handle(V3d_View)& theView,
Prs3d_DimensionTextHorizontalPosition aHPos = myInteractedIO->DimensionAspect()->TextHorizontalPosition(); Prs3d_DimensionTextHorizontalPosition aHPos = myInteractedIO->DimensionAspect()->TextHorizontalPosition();
Prs3d_DimensionTextVerticalPosition aVPos = myInteractedIO->DimensionAspect()->TextVerticalPosition(); Prs3d_DimensionTextVerticalPosition aVPos = myInteractedIO->DimensionAspect()->TextVerticalPosition();
Prs3d_DimensionArrowOrientation aArrPos = myInteractedIO->DimensionAspect()->ArrowOrientation();
Standard_Real aHeight = myInteractedIO->DimensionAspect()->TextAspect()->Height() * 0.5; Standard_Real aHeight = myInteractedIO->DimensionAspect()->TextAspect()->Height() * 0.5;
@ -564,14 +565,17 @@ void MeasureGUI_DimensionInteractor::MoveText( const Handle(V3d_View)& theView,
if ( aPosX < 0.0 ) if ( aPosX < 0.0 )
{ {
aHPos = Prs3d_DTHP_Left; aHPos = Prs3d_DTHP_Left;
aArrPos = Prs3d_DAO_External;
} }
else if ( aPosX > aFirstPoint.Distance( aSecondPoint ) ) else if ( aPosX > aFirstPoint.Distance( aSecondPoint ) )
{ {
aHPos = Prs3d_DTHP_Right; aHPos = Prs3d_DTHP_Right;
aArrPos = Prs3d_DAO_External;
} }
else else
{ {
aHPos = Prs3d_DTHP_Center; aHPos = Prs3d_DTHP_Center;
aArrPos = Prs3d_DAO_Fit;
} }
if ( aPosY > aHeight ) if ( aPosY > aHeight )
@ -636,16 +640,19 @@ void MeasureGUI_DimensionInteractor::MoveText( const Handle(V3d_View)& theView,
if ( aPointAngle < -aDirAngle * 0.5 ) // outside of second dir if ( aPointAngle < -aDirAngle * 0.5 ) // outside of second dir
{ {
aHPos = Prs3d_DTHP_Left; aHPos = Prs3d_DTHP_Left;
aArrPos = Prs3d_DAO_External;
aPosY = Abs( aPointVec.Dot( aFirstDir ) ) - Abs( myInteractedIO->GetFlyout() ); aPosY = Abs( aPointVec.Dot( aFirstDir ) ) - Abs( myInteractedIO->GetFlyout() );
} }
else if ( aPointAngle > aDirAngle * 0.5 ) // outside of first dir else if ( aPointAngle > aDirAngle * 0.5 ) // outside of first dir
{ {
aHPos = Prs3d_DTHP_Right; aHPos = Prs3d_DTHP_Right;
aArrPos = Prs3d_DAO_External;
aPosY = Abs( aPointVec.Dot( aSecondDir ) ) - Abs( myInteractedIO->GetFlyout() ); aPosY = Abs( aPointVec.Dot( aSecondDir ) ) - Abs( myInteractedIO->GetFlyout() );
} }
else // between first and second direction else // between first and second direction
{ {
aHPos = Prs3d_DTHP_Center; aHPos = Prs3d_DTHP_Center;
aArrPos = Prs3d_DAO_Fit;
aPosY = Abs( aPointVec.Magnitude() ) - Abs( myInteractedIO->GetFlyout() ); aPosY = Abs( aPointVec.Magnitude() ) - Abs( myInteractedIO->GetFlyout() );
} }
@ -665,6 +672,7 @@ void MeasureGUI_DimensionInteractor::MoveText( const Handle(V3d_View)& theView,
myInteractedIO->DimensionAspect()->SetTextVerticalPosition( aVPos ); myInteractedIO->DimensionAspect()->SetTextVerticalPosition( aVPos );
myInteractedIO->DimensionAspect()->SetTextHorizontalPosition( aHPos ); myInteractedIO->DimensionAspect()->SetTextHorizontalPosition( aHPos );
myInteractedIO->DimensionAspect()->SetArrowOrientation( aArrPos );
myInteractedIO->SetToUpdate(); myInteractedIO->SetToUpdate();
myViewer->getAISContext()->Redisplay( myInteractedIO ); myViewer->getAISContext()->Redisplay( myInteractedIO );

View File

@ -122,6 +122,9 @@ MeasureGUI_ManageDimensionsDlg::MeasureGUI_ManageDimensionsDlg( GeometryGUI* the
connect( this, SIGNAL( finished( int ) ), SLOT( OnFinish() ) ); connect( this, SIGNAL( finished( int ) ), SLOT( OnFinish() ) );
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( OnDeactivateThisDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent ), myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent ),
SelectionIntoArgument( Selection_Object ); SelectionIntoArgument( Selection_Object );
@ -130,6 +133,8 @@ MeasureGUI_ManageDimensionsDlg::MeasureGUI_ManageDimensionsDlg( GeometryGUI* the
{ {
myObjectSelector->PushButton1->click(); myObjectSelector->PushButton1->click();
} }
setHelpFileName("managing_dimensions_page.html");
} }
//================================================================================= //=================================================================================
@ -151,7 +156,7 @@ void MeasureGUI_ManageDimensionsDlg::StartSelection( const Selection theSelectio
myCurrentSelection = theSelection; myCurrentSelection = theSelection;
if ( theSelection == Selection_Object && WarnUnsaved() ) if ( theSelection == Selection_Object && AllowedToCancelChanges() )
{ {
/* ----------------------------------------------- * /* ----------------------------------------------- *
* selection of object * * selection of object *
@ -703,7 +708,7 @@ void MeasureGUI_ManageDimensionsDlg::ClickOnOk()
//================================================================================= //=================================================================================
void MeasureGUI_ManageDimensionsDlg::ClickOnCancel() void MeasureGUI_ManageDimensionsDlg::ClickOnCancel()
{ {
if ( !WarnUnsaved() ) if ( !AllowedToCancelChanges() )
{ {
return; return;
} }
@ -781,6 +786,70 @@ void MeasureGUI_ManageDimensionsDlg::OnFinish()
redisplay( myEditObject.get() ); redisplay( myEditObject.get() );
} }
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::enterEvent( QEvent* )
{
if ( !mainFrame()->GroupConstructors->isEnabled() )
{
OnActivateThisDialog();
}
}
//=================================================================================
// function : OnActivateThisDialog
// purpose :
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::OnActivateThisDialog()
{
disconnect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( OnDeactivateThisDialog() ) );
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( OnDeactivateThisDialog() ) );
SelectionIntoArgument( Selection_Object );
if ( myEditObject.isNull() )
{
myObjectSelector->PushButton1->click();
}
}
//=================================================================================
// function : OnDeactivateThisDialog
// purpose :
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::OnDeactivateThisDialog()
{
if ( AllowedToSaveChanges() )
{
ClickOnApply();
}
if ( !myEditObject.isNull() )
{
SalomeApp_Study* aStudy = NULL;
SalomeApp_Application* anApp = myGeomGUI->getApp();
if ( anApp )
{
aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
}
if ( aStudy )
{
aStudy->setObjectProperty( GEOM::sharedPropertiesId(),
myEditObject->GetStudyEntry(),
GEOM::propertyName( GEOM::Dimensions ),
QVariant() );
}
redisplay( myEditObject.get() );
}
GEOMBase_Skeleton::DeactivateActiveDialog();
}
//================================================================================= //=================================================================================
// function : SetEditObject // function : SetEditObject
// purpose : // purpose :
@ -967,26 +1036,26 @@ void MeasureGUI_ManageDimensionsDlg::PopulateList()
} }
//================================================================================= //=================================================================================
// function : WarnUnsaved // function : HasUnsavedChanges
// purpose : // purpose :
//================================================================================= //=================================================================================
bool MeasureGUI_ManageDimensionsDlg::WarnUnsaved() bool MeasureGUI_ManageDimensionsDlg::HasUnsavedChanges()
{ {
if ( myEditObject.isNull() ) if ( myEditObject.isNull() )
{ {
return true; return false;
} }
SalomeApp_Application* anApp = myGeomGUI->getApp(); SalomeApp_Application* anApp = myGeomGUI->getApp();
if ( !anApp ) if ( !anApp )
{ {
return true; return false;
} }
SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() ); SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
if ( !aStudy ) if ( !aStudy )
{ {
return true; return false;
} }
GEOMGUI_DimensionProperty aCurrentState = GEOMGUI_DimensionProperty aCurrentState =
@ -996,14 +1065,43 @@ bool MeasureGUI_ManageDimensionsDlg::WarnUnsaved()
QVariant() ) QVariant() )
.value<GEOMGUI_DimensionProperty>(); .value<GEOMGUI_DimensionProperty>();
if ( aCurrentState == mySavedPropertyState ) return aCurrentState != mySavedPropertyState;
}
//=================================================================================
// function : AllowedToCancelChanges
// purpose :
//=================================================================================
bool MeasureGUI_ManageDimensionsDlg::AllowedToCancelChanges()
{
if ( !HasUnsavedChanges() )
{ {
return true; return true;
} }
int aResponse = SUIT_MessageBox::warning( this, int aResponse = SUIT_MessageBox::warning( this,
tr( "WRN_TITLE_UNSAVED" ), tr( "WRN_TITLE_UNSAVED" ),
tr( "WRN_MSG_UNSAVED" ), tr( "WRN_MSG_CHANGES_LOST" ),
QMessageBox::Ok,
QMessageBox::Cancel );
return aResponse == QMessageBox::Ok;
}
//=================================================================================
// function : AllowedToSaveChanges
// purpose :
//=================================================================================
bool MeasureGUI_ManageDimensionsDlg::AllowedToSaveChanges()
{
if ( !HasUnsavedChanges() )
{
return false;
}
int aResponse = SUIT_MessageBox::warning( this,
tr( "WRN_TITLE_UNSAVED" ),
tr( "WRN_MSG_CHANGES_SAVE" ),
QMessageBox::Ok, QMessageBox::Ok,
QMessageBox::Cancel ); QMessageBox::Cancel );

View File

@ -79,12 +79,17 @@ protected slots:
virtual void ClickOnCancel(); virtual void ClickOnCancel();
bool ClickOnApply(); bool ClickOnApply();
void OnFinish(); void OnFinish();
void OnActivateThisDialog();
void OnDeactivateThisDialog();
/* Utils */ /* Utils */
private: private:
void SetEditObject( const GEOM::GeomObjPtr& ); void SetEditObject( const GEOM::GeomObjPtr& );
void RestoreState(); void RestoreState();
void PopulateList(); void PopulateList();
bool HasUnsavedChanges();
bool AllowedToCancelChanges();
bool AllowedToSaveChanges();
bool WarnUnsaved(); bool WarnUnsaved();
int IdFromItem( QTreeWidgetItem* theItem ); int IdFromItem( QTreeWidgetItem* theItem );
int IdFromPrs( const Handle(AIS_InteractiveObject)& theAIS ); int IdFromPrs( const Handle(AIS_InteractiveObject)& theAIS );
@ -93,6 +98,9 @@ private:
void SelectInViewer( SOCC_Viewer* theViewer, const int theId ); void SelectInViewer( SOCC_Viewer* theViewer, const int theId );
void RedisplayObject(); void RedisplayObject();
private:
void enterEvent(QEvent*);
private: private:
enum GroupItems enum GroupItems
{ {