Salome HOME
Merge branch 'hydro/imps_2017' into V8_3_BR
authorPaul RASCLE <paul.rascle@edf.fr>
Sat, 29 Apr 2017 09:50:59 +0000 (11:50 +0200)
committerPaul RASCLE <paul.rascle@edf.fr>
Sat, 29 Apr 2017 09:50:59 +0000 (11:50 +0200)
111 files changed:
CMakeLists.txt
doc/salome/gui/GEOM/images/annotation.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/annotation_preview.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/exportxao_dlg.png
doc/salome/gui/GEOM/input/annotation.doc [new file with mode: 0644]
doc/salome/gui/GEOM/input/import_export.doc
doc/salome/gui/GEOM/input/using_measurement_tools.doc
idl/GEOM_Superv.idl
idl/XAOPlugin.idl
resources/CMakeLists.txt
resources/SalomeApp.xml.in [changed mode: 0644->0755]
resources/annotation.png [new file with mode: 0644]
src/ARCHIMEDE/Archimede_VolumeSection.cxx
src/BasicGUI/BasicGUI.cxx
src/BuildGUI/BuildGUI_FaceDlg.cxx
src/CurveCreator/CurveCreator_Utils.cxx
src/CurveCreator/CurveCreator_Widget.cxx
src/DependencyTree/DependencyTree_View.cxx
src/EntityGUI/CMakeLists.txt
src/EntityGUI/EntityGUI.cxx
src/EntityGUI/EntityGUI_PolylineDlg.cxx
src/GEOM/CMakeLists.txt
src/GEOMBase/GEOMBase_Helper.cxx
src/GEOMBase/GEOMBase_Helper.h
src/GEOMClient/GEOM_Client.cxx
src/GEOMGUI/CMakeLists.txt
src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx [new file with mode: 0755]
src/GEOMGUI/GEOMGUI_AnnotationAttrs.h [new file with mode: 0755]
src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx [new file with mode: 0755]
src/GEOMGUI/GEOMGUI_AnnotationMgr.h [new file with mode: 0755]
src/GEOMGUI/GEOMGUI_DimensionProperty.h
src/GEOMGUI/GEOMGUI_OCCSelector.cxx
src/GEOMGUI/GEOMGUI_Selection.cxx
src/GEOMGUI/GEOMGUI_Selection.h
src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx [new file with mode: 0644]
src/GEOMGUI/GEOMGUI_TextTreeSelector.h [new file with mode: 0644]
src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx [changed mode: 0644->0755]
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
src/GEOMGUI/GEOM_Displayer.cxx [changed mode: 0644->0755]
src/GEOMGUI/GEOM_Displayer.h [changed mode: 0644->0755]
src/GEOMGUI/GEOM_images.ts
src/GEOMGUI/GEOM_msg_en.ts [changed mode: 0644->0755]
src/GEOMGUI/GEOM_msg_fr.ts [changed mode: 0644->0755]
src/GEOMGUI/GEOM_msg_ja.ts [changed mode: 0644->0755]
src/GEOMGUI/GeometryGUI.cxx [changed mode: 0644->0755]
src/GEOMGUI/GeometryGUI.h
src/GEOMGUI/GeometryGUI_Operations.h [changed mode: 0644->0755]
src/GEOMImpl/GEOMImpl_BooleanDriver.cxx
src/GEOMImpl/GEOMImpl_Fillet1d.cxx
src/GEOMImpl/GEOMImpl_Fillet1dDriver.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_OffsetDriver.cxx
src/GEOMImpl/GEOMImpl_PipeDriver.cxx
src/GEOMToolsGUI/GEOMToolsGUI.cxx
src/GEOMToolsGUI/GEOMToolsGUI_1.cxx
src/GEOMToolsGUI/GEOMToolsGUI_DeleteDlg.cxx
src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx
src/GEOMToolsGUI/GEOMToolsGUI_PublishDlg.cxx
src/GEOMToolsGUI/GEOMToolsGUI_ReduceStudyDlg.cxx
src/GEOMUtils/GEOMUtils.cxx
src/GEOMUtils/GEOMUtils_ShapeStatistics.cxx
src/GEOMUtils/GEOMUtils_XmlHandler.cxx
src/GEOM_I/GEOM_Gen_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.cc
src/GEOM_I_Superv/GEOM_Superv_i.hh
src/GEOM_SWIG/XAOPluginBuilder.py
src/GEOM_SWIG/geomBuilder.py
src/IGESPlugin/IGESPlugin_GUI.cxx
src/MeasureGUI/CMakeLists.txt
src/MeasureGUI/MeasureGUI.cxx [changed mode: 0644->0755]
src/MeasureGUI/MeasureGUI.h [changed mode: 0644->0755]
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx [new file with mode: 0755]
src/MeasureGUI/MeasureGUI_AnnotationDlg.h [new file with mode: 0755]
src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx [new file with mode: 0755]
src/MeasureGUI/MeasureGUI_AnnotationInteractor.h [new file with mode: 0755]
src/MeasureGUI/MeasureGUI_CheckCompoundOfBlocksDlg.cxx
src/MeasureGUI/MeasureGUI_CreateDimensionDlg.cxx
src/MeasureGUI/MeasureGUI_DimensionInteractor.cxx
src/MeasureGUI/MeasureGUI_ManageDimensionsDlg.cxx
src/OBJECT/CMakeLists.txt
src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_Annotation.cxx [new file with mode: 0755]
src/OBJECT/GEOM_Annotation.hxx [new file with mode: 0755]
src/OBJECT/GEOM_Constants.cxx
src/OBJECT/GEOM_Constants.h
src/SKETCHER/Sketcher_Profile.cxx
src/STLPlugin/STLPlugin_GUI.cxx
src/ShHealOper/ShHealOper_FillHoles.cxx
src/ShapeRecognition/CMakeLists.txt
src/XAO/XAO_BrepGeometry.cxx
src/XAO/XAO_BrepGeometry.hxx
src/XAO/XAO_Field.cxx
src/XAO/XAO_Field.hxx
src/XAO/XAO_Geometry.hxx
src/XAO/XAO_Group.cxx
src/XAO/XAO_Xao.cxx
src/XAO/XAO_Xao.hxx
src/XAO/XAO_XaoExporter.cxx
src/XAO/XAO_XaoExporter.hxx
src/XAO/tests/ImportExportTest.cxx
src/XAOPlugin/XAOPlugin_ExportDlg.cxx
src/XAOPlugin/XAOPlugin_ExportDlg.h
src/XAOPlugin/XAOPlugin_IECallBack.cxx
src/XAOPlugin/XAOPlugin_IECallBack.hxx
src/XAOPlugin/XAOPlugin_IOperations.cxx
src/XAOPlugin/XAOPlugin_IOperations.hxx
src/XAOPlugin/XAOPlugin_IOperations_i.cc
src/XAOPlugin/XAOPlugin_IOperations_i.hh
src/XAOPlugin/XAOPlugin_ImportDlg.cxx
src/XAOPlugin/XAOPlugin_msg_en.ts
src/XAOPlugin/XAOPlugin_msg_fr.ts

index 01e412e6ae09b51a98893af00648282447b14850..c85cb8fad3226aa37196ca3b1e79396e577e6a4e 100755 (executable)
@@ -33,7 +33,7 @@ ENDIF(WIN32)
 STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
 
 SET(${PROJECT_NAME_UC}_MAJOR_VERSION 8)
-SET(${PROJECT_NAME_UC}_MINOR_VERSION 2)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 3)
 SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
 SET(${PROJECT_NAME_UC}_VERSION
   ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
diff --git a/doc/salome/gui/GEOM/images/annotation.png b/doc/salome/gui/GEOM/images/annotation.png
new file mode 100644 (file)
index 0000000..584104f
Binary files /dev/null and b/doc/salome/gui/GEOM/images/annotation.png differ
diff --git a/doc/salome/gui/GEOM/images/annotation_preview.png b/doc/salome/gui/GEOM/images/annotation_preview.png
new file mode 100644 (file)
index 0000000..0cb5020
Binary files /dev/null and b/doc/salome/gui/GEOM/images/annotation_preview.png differ
index d273b9d7813f84277ae841f0385a0177bc6fbc64..7e7fc5f2452798fe5c680a3e4367eea1278e6601 100644 (file)
Binary files a/doc/salome/gui/GEOM/images/exportxao_dlg.png and b/doc/salome/gui/GEOM/images/exportxao_dlg.png differ
diff --git a/doc/salome/gui/GEOM/input/annotation.doc b/doc/salome/gui/GEOM/input/annotation.doc
new file mode 100644 (file)
index 0000000..944630a
--- /dev/null
@@ -0,0 +1,57 @@
+/*! 
+
+\page annotation_page Shape annotation
+
+<b> Annotation </b> functionality allows showing in the viewer special user-defined text label connected to corresponding part of a CAD model with a line.
+Annotation text is always parallel to the screen and horizontal. It is is not zoomed or rotated when a 3D scene is zoomed or rotated by the user.
+The annotation text is defined using UTF-8 encoding and thus support any Unicode characters.
+
+There are several algorithms for the annotation position calculation during the scene manipulations (panning, zooming, rotation):
+<ul>
+  <li>Algorithm 1: an annotation has fixed position in 2D screen coordinates (fixed screen position mode). In this mode, the annotations are always visible (appear as topmost objects), never hidden by the (annotated) geometry.</li>
+  <li>Algorithm 2: an annotation has fixed position in 3D model space, this position is projected onto the screen just as normal point coordinates. In this mode, some annotations may be invisible depending on the camera (position, orientation, zoom).</li>
+</ul>
+
+\image html annotation_preview.png
+
+It can be accessed from the main menu via <b>Inspection -> Annotation </b>
+
+\image html annotation.png "Create Annotation dialog"
+
+In this dialog you can:
+<ul>
+  <li>Set <b>Text</b> text shown in View 3d and a name of annotation presented in the Text Browser.</li>
+  <li>Select a \b Shape to which the annotation will be assigned.</li>
+  <li>Set <b>Fixed screen position</b> to select alogithm for the annotation position caldulation.</li>
+  <li>Select a <b>Shape Type</b> to which the annotation will be assigned on the shape.
+  It contains "Whole shape", "Vertex", "Edge", "Face" and "Solid" choices.</li>
+  <li>Select a sub shape to assign annotation to. Text control contains information about local selection in the viewer.</li>
+  <li>Move annotation dragging it in 3D view to select an appropriate position.</li>
+  <li>Push \b Apply or <b>Apply and Close</b> button to commit creation of the field.</li>
+</ul>
+
+Annotations appear in an Annotations sub-tree in Text Browser.</li>
+The foolowing context menu commands are provided for annotation object in Text Browser:
+<ul>
+  <li><b>Edit</b> allows modifying the annotation text, the positioning algorithm and the annotation position.</li>
+  <li><b>Delete</b> deletes selected annotation.</li>
+  <li><b>Show</b>/<b>Hide</b> change visibility of annotation in the active view.</li>
+</ul>
+<b>Edit</b> and <b>Delete</b> actions are also available in View 3d for selected annotation object/s.
+
+All annotations may be shown/hidden in a 3D view. The corresponded popup menu is available in Text Browser.
+
+All annotations of a shape may be shown/hidden in a 3D view using corresponded popup menu on the shape item in Object Browser.
+
+Synchronization of selection between 3D view and Text browser is available. It means that selection of annotation in 3D view will select this annotation in Text browser and vice versa.
+
+Annotation is logically connected to the shape:
+<ul>
+  <li>Selection of an annotation will highlight corresponding shape/subshape in 3D view.</li>
+  <li>When the shape is deleted, the annotation will be also deleted.</li>
+</ul>
+
+The user is able to modify the font, the style, the color and the size of the annotation text and the color, the width and the style of the connection line applied to all annotations.
+It can be accessed from the main menu via <b>File -> Preferences</b>. The Shape annotations group on Geometry Settings pane contains controls for it.
+
+*/
index 890ce97e672eef3e2052adff2c8ec2d9bc02a890..7e79e38d69ee89770d48730a2517cf40237cee3a 100644 (file)
@@ -98,10 +98,12 @@ In the \b File menu select <b>Export/XAO</b>.
 In this dialog:
 - Click the arrow button and select in the Object Browser or in the Viewer the <b>Shape</b> to be exported.
 - Input the <b>File name</b> to create a new file or click browse button to save in an existing file.
+- Input the <b>Author</b> if needed.
+- Tick <b>Export shape in a separate file</b> to write the shape in a separate BREP file, referenced in the XAO file. It will have the same name as the XAO file with the .brep extension appended.
 - Select the \b Groups of the chosen shape to be exported.
 - Select the \b Fields of the chosen shape to be exported.
 - Press "Apply" or "Apply & Close" button to get the result.
 
-It also possible to export a shape using the TUI Command: <em>geompy.ExportXAO(Shape, FileName, Groups, Fields)</em>
+It is also possible to export a shape using the TUI Command: <em>geompy.ExportXAO(Shape, Groups, Fields, Author, FileName, ShapeFileName)</em>
 
 */
index 515a94ce4a7808c7942730e944c6d6ec2b716803..feca9e24f5282ecc5e9f03de9051eb1eef8fe379 100644 (file)
@@ -17,6 +17,7 @@
 <li>\subpage angle_page "Angle"</li>
 <li>\subpage tolerance_page "Tolerance"</li>
 <li>\subpage managing_dimensions_page "Dimensions"</li>
+<li>\subpage annotation_page "Annotations"</li>
 <li>\subpage whatis_page "WhatIs"</li>
 <li>\subpage inspect_object_operation_page "Inspect Object"</li>
 <li>\subpage shape_statistics_operation_page "Shape Statistics"</li>
index c12b0104caf198abac61fd3c85e2c8944f1c2c00..003c8210bbe23f5a204ea42710331cbcff0f23e0 100644 (file)
@@ -668,7 +668,8 @@ module GEOM
                            in ListOfGO groups, 
                            in ListOfFields fields,
                            in string author, 
-                           in string fileName );
+                           in string fileName,
+                           in string shapeFileName );
     boolean     ImportXAO( in string fileName, 
                            out GEOM_Object shape,
                            out ListOfGO subShapes, 
index 16a470802f836199eef6cb685d3c852efb2b10a4..d8e2ebb7f6cc69a8c67077f6dbadf2187512552c 100644 (file)
@@ -36,13 +36,15 @@ module GEOM
      *  \param fields The list of fields to export
      *  \param author The author of the export
      *  \param fileName The name of the file to export
+     *  \param shapeFileName The name of the file to export the shape in an external file
      *  \return boolean indicating if export was successful.
      */
     boolean ExportXAO( in GEOM::GEOM_Object shape,
                        in GEOM::ListOfGO groups, 
                        in GEOM::ListOfFields fields,
                        in string author, 
-                       in string fileName );
+                       in string fileName,
+                       in string shapeFileName );
     
     /*!
      *  Import a shape from XAO format
index dc98cbf97e6f309758b1fb0095e9eb1b433d05f6..74be117a6d15f13d519b69f81eb98a142d407985 100755 (executable)
@@ -39,6 +39,7 @@ SET( _res_files
   isoline.png
   isoline_v.png
   angle.png
+  annotation.png
   arc.png
   arccenter.png
   arcofellipse.png
old mode 100644 (file)
new mode 100755 (executable)
index 45e41fc..72d1c70
     <parameter name="dimensions_default_flyout" value="20" />
     <parameter name="dimensions_use_text3d"     value="0" />
 
+    <!-- Shape annotation presentation properties -->
+    <parameter name="shape_annotation_font_color" value="#00007f" />
+    <parameter name="shape_annotation_font"       value="Courier 10 Pitch,24" />
+    <parameter name="shape_annotation_line_color" value="#00007f" />
+    <parameter name="shape_annotation_line_width" value="1.0" />
+    <parameter name="shape_annotation_line_style" value="0" />
+    <parameter name="shape_annotation_autohide"   value="false" />
+
     <!-- Scalar bar for field step presentation -->
     <parameter name="scalar_bar_x_position"   value="0.05" />
     <parameter name="scalar_bar_y_position"   value="0.1" />
diff --git a/resources/annotation.png b/resources/annotation.png
new file mode 100644 (file)
index 0000000..a02ff68
Binary files /dev/null and b/resources/annotation.png differ
index 729a836b8b83c590b9b58e838239995784a03ed9..3364ac322dc00986189b2e8c9030c456975c7def 100644 (file)
@@ -124,7 +124,7 @@ void VolumeSection::CenterOfGravity()
 Standard_Real VolumeSection::CalculateVolume(Standard_Real Elevation)
 {
   Standard_Integer i,noeud[3],flag[3];
-  Standard_Integer nbNodes;
+  //Standard_Integer nbNodes;
   TopExp_Explorer ex;
   TopLoc_Location L;
   Standard_Real z[3];
@@ -144,7 +144,7 @@ Standard_Real VolumeSection::CalculateVolume(Standard_Real Elevation)
         MESSAGE("Error, null layer" )
       const Poly_Array1OfTriangle& triangles = Tr->Triangles();
       Standard_Integer nbTriangles = Tr->NbTriangles();
-      nbNodes = Tr->NbNodes();
+      //nbNodes = Tr->NbNodes();
       const TColgp_Array1OfPnt& Nodes = Tr->Nodes();
       
       // Calcul des volumes de chaque triangle, de chaque face 
index d7686b070092df4e6a5af677fe67f8c2e7e60a69..816162deec4cf3711f21183d941e3599f9920edc 100644 (file)
@@ -144,9 +144,9 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
 
       ic->InitSelected();
       if ( pe->modifiers() == Qt::ShiftModifier )
-        ic->ShiftSelect();  // Append selection
+        ic->ShiftSelect( Standard_True );  // Append selection
       else
-        ic->Select();       // New selection
+        ic->Select( Standard_True );       // New selection
 
       ic->InitSelected();
       if ( ic->MoreSelected() ) {
index bb81992cbc9eaff171098a761497052dceef7213..88ff45f0d2a5579e6e04244c1931e1bfc9ca6041 100644 (file)
@@ -322,8 +322,8 @@ void BuildGUI_FaceDlg::updateConstraintsTree()
     return;
 
   for ( int i = 0, n = aList->length(); i < n; i++ ) {
-    TreeWidgetItem* item = new TreeWidgetItem( myTreeConstraints,
-                                               GEOM::GeomObjPtr( aList[i] ) );
+    /*TreeWidgetItem* item =*/
+    new TreeWidgetItem( myTreeConstraints, GEOM::GeomObjPtr( aList[i] ) );
   }
 
   myEditCurrentArgument->setEnabled(false);
index 0170fb5ffe5d186e212926248a0096346e9a82fb..5f53caea4b9b76b1c622ec05d4b18bc85669d24f 100644 (file)
@@ -687,7 +687,7 @@ void CurveCreator_Utils::setLocalPointContext( const CurveCreator_ICurve* theCur
   }
   else {
     if ( theContext->HasOpenedContext() )
-      theContext->CloseAllContexts();
+      theContext->CloseAllContexts( Standard_True );
   }
 }
 
index b34b1f2da40f40ecd56a0d9fa47743700bd4cf76..1906c758dbd8b613e86daf80fbbb9446f51cb7f4 100644 (file)
@@ -1090,7 +1090,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
     {
       Handle(AIS_InteractiveContext) aCtx = getAISContext();
       if ( !aCtx.IsNull() )
-        aCtx->ClearSelected();
+        aCtx->ClearSelected( Standard_True );
     }
     return;
   } 
@@ -1121,11 +1121,11 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
       // otherwise a rectangular selection.
       if ( myStartPoint == myEndPoint )
       {
-        aCtx->MoveTo( myEndPoint.x(), myEndPoint.y(), aView3d );
+        aCtx->MoveTo( myEndPoint.x(), myEndPoint.y(), aView3d, Standard_True );
         if ( aHasShift )
-          aCtx->ShiftSelect();
+          aCtx->ShiftSelect( Standard_True );
         else
-          aCtx->Select();
+          aCtx->Select( Standard_True );
       }
       else
       {
index 22b61de5668d8a44f53443a43dde6ec5710262ec..2164574db669c68983c5514d8d984bb2765872aa 100644 (file)
@@ -475,10 +475,10 @@ void DependencyTree_View::parseTree()
     std::string objectEntry = i->first;
     addNode( objectEntry );
     parseTreeWard( i->second.first );
-    if( i->second.first.size() > myMaxUpwardLevelsNumber )
+    if((int) i->second.first.size() > myMaxUpwardLevelsNumber )
       myMaxUpwardLevelsNumber = i->second.first.size();
     parseTreeWard( i->second.second );
-    if( i->second.second.size() > myMaxDownwardLevelsNumber )
+    if((int) i->second.second.size() > myMaxDownwardLevelsNumber )
       myMaxDownwardLevelsNumber = i->second.second.size();
   }
 
@@ -518,13 +518,13 @@ void DependencyTree_View::parseTreeWard( const GEOMUtils::LevelsList& theWard )
 //=================================================================================
 void DependencyTree_View::parseTreeWardArrow( const GEOMUtils::LevelsList& theWard)
 {
-  for( int j = 0; j < theWard.size(); j++ ) {
+  for( size_t j = 0; j < theWard.size(); j++ ) {
     GEOMUtils::LevelInfo Level = theWard.at(j);
     GEOMUtils::LevelInfo::const_iterator node;
     for( node = Level.begin(); node != Level.end(); node++ ) {
       DependencyTree_Object* object = myTreeMap[ node->first ];
       std::vector<std::string> Links = node->second;
-      for( int link = 0; link < Links.size(); link++ ) {
+      for( size_t link = 0; link < Links.size(); link++ ) {
         DependencyTree_Object* LinkObject = myTreeMap[ Links[ link ] ];
         if( object && LinkObject )
           addArrow( LinkObject, object );
@@ -607,7 +607,7 @@ void DependencyTree_View::drawTree()
   std::map< int, std::vector< std::string > >::const_iterator level;
   for( level = levelObjects.begin(); level != levelObjects.end(); level++ ) {
     int step = -horDistance * ( int(level->second.size()) - 1 ) / 2;
-    for( int objIter = 0; objIter < level->second.size(); objIter++ ) {
+    for( size_t objIter = 0; objIter < level->second.size(); objIter++ ) {
       DependencyTree_Object* anObject = myTreeMap[ level->second.at( objIter ) ];
       anObject->setPos( step, verDistance * level->first );
       step += horDistance;
@@ -647,7 +647,7 @@ void DependencyTree_View::drawWard( const GEOMUtils::LevelsList& theWard,
                                     std::map< int, std::vector< std::string > >& theLevelObjects,
                                     int theCurrentLevel, const int theLevelStep )
 {
-  for( int level = 0; level < theWard.size(); level++ ) {
+  for( int level = 0, size = theWard.size(); level < size; level++ ) {
     if( level >= myLevelsNumber )
       return;
     theCurrentLevel += theLevelStep;
@@ -671,7 +671,7 @@ void DependencyTree_View::drawWard( const GEOMUtils::LevelsList& theWard,
 //=================================================================================
 void DependencyTree_View::drawWardArrows( const GEOMUtils::LevelsList& theWard )
 {
-  for( int j = 0; j < theWard.size(); j++ ) {
+  for( int j = 0, size = theWard.size(); j < size; j++ ) {
     if( j >= myLevelsNumber )
       break;
     GEOMUtils::LevelInfo Level = theWard.at(j);
@@ -679,7 +679,7 @@ void DependencyTree_View::drawWardArrows( const GEOMUtils::LevelsList& theWard )
     for( node = Level.begin(); node != Level.end(); node++ ) {
       DependencyTree_Object* object = myTreeMap[ node->first ];
       GEOMUtils::NodeLinks Links = node->second;
-      for( int link = 0; link < Links.size(); link++ ) {
+      for( size_t link = 0; link < Links.size(); link++ ) {
         DependencyTree_Object* LinkObject = myTreeMap[ Links[ link ] ];
         if( isItemAdded( object ) && isItemAdded( LinkObject ) ) {
           DependencyTree_Arrow* arrow = myArrows[ std::pair<DependencyTree_Object*,DependencyTree_Object*>( LinkObject, object ) ];
@@ -824,4 +824,5 @@ int DependencyTree_View::checkMaxLevelsNumber()
     return myMaxUpwardLevelsNumber;
   else if( myDisplayDescendants->isChecked() )
     return  myMaxDownwardLevelsNumber;
+  return 0;
 }
index a1cfd47362646846e3f1e538b28647266ca2c3cc..c42e5095d105dde20b0ad2051e783963d2ffcc12 100755 (executable)
@@ -25,6 +25,7 @@ INCLUDE(UseQtExt)
 INCLUDE_DIRECTORIES(
   ${PTHREAD_INCLUDE_DIR}
   ${VTK_INCLUDE_DIRS}
+  ${OPENCV_INCLUDE_DIR}
   ${OMNIORB_INCLUDE_DIR}
   ${CAS_INCLUDE_DIRS}
   ${KERNEL_INCLUDE_DIRS}
index d35d6b218cbf2d6d1af24f609e4670622972bdf0..019e0ad47ecfc812bffe84535a695a4a7ae17b2f 100644 (file)
@@ -234,9 +234,9 @@ bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWi
     
         ic->InitSelected();
         if ( pe->modifiers() == Qt::ShiftModifier )
-          ic->ShiftSelect();  // Append selection
+          ic->ShiftSelect( Standard_True );  // Append selection
         else
-          ic->Select();       // New selection
+          ic->Select( Standard_True );       // New selection
 
         ic->InitSelected();
         if ( ic->MoreSelected() ) {
@@ -263,7 +263,7 @@ bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWi
         Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();   
 
         ic->InitSelected();
-        ic->Select();       // New selection
+        ic->Select( Standard_True );       // New selection
 
         ic->InitSelected();
         TopoDS_Shape aShape;
@@ -365,7 +365,7 @@ void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Sha
     if ( !S1.IsNull() ) {
       /* erase any previous */
       ic->Erase( mySimulationShape1, Standard_True );
-      ic->ClearPrs( mySimulationShape1 );
+      ic->ClearPrs( mySimulationShape1, 0, Standard_True );
 
       mySimulationShape1 = new AIS_Shape( TopoDS_Shape() );
       mySimulationShape1->Set( S1 );
@@ -377,7 +377,7 @@ void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Sha
     }
     if ( !S2.IsNull() ) {
       ic->Erase( mySimulationShape2, Standard_True );
-      ic->ClearPrs( mySimulationShape2 );
+      ic->ClearPrs( mySimulationShape2, 0, Standard_True );
 
       mySimulationShape2 = new AIS_Shape( TopoDS_Shape() );
       mySimulationShape2->Set( S2 );
@@ -422,8 +422,8 @@ void EntityGUI::EraseSimulationShape()
       Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
       ic->Erase( mySimulationShape1, Standard_True );
       ic->Erase( mySimulationShape2, Standard_True );
-      ic->ClearPrs( mySimulationShape1 );
-      ic->ClearPrs( mySimulationShape2 );
+      ic->ClearPrs( mySimulationShape1, 0, Standard_True );
+      ic->ClearPrs( mySimulationShape2, 0, Standard_True );
       ic->UpdateCurrentViewer();
     } 
   }
index a2c4be2c603a983292125f83824e00446deb1791..1c6c9bda5cb44a81ab9bd11563f308cc9e361f26 100644 (file)
@@ -780,7 +780,7 @@ void EntityGUI_PolylineDlg::displayPreview()
 
         // Set color for temporary AIS_InteractiveObject
         anAISObj->Attributes()->WireAspect()->SetColor( Quantity_NOC_VIOLET );
-        aCtx->Redisplay( anAISObj );
+        aCtx->Redisplay( anAISObj, Standard_True );
       }
     }
   }
index 2c0c7605c012cc481f8bf35f98b5686250af88d2..4a73c259f361d7ab31744e1c4ab37615b589f0f8 100755 (executable)
@@ -39,6 +39,7 @@ SET(_link_LIBRARIES
   ${CAS_TKLCAF}
   ${CAS_TKCDF}
   ${CAS_TKG3d}
+  ${CAS_TKStdL}
   ${KERNEL_SALOMELocalTrace}
   ${KERNEL_OpUtil}
   GEOMSketcher
index 4c2614e10f759cc96a9cf04aa3527679f9e36679..c183e3ec694ff244ab8d623963e47e5182dace34 100755 (executable)
@@ -89,7 +89,7 @@ GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
 // Purpose  :
 //================================================================
 GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
-  : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ),
+  : myDisplayer( 0 ), myCommand( 0 ), myViewWindow( 0 ), isPreview( false ), myDesktop( desktop ),
     myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ),
     myIsDisableBrowsing(false), myIsDisplayResult(true)
 {
index 64d46f2029b634efe584abc0279126eb49bbd9d1..a62b2f129beae9f6dd374561a92957badc25b3de 100755 (executable)
@@ -65,6 +65,8 @@ public:
   static SUIT_ViewWindow* getActiveView();
 
 protected:
+  typedef std::list<SALOME_Prs*> PrsList;
+
   static GEOM::GEOM_Gen_ptr getGeomEngine();
 
   void display         ( const ObjectList&, const bool = true );
@@ -97,6 +99,8 @@ protected:
                          const bool = true );
   void erasePreview    ( const bool = true );
 
+  const PrsList& getPreview() const { return myPreview; }
+
   void localSelection( const ObjectList&, const std::list<int> );
   void localSelection( const ObjectList&, const int );
   void localSelection( GEOM::GEOM_Object_ptr, const std::list<int> );
@@ -210,7 +214,6 @@ private:
   void                        clearShapeBuffer( GEOM::GEOM_Object_ptr );
 
 private:
-  typedef std::list<SALOME_Prs*> PrsList;
 
   PrsList                     myPreview;
   GEOM_Displayer*             myDisplayer;
index ba8711e4190cc3812f60cc01de178cdd91239960..bfe844b1404acf625ea5be1865c2f8c72f81a21a 100644 (file)
@@ -258,8 +258,8 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p
     BRep_Builder B;
     TopoDS_Compound aCompound;
     B.MakeCompound(aCompound);
-    for (int i = 0; i < list->length(); i++) {
-      if (0 < list[i] && list[i] <= _mySubShapes[mainIOR].size()) {
+    for (size_t i = 0; i < list->length(); i++) {
+      if (0 < list[i] && list[i] <= (CORBA::Long)_mySubShapes[mainIOR].size()) {
         TopoDS_Shape aSubShape = _mySubShapes[mainIOR][list[i]-1];
         B.Add(aCompound, aSubShape);
       }
index dba48f80635847245f64d28a6245bb7e3bce8d1e..9dd7a50d8fdec939708ba4c409fe137c3b95572f 100755 (executable)
@@ -66,6 +66,7 @@ SET(_link_LIBRARIES
 
 SET(GEOMGUI_HEADERS
   GeometryGUI.h
+  GEOMGUI_AnnotationMgr.h
   GeometryGUI_Operations.h
   GEOMGUI.h
   GEOMPluginGUI.h
@@ -75,13 +76,17 @@ SET(GEOMGUI_HEADERS
   GEOM_GEOMGUI.hxx
   GEOMGUI_CreationInfoWdg.h
   GEOMGUI_TextTreeWdg.h
+  GEOMGUI_TextTreeSelector.h
   GEOMGUI_DimensionProperty.h
+  GEOMGUI_AnnotationAttrs.h
   )
 
 # header files / to be processed by moc
 SET(_moc_HEADERS 
+  GEOMGUI_AnnotationMgr.h
   GEOMGUI_CreationInfoWdg.h
   GEOMGUI_TextTreeWdg.h
+  GEOMGUI_TextTreeSelector.h
   GeometryGUI.h
   )
 
@@ -108,6 +113,7 @@ QT_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES})
 
 SET(GEOMGUI_SOURCES
   GeometryGUI.cxx
+  GEOMGUI_AnnotationMgr.cxx
   GEOMGUI.cxx
   GEOMPluginGUI.cxx
   GEOM_Displayer.cxx
@@ -115,7 +121,9 @@ SET(GEOMGUI_SOURCES
   GEOMGUI_Selection.cxx
   GEOMGUI_CreationInfoWdg.cxx
   GEOMGUI_TextTreeWdg.cxx
+  GEOMGUI_TextTreeSelector.cxx
   GEOMGUI_DimensionProperty.cxx
+  GEOMGUI_AnnotationAttrs.cxx
   ${_moc_SOURCES}
   ${_rcc_SOURCES}
   )
diff --git a/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx
new file mode 100755 (executable)
index 0000000..1a09b50
--- /dev/null
@@ -0,0 +1,552 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : GEOMGUI_AnnotationAttr.cxx
+// Author : Anton POLETAEV, Open CASCADE S.A.S.
+//
+
+// SALOME includes
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOM_Annotation.hxx>
+#include <SALOMEDSImpl_AttributeParameter.hxx>
+
+// STL includes
+#include <string>
+#include <vector>
+#include <sstream>
+
+IMPLEMENT_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
+
+namespace
+{
+  static const std::string PARAMETER_COUNT = "GEOMGUI_AnnotationAttrs_Count";
+
+  std::string PARAMETER_I( const std::string& s, const int i ) {
+    std::stringstream ss;
+    ss << i;
+    return std::string( s ) + ss.str();
+  }
+  std::string PARAMETER_IS_VISIBLE( const int i ) {
+    return PARAMETER_I( "GEOMGUI_AnnotationAttrs_IsVisible", i );
+  }
+  std::string PARAMETER_IS_2D( const int i ) {
+    return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Is2D", i );
+  }
+  std::string PARAMETER_TEXT( const int i ) {
+    return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Text", i );
+  }
+  std::string PARAMETER_POSITION( const int i ) {
+    return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Position", i );
+  }
+  std::string PARAMETER_ATTACH( const int i ) {
+    return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Attach", i );
+  }
+  std::string PARAMETER_SHAPE(  const int i ) {
+    return PARAMETER_I( "GEOMGUI_AnnotationAttrs_Shape", i );
+  }
+
+  // REGEXP pattern for converting array of entries into plain text string.
+  // The pattern has the following structure:
+  // ENTRY: { text[string] : visibility[bool] : screen fixed[bool] : position[xyz] : attach[xyz] }
+  static const QString PATTERN_ITEM_GROUP = "\\{ (Text=(?::{2,}|.)*:(?!:)Screen=.*:Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=.*:ShapeType=.*) \\}";
+  static const QString PATTERN_ITEM = "Text=((?::{2,}|.)*):(?!:)Screen=(\\d{1}):Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=(\\-?\\d{1,}):ShapeType=(\\d{1})";
+  static QString toPattern (const QString& theText,
+                            const bool theIsFixed,
+                            const gp_Pnt& thePosition,
+                            const gp_Pnt& theAttach,
+                            const int theShapeIndex,
+                            const int theShapeType)
+  {
+    return QString( "{ Text=" ) + theText +
+           QString( ":" ) + QString( "Screen=" ) + QString::number( theIsFixed ? 1 : 0 ) +
+           QString( ":" ) + QString( "Position={" ) +
+             QString::number( thePosition.X() ) + QString( ":" ) + 
+             QString::number( thePosition.Y() ) + QString( ":" ) + 
+             QString::number( thePosition.Z() ) + QString( "}" ) + 
+           QString( ":" ) + QString( "Attach={" ) +
+             QString::number( theAttach.X() ) + QString( ":" ) + 
+             QString::number( theAttach.Y() ) + QString( ":" ) + 
+             QString::number( theAttach.Z() ) + QString( "}" ) +
+           QString( ":" ) + QString( "ShapeIdx=" ) + QString::number( theShapeIndex ) +
+           QString( ":" ) + QString( "ShapeType=" ) + QString::number( theShapeType ) +
+           QString( " }" );
+  }
+};
+
+//=================================================================================
+// function : FindAttributes
+// purpose  : 
+//=================================================================================
+Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindAttributes( const _PTR(SObject)& theObject )
+{
+  _PTR(GenericAttribute) aGenericAttr;
+  _PTR(AttributeParameter) aParameterMap;
+
+  if ( !theObject || !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )
+  {
+    return Handle(GEOMGUI_AnnotationAttrs)();
+  }
+
+  aParameterMap = aGenericAttr;
+
+  if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
+  {
+    return Handle(GEOMGUI_AnnotationAttrs)();
+  }
+
+  return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );
+}
+
+//=================================================================================
+// function : FindOrCreateAttributes
+// purpose  : 
+//=================================================================================
+Handle(GEOMGUI_AnnotationAttrs) GEOMGUI_AnnotationAttrs::FindOrCreateAttributes(
+  const _PTR(SObject)& theObject, SalomeApp_Study* theStudy )
+{
+  _PTR(StudyBuilder) aBuilder = theStudy->studyDS()->NewBuilder();
+  _PTR(AttributeParameter) aParameterMap = aBuilder->FindOrCreateAttribute( theObject, "AttributeParameter" );
+  if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
+  {
+    aParameterMap->SetInt( PARAMETER_COUNT, 0 );
+  }
+
+  return new GEOMGUI_AnnotationAttrs( theObject, aParameterMap );
+}
+
+//=================================================================================
+// function : Remove
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject )
+{
+  _PTR(GenericAttribute) aGenericAttr;
+  _PTR(AttributeParameter) aParameterMap;
+
+  if ( !theObject->FindAttribute( aGenericAttr, "AttributeParameter" ) )
+  {
+    return;
+  }
+
+  aParameterMap = aGenericAttr;
+
+  if ( !aParameterMap->IsSet( PARAMETER_COUNT, PT_INTEGER ) )
+  {
+    return;
+  }
+
+  const int aParamCount = aParameterMap->GetInt( PARAMETER_COUNT );
+
+  for ( int anI = 0; anI < aParamCount; ++anI )
+  {
+    aParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );
+    aParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );
+    aParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );
+    aParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );
+    aParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );
+    aParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );
+  }
+
+  aParameterMap->RemoveID( PARAMETER_COUNT, PT_INTEGER );
+}
+
+//=================================================================================
+// function : ExportAsPropertyString
+// purpose  : 
+//=================================================================================
+QString GEOMGUI_AnnotationAttrs::ExportAsPropertyString() const
+{
+  QStringList anItems;
+
+  for ( int anI = 0; anI < GetNbAnnotation(); ++anI )
+  {
+    Properties aEntry;
+
+    GetProperties( anI, aEntry );
+
+    anItems.append( toPattern( aEntry.Text,
+                               aEntry.IsScreenFixed,
+                               aEntry.Position,
+                               aEntry.Attach,
+                               aEntry.ShapeIndex,
+                               aEntry.ShapeType ) );
+  }
+
+  return anItems.join( ":" );
+}
+
+//=================================================================================
+// function : ImportFromPropertyString
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::ImportFromPropertyString( const QString& theString )
+{
+  SetNbAnnotation( 0 );
+
+  QRegExp aRegExpItemGroups( PATTERN_ITEM_GROUP );
+  QRegExp aRegExpItem( "^" + PATTERN_ITEM + "$" );
+  aRegExpItemGroups.setMinimal( true );
+  aRegExpItem.setMinimal( true );
+
+  int aPos = 0;
+  while ( ( aPos = aRegExpItemGroups.indexIn( theString, aPos ) ) != -1 )
+  {
+    aPos += aRegExpItemGroups.matchedLength();
+
+    QString aStrItem = aRegExpItemGroups.cap(1);
+
+    if ( aRegExpItem.indexIn( aStrItem ) < 0 )
+    {
+      continue;
+    }
+
+    QString aStrText       = aRegExpItem.cap( 1 );
+    QString aStrFixed      = aRegExpItem.cap( 2 );
+    QString aStrPosX       = aRegExpItem.cap( 3 );
+    QString aStrPosY       = aRegExpItem.cap( 4 );
+    QString aStrPosZ       = aRegExpItem.cap( 5 );
+    QString aStrAttX       = aRegExpItem.cap( 6 );
+    QString aStrAttY       = aRegExpItem.cap( 7 );
+    QString aStrAttZ       = aRegExpItem.cap( 8 );
+    QString aStrShapeIdx   = aRegExpItem.cap( 9 );
+    QString aStrShapeType  = aRegExpItem.cap( 10 );
+    aStrText.replace( "::", ":" );
+
+    Properties aEntry;
+    aEntry.Text = aStrText;
+    aEntry.IsVisible = false;
+    aEntry.IsScreenFixed = aStrFixed.toInt() != 0;
+    aEntry.Position.SetX( aStrPosX.toDouble() );
+    aEntry.Position.SetY( aStrPosY.toDouble() );
+    aEntry.Position.SetZ( aStrPosZ.toDouble() );
+    aEntry.Attach.SetX( aStrAttX.toDouble() );
+    aEntry.Attach.SetY( aStrAttY.toDouble() );
+    aEntry.Attach.SetZ( aStrAttZ.toDouble() );
+    aEntry.ShapeIndex = aStrShapeIdx.toInt();
+    aEntry.ShapeType = aStrShapeType.toInt();
+
+    Append( aEntry );
+  }
+}
+
+//=================================================================================
+// function : SetNbAnnotation
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetNbAnnotation( const int theCount ) const
+{
+  const int aCount = this->GetNbAnnotation();
+
+  if ( aCount < theCount )
+  {
+    // set default values
+    for ( int anI = aCount; anI < theCount; ++anI )
+    {
+      myParameterMap->SetBool( PARAMETER_IS_VISIBLE( anI ), true );
+      myParameterMap->SetBool( PARAMETER_IS_2D( anI ), false );
+      myParameterMap->SetString( PARAMETER_TEXT( anI ), std::string() );
+      myParameterMap->SetRealArray( PARAMETER_POSITION( anI ), std::vector<double>(3, 0.0) );
+      myParameterMap->SetRealArray( PARAMETER_ATTACH( anI ), std::vector<double>(3, 0.0) );
+      myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector<int>(2, 0) );
+    }
+  }
+  else
+  {
+    // remove exceeding values
+    for ( int anI = theCount; anI < aCount; ++anI )
+    {
+      myParameterMap->RemoveID( PARAMETER_IS_VISIBLE( anI ), PT_BOOLEAN );
+      myParameterMap->RemoveID( PARAMETER_IS_2D( anI ), PT_BOOLEAN );
+      myParameterMap->RemoveID( PARAMETER_TEXT( anI ), PT_STRING );
+      myParameterMap->RemoveID( PARAMETER_POSITION( anI ), PT_REALARRAY );
+      myParameterMap->RemoveID( PARAMETER_ATTACH( anI ), PT_REALARRAY );
+      myParameterMap->RemoveID( PARAMETER_SHAPE( anI ), PT_INTARRAY );
+    }
+  }
+
+  myParameterMap->SetInt( PARAMETER_COUNT, theCount );
+}
+
+//=================================================================================
+// function : GetNbAnnotation
+// purpose  : 
+//=================================================================================
+int GEOMGUI_AnnotationAttrs::GetNbAnnotation() const
+{
+  return myParameterMap->GetInt( PARAMETER_COUNT );
+}
+
+//=================================================================================
+// function : SetVisible
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetIsVisible( const int theIndex, const bool theIsVisible )
+{
+  myParameterMap->SetBool( PARAMETER_IS_VISIBLE( theIndex ), theIsVisible );
+}
+
+//=================================================================================
+// function : GetIsVisible
+// purpose  : 
+//=================================================================================
+bool GEOMGUI_AnnotationAttrs::GetIsVisible( const int theIndex ) const
+{
+  return myParameterMap->GetBool( PARAMETER_IS_VISIBLE( theIndex ) );
+}
+
+//=================================================================================
+// function : SetText
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetText( const int theIndex, const QString& theText )
+{
+  myParameterMap->SetString( PARAMETER_TEXT( theIndex ), theText.toStdString() );
+}
+
+//=================================================================================
+// function : GetText
+// purpose  : 
+//=================================================================================
+QString GEOMGUI_AnnotationAttrs::GetText( const int theIndex ) const
+{
+  return QString::fromStdString( myParameterMap->GetString( PARAMETER_TEXT( theIndex ) ) );
+}
+
+//=================================================================================
+// function : SetIsScreenFixed
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed )
+{
+  myParameterMap->SetBool( PARAMETER_IS_2D( theIndex ), theIsScreenFixed );
+}
+
+//=================================================================================
+// function : GetIsScreenFixed
+// purpose  : 
+//=================================================================================
+bool GEOMGUI_AnnotationAttrs::GetIsScreenFixed( const int theIndex ) const
+{
+  return myParameterMap->GetBool( PARAMETER_IS_2D( theIndex ) );
+}
+
+//=================================================================================
+// function : SetPosition
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetPosition( const int theIndex, const gp_Pnt& thePosition )
+{
+  std::vector<double> aCoords( 3 );
+
+  aCoords[0] = thePosition.X();
+  aCoords[1] = thePosition.Y();
+  aCoords[2] = thePosition.Z();
+
+  myParameterMap->SetRealArray( PARAMETER_POSITION( theIndex ), aCoords );
+}
+
+//=================================================================================
+// function : GetPosition
+// purpose  : 
+//=================================================================================
+gp_Pnt GEOMGUI_AnnotationAttrs::GetPosition( const int theIndex ) const
+{
+  std::vector<double> aCoords =
+    myParameterMap->GetRealArray( PARAMETER_POSITION( theIndex ) );
+
+  return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );
+}
+
+//=================================================================================
+// function : SetAttach
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetAttach( const int theIndex, const gp_Pnt& theAttach )
+{
+  std::vector<double> aCoords( 3 );
+
+  aCoords[0] = theAttach.X();
+  aCoords[1] = theAttach.Y();
+  aCoords[2] = theAttach.Z();
+
+  myParameterMap->SetRealArray( PARAMETER_ATTACH( theIndex ), aCoords );
+}
+
+//=================================================================================
+// function : GetAttach
+// purpose  : 
+//=================================================================================
+gp_Pnt GEOMGUI_AnnotationAttrs::GetAttach( const int theIndex ) const
+{
+  std::vector<double> aCoords =
+    myParameterMap->GetRealArray( PARAMETER_ATTACH( theIndex ) );
+
+  return gp_Pnt( aCoords[0], aCoords[1], aCoords[2] );
+}
+
+//=================================================================================
+// function : SetShapeSel
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx )
+{
+  std::vector<int> aSelection( 2 );
+
+  aSelection[0] = theShapeType;
+  aSelection[1] = theSubIdx;
+
+  myParameterMap->SetIntArray( PARAMETER_SHAPE( theIndex ), aSelection );
+}
+
+//=================================================================================
+// function : GetShapeSel
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const
+{
+  std::vector<int> aSelection =
+    myParameterMap->GetIntArray( PARAMETER_SHAPE( theIndex ) );
+
+  theShapeType = aSelection[0];
+  theSubIdx    = aSelection[1];
+}
+
+//=================================================================================
+// function : Append
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )
+{
+  this->Append( theProps, gp_Ax3() );
+}
+
+//=================================================================================
+// function : Append
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps, const gp_Ax3& theShapeLCS )
+{
+  const int aCount = this->GetNbAnnotation();
+  this->SetNbAnnotation( aCount + 1 );
+  this->SetProperties( aCount, theProps, theShapeLCS );
+}
+
+//=================================================================================
+// function : Remove
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::Remove( const Standard_Integer theIndex )
+{
+  const int aCount = this->GetNbAnnotation();
+  if ( theIndex < 0 || theIndex >= aCount ) {
+    return;
+  }
+
+  std::vector<Properties> aEntries( (aCount - 1) - theIndex );
+  for ( int anI = theIndex + 1; anI < aCount; ++anI ) {
+    GetProperties( anI, aEntries[ anI - (theIndex + 1) ] );
+  }
+
+  SetNbAnnotation( theIndex );
+
+  for ( int anI = 0; anI < static_cast<int>( aEntries.size() ); ++anI ) {
+    Append( aEntries[anI] );
+  }
+}
+
+//=================================================================================
+// function : SetProperties
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps )
+{
+  this->SetProperties( theIndex, theProps, gp_Ax3() );
+}
+
+//=================================================================================
+// function : SetProperties
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetProperties( const int theIndex, const Properties& theProps,
+                                             const gp_Ax3& theShapeLCS )
+{
+  gp_Trsf aToShapeLCS;
+  aToShapeLCS.SetTransformation( gp_Ax3(), theShapeLCS );
+
+  this->SetText( theIndex, theProps.Text );
+  this->SetIsVisible( theIndex, theProps.IsVisible );
+  this->SetIsScreenFixed( theIndex, theProps.IsScreenFixed );
+  this->SetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
+  this->SetAttach( theIndex, theProps.Attach.Transformed( aToShapeLCS ) );
+  this->SetPosition( theIndex, (theProps.IsScreenFixed) ? 
+    theProps.Position : theProps.Position.Transformed( aToShapeLCS ) );
+}
+
+//=================================================================================
+// function : GetProperties
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::GetProperties( const int theIndex, Properties& theProps ) const
+{
+  theProps.Text = this->GetText( theIndex );
+  theProps.IsVisible = this->GetIsVisible( theIndex );
+  theProps.IsScreenFixed = this->GetIsScreenFixed( theIndex );
+  theProps.Position = this->GetPosition( theIndex );
+  theProps.Attach = this->GetAttach( theIndex );
+
+  this->GetShapeSel( theIndex, theProps.ShapeType, theProps.ShapeIndex );
+}
+
+//=================================================================================
+// function : SetupPresentation
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
+                                                 const Properties& theProps,
+                                                 const gp_Ax3& theShapeLCS )
+{
+  gp_Trsf aFromShapeLCS;
+  aFromShapeLCS.SetTransformation( theShapeLCS, gp_Ax3() );
+
+  TCollection_ExtendedString aText;
+  for (int i = 0; i < (int)theProps.Text.length(); i++ )
+    aText.Insert( i + 1, theProps.Text[ i ].unicode() );
+
+  thePresentation->SetText( aText );
+  thePresentation->SetIsScreenFixed( theProps.IsScreenFixed );
+  thePresentation->SetAttachPoint( theProps.Attach.Transformed( aFromShapeLCS ) );
+  thePresentation->SetPosition( (theProps.IsScreenFixed) ? 
+    theProps.Position : theProps.Position.Transformed( aFromShapeLCS ) );
+}
+
+//=================================================================================
+// function : SetupPresentation
+// purpose  : 
+//=================================================================================
+void GEOMGUI_AnnotationAttrs::SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
+                                                 const int theIndex,
+                                                 const gp_Ax3& theShapeLCS )
+{
+  Properties aProps;
+  this->GetProperties( theIndex, aProps );
+  this->SetupPresentation( thePresentation, aProps, theShapeLCS );
+}
diff --git a/src/GEOMGUI/GEOMGUI_AnnotationAttrs.h b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.h
new file mode 100755 (executable)
index 0000000..9d93347
--- /dev/null
@@ -0,0 +1,220 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : GEOMGUI_AnnotationAttrs.h
+// Author : Anton POLETAEV, Open CASCADE S.A.S.
+//
+
+#ifndef GEOMGUI_ANNOTATIONATTRS_H
+#define GEOMGUI_ANNOTATIONATTRS_H
+
+// SALOME GUI includes
+#include <GEOMGUI.h>
+#include <SalomeApp_Study.h>
+
+// OCCT includes
+#include <gp_Ax3.hxx>
+#include <gp_Pnt.hxx>
+#include <Standard_Transient.hxx>
+
+// Qt, STL includes
+#include <QString>
+
+class GEOM_Annotation;
+class gp_Ax3;
+
+/*!
+ * \brief Attribute-style helper tool to manage shape annotation data of an object.
+ */
+class GEOMGUI_AnnotationAttrs : public Standard_Transient
+{
+public:
+
+  DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
+
+  //! Find annotation data defined for an object.
+  GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject );
+
+  //! Find or create annotation data fields for an object.
+  GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject,
+                                                                                SalomeApp_Study* theStudy );
+
+  //! Remove annotation data fields for an object.
+  GEOMGUI_EXPORT static void Remove( const _PTR(SObject)& theObject );
+
+// Import / Export
+public:
+
+  //! Exports annotation records as a property string.
+  GEOMGUI_EXPORT QString ExportAsPropertyString() const;
+
+  //! Imports annotation records from a property string.
+  GEOMGUI_EXPORT void ImportFromPropertyString( const QString& theString );
+
+public:
+
+  /*!
+   * \ brief Structure representing visual properties of the shape annotation.
+   */
+  struct Properties
+  {
+    QString Text;          //!< Displayed annotation text.
+    bool    IsVisible;     //!< Application visibility flag of annotation.
+    bool    IsScreenFixed; //!< Fixed screen mode flag.
+    gp_Pnt  Position;      //!< Position of the annotation.
+    gp_Pnt  Attach;        //!< Attachment point of the annotation.
+    int     ShapeIndex;    //!< Index of the annotated subshape.
+    int     ShapeType;     //!< Type of the annotated subshape.
+  };
+
+  //! Setup parameters of the annotation presentation with the properties given.
+  //! @param thePresentation [in] the presentation to setup.
+  //! @param theProps [in] the set of properties.
+  //! @param theShapeLCS [in] the local coordinate system of the shape.
+  GEOMGUI_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
+                                                const Properties& theProps,
+                                                const gp_Ax3& theShapeLCS );
+
+  //! Setup parameters of the annotation presentation with the properties of a definition.
+  //! @param thePresentation [in] the presentation to setup.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theShapeLCS [in] the local coordinate system of the shape.
+  GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
+                                         const int theIndex,
+                                         const gp_Ax3& theShapeLCS );
+
+public:
+
+  //! Changes count of annotation definitions stored on the object.
+  //! If the count is decreased the extra annotation definitions are
+  //! cleared out from the attribute.
+  //! @param theNumber [in] the new number of annotation definitions.
+  GEOMGUI_EXPORT void SetNbAnnotation( const int theCount ) const;
+
+  //! Returns number of annotation definitions stored on the object.
+  GEOMGUI_EXPORT int GetNbAnnotation() const;
+
+  //! Sets application visibility state of an annotation definition.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theIsVisible [in] the visibility state.
+  GEOMGUI_EXPORT void SetIsVisible( const int theIndex, const bool theIsVisible );
+
+  //! Returns applicationb visibility state of an annotaion definition.
+  GEOMGUI_EXPORT bool GetIsVisible( const int theIndex ) const;
+
+  //! Sets annotation label's text.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theText [in] the text string.
+  GEOMGUI_EXPORT void SetText( const int theIndex, const QString& theText );
+
+  //! Returns annotation label's text.
+  GEOMGUI_EXPORT QString GetText( const int theIndex ) const;
+
+  //! Sets screen fixed flag of the annotation definition.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theIsScreenFixed [in] the presentation flag.
+  GEOMGUI_EXPORT void SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed );
+
+  //! Returns screen fixed flag of the annotation definition.
+  GEOMGUI_EXPORT bool GetIsScreenFixed( const int theIndex ) const;
+
+  //! Sets position of the annotation definition.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param thePosition [in] the position of the annotation label.
+  GEOMGUI_EXPORT void SetPosition( const int theIndex, const gp_Pnt& thePosition );
+
+  //! Returns position of the annotation definition.
+  GEOMGUI_EXPORT gp_Pnt GetPosition( const int theIndex ) const;
+
+  //! Sets attach point of the annotation definition.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theAttach [in] the attach point of the annotation.
+  GEOMGUI_EXPORT void SetAttach( const int theIndex, const gp_Pnt& theAttach );
+
+  //! Returns attach point of the annotation definition.
+  GEOMGUI_EXPORT gp_Pnt GetAttach( const int theIndex ) const;
+
+  //! Sets shape selection arguments.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theShapeType, theSubIdx [in] the type of the selected shape and the sub-shape index.
+  GEOMGUI_EXPORT void SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx );
+
+  //! Returns shape selection arguments.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theShapeType, theSubIdx [out] the type of the selected shape and the sub-shape index.
+  GEOMGUI_EXPORT void GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const;
+
+public:
+
+  //! Appends new annotation definition with the given properties.
+  GEOMGUI_EXPORT void Append( const Properties& theProps );
+
+  //! Appends new annotation definition with the given properties and converts
+  //! position and attachment points to the given shape's local frame of reference.
+  //! @param theShapeLCS [in] the position of shape's local frame of reference with respect
+  //!        to the world frame of reference.
+  GEOMGUI_EXPORT void Append( const Properties& theProps, const gp_Ax3& theShapeLCS );
+
+  //! Removes annotation definition by the given index.
+  //! This methods performs iterative reindexing of elements starting
+  //! from the given index, so sequential removal should be performed
+  //! from the last element, or avoided at all.
+  GEOMGUI_EXPORT void Remove( const Standard_Integer theIndex );
+
+  //! Sets complete properties of an annotation definition.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theProps [in] the structure containing the properties.
+  GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps );
+
+  //! Sets complete properties of an annotation definition with converting
+  //! position and attachment points to the given shape's local frame
+  //! of reference.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theProps [in] the structure containing the properties.
+  //! @param theShapeLCS [in] the position of shape's local frame of reference with respect
+  //!        to the world frame of reference.
+  GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps, const gp_Ax3& theShapeLCS );
+
+  //! Returns complete properties of an annotation definition.
+  //! @param theIndex [in] the index of the annotation definition.
+  //! @param theProps [out] the structure containing the properties.
+  GEOMGUI_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const;
+
+private:
+
+  GEOMGUI_AnnotationAttrs( const _PTR(SObject)& theObject, const _PTR(AttributeParameter)& theParameter )
+  : myObj( theObject ),
+    myParameterMap( theParameter ) {}
+
+  GEOMGUI_AnnotationAttrs( const GEOMGUI_AnnotationAttrs& theOther ) {}
+
+  void operator=( const GEOMGUI_AnnotationAttrs& theOther ) {}
+
+private:
+
+  _PTR(SObject) myObj;
+  _PTR(AttributeParameter) myParameterMap;
+};
+
+DEFINE_STANDARD_HANDLE( GEOMGUI_AnnotationAttrs, Standard_Transient )
+
+#endif
diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx
new file mode 100755 (executable)
index 0000000..1c2e59e
--- /dev/null
@@ -0,0 +1,898 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "GEOMGUI_AnnotationMgr.h"
+
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOM_Annotation.hxx>
+#include <GEOM_Client.hxx>
+#include <GEOM_Constants.h>
+#include <GEOM_Displayer.h>
+#include <GEOMGUI_TextTreeWdg.h>
+
+#include <GeometryGUI.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SALOME_Prs.h>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+
+#include <SOCC_Prs.h>
+#include <SOCC_ViewWindow.h>
+
+#include <Quantity_Color.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <TopExp.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <gp_Ax3.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+#include <QFont>
+#include <QColor>
+
+
+GEOMGUI_AnnotationMgr::GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication )
+: myApplication( theApplication )
+{
+}
+
+QString GEOMGUI_AnnotationMgr::GetEntrySeparator()
+{
+        return "_annotation:";
+}
+
+//================================================================
+// Function : CreatePresentation
+// Purpose  :
+//================================================================
+SALOME_Prs* GEOMGUI_AnnotationMgr::CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
+                                                       GEOM::GEOM_Object_ptr theObject,
+                                                       SOCC_Viewer* theView,
+                                                       const QString& theEntry )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView ) {
+    return NULL;
+  }
+
+  Handle ( GEOM_Annotation ) aPresentation = new GEOM_Annotation();
+  if ( !theEntry.isEmpty() ) {
+    // owner should be set to provide selection mechanizm
+    Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject();
+    anIO->setEntry( theEntry.toLatin1().constData() );
+    aPresentation->SetOwner( anIO );
+  }
+
+  aPresentation->SetIsScreenFixed( theProperty.IsScreenFixed );
+
+  TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
+  if ( !aShape.IsNull() ) {
+
+    gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+
+    GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
+
+    if ( theProperty.ShapeType == TopAbs_SHAPE ) {
+
+      aPresentation->SetHilightShape( aShape );
+    }
+    else if ( theProperty.ShapeIndex > 0 ) {
+
+      TopTools_IndexedMapOfShape aSubShapeMap;
+      TopExp::MapShapes( aShape, static_cast<TopAbs_ShapeEnum>( theProperty.ShapeType ), aSubShapeMap );
+      if ( theProperty.ShapeIndex <= aSubShapeMap.Extent() ) {
+
+        aPresentation->SetHilightShape( aSubShapeMap( theProperty.ShapeIndex ) );
+      }
+    }
+  }
+
+  setDisplayProperties( aPresentation, aView, getEntry( theObject ).c_str() );
+
+  // add Prs to preview
+  //SUIT_ViewWindow* vw = getApplication()->desktop()->activeWindow();
+  SOCC_Prs* aPrs =
+      dynamic_cast<SOCC_Prs*>( ( aView )->CreatePrs( 0 ) );
+
+  if ( aPrs )
+    aPrs->AddObject( aPresentation );
+
+  return aPrs;
+}
+
+bool GEOMGUI_AnnotationMgr::IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView ) const
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView || !myVisualized.contains( aView ) )
+    return false;
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( theEntry ) )
+    return false;
+
+  AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+  if ( !anAnnotationToPrs.contains( theIndex ) )
+    return false;
+
+  return true;
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::Display
+// purpose  : Displays annotation shape presentation in view. It creates an annotation presentation
+// and stores it in an internal container
+//=======================================================================
+void GEOMGUI_AnnotationMgr::Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView,
+                                     const bool isStoreViewState, const bool isUpdateViewer )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView )
+    return;
+
+  if ( IsDisplayed( theEntry, theIndex, aView ) )
+    return;
+
+  GEOMGUI_AnnotationAttrs::Properties aProperty;
+  GEOM::GEOM_Object_ptr anObject;
+  getObject( theEntry, theIndex, anObject, aProperty );
+
+  // display presentation in the viewer
+  QString anEntry = QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
+  SALOME_Prs* aPrs = CreatePresentation( aProperty, anObject, aView, anEntry );
+  ((SALOME_View*)aView)->Display( getDisplayer(), aPrs );
+  if ( isUpdateViewer )
+    getDisplayer()->UpdateViewer();
+
+  EntryToAnnotations anEntryToMap;
+  if ( myVisualized.contains( aView ) )
+    anEntryToMap = myVisualized[aView];
+
+  // store displayed parameters to an internal container
+  AnnotationToPrs anAnnotationToPrsMap;
+  if ( anEntryToMap.contains( theEntry ) )
+    anAnnotationToPrsMap = anEntryToMap[theEntry];
+  anAnnotationToPrsMap[theIndex] = aPrs;
+  anEntryToMap[theEntry] = anAnnotationToPrsMap;
+  myVisualized[aView] = anEntryToMap;
+
+  if ( isStoreViewState ) {
+    // change persistent for the entry: set visible state in true for indices which presentations are shown
+    storeVisibleState( theEntry, theView );
+    storeFixedPosition( theEntry, theView );
+  }
+}
+
+void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
+                                       const GEOMGUI_AnnotationAttrs::Properties& theProperty )
+{
+  SUIT_Session* ses = SUIT_Session::session();
+  SUIT_Application* app = ses->activeApplication();
+  if ( app )
+  {
+    SUIT_Desktop* desk = app->desktop();
+    QList<SUIT_ViewWindow*> wnds = desk->windows();
+    SUIT_ViewWindow* wnd;
+    QListIterator<SUIT_ViewWindow*> it( wnds );
+    while ( it.hasNext() && (wnd = it.next()) )
+    {
+      SUIT_ViewManager* vman = wnd->getViewManager();
+      if ( vman )
+      {
+        SUIT_ViewModel* vmodel = vman->getViewModel();
+        if ( vmodel )
+        {
+          SOCC_Viewer* aView = dynamic_cast<SOCC_Viewer*>(vmodel);
+          if ( aView )
+            Redisplay( theEntry, theIndex, theProperty, aView );
+        }
+      }
+    }
+  }
+}
+
+void GEOMGUI_AnnotationMgr::Redisplay( const QString& theEntry, const int theIndex,
+                                       const GEOMGUI_AnnotationAttrs::Properties& theProperty,
+                                       SOCC_Viewer* theView )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView )
+    return;
+
+  if ( !myVisualized.contains( aView ) )
+    return;
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( theEntry ) )
+    return;
+
+  AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+  if ( !anAnnotationToPrs.contains( theIndex ) )
+    return;
+
+  GEOMGUI_AnnotationAttrs::Properties aProperty;
+  GEOM::GEOM_Object_ptr anObject;
+  getObject( theEntry, theIndex, anObject, aProperty );
+  TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), anObject );
+  gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+
+  // erase presentation from the viewer
+  SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
+  SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
+  if ( anOCCPrs ) {
+    AIS_ListOfInteractive anIOs;
+    anOCCPrs->GetObjects( anIOs );
+    AIS_ListIteratorOfListOfInteractive anIter( anIOs );
+
+    for ( ; anIter.More(); anIter.Next() ) {
+      Handle(AIS_InteractiveObject) aPrs = anIter.Value();
+      Handle(GEOM_Annotation) aPresentation = Handle(GEOM_Annotation)::DownCast( aPrs );
+
+      GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, theProperty, aShapeLCS );
+      aView->getAISContext()->Redisplay( aPresentation, Standard_True );
+    }
+  }
+}
+
+void GEOMGUI_AnnotationMgr::Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView,
+                                   const bool isUpdateViewer )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView )
+    return;
+
+  if ( !myVisualized.contains( aView ) )
+    return;
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( theEntry ) )
+    return;
+
+  AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+  if ( !anAnnotationToPrs.contains( theIndex ) )
+    return;
+
+  // erase presentation from the viewer
+  SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
+  ((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
+  if ( isUpdateViewer )
+    getDisplayer()->UpdateViewer();
+
+  // remove displayed parameters from an internal container
+  anAnnotationToPrs.remove( theIndex );
+  anEntryToAnnotation[theEntry] = anAnnotationToPrs;
+  if (anAnnotationToPrs.isEmpty()) {
+    anEntryToAnnotation.remove( theEntry );
+  }
+  else {
+    anEntryToAnnotation[theEntry] = anAnnotationToPrs;
+  }
+  myVisualized[aView] = anEntryToAnnotation;
+
+  // change persistent for the entry: set visible state in true for indices which presentations are shown
+  storeVisibleState( theEntry, theView );
+}
+
+void GEOMGUI_AnnotationMgr::DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView,
+                                                       const bool isUpdateViewer )
+{
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
+  const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+  if ( !aShapeAnnotations.IsNull() ) {
+    const int aCount = aShapeAnnotations->GetNbAnnotation();
+    std::vector<bool> isVisible( aCount );
+    for ( int anIndex = 0; anIndex < aCount; ++anIndex )
+    {
+      isVisible[anIndex] = aShapeAnnotations->GetIsVisible( anIndex );
+    }
+    for ( int anIndex = 0; anIndex < aCount; ++anIndex )
+    {
+      if ( isVisible[anIndex] )
+        Display( theEntry, anIndex, theView, true, isUpdateViewer );
+    }
+  }
+}
+
+void GEOMGUI_AnnotationMgr::EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView,
+                                                     const bool isUpdateViewer )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !myVisualized.contains( aView ) )
+    return;
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( theEntry ) )
+    return;
+  AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
+  const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+
+  const int aCount = aShapeAnnotations->GetNbAnnotation();
+  for ( int anIndex = 0; anIndex < aCount; ++anIndex )
+  {
+    if ( !anAnnotationToPrs.contains( anIndex ) )
+      continue;
+
+    // erase presentation from the viewer
+    SALOME_Prs* aPrs = anAnnotationToPrs[anIndex];
+    ((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
+  }
+  if ( isUpdateViewer )
+    getDisplayer()->UpdateViewer();
+  anEntryToAnnotation.remove( theEntry );
+  myVisualized[aView] = anEntryToAnnotation;
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::EraseRemovedAnnotation
+// purpose  : Method to update internal maps after removing an
+//  annotation from the object.
+//=======================================================================
+void GEOMGUI_AnnotationMgr::EraseRemovedAnnotation( const QString& theEntry, const int theIndex )
+{
+  QMap<SOCC_Viewer*, EntryToAnnotations>::iterator aEntryMapIt = myVisualized.begin();
+  for ( ; aEntryMapIt != myVisualized.end(); ++aEntryMapIt ) {
+    SOCC_Viewer* aView = aEntryMapIt.key();
+    EntryToAnnotations& anEntryToAnnotation = aEntryMapIt.value();
+    if ( !anEntryToAnnotation.contains( theEntry ) )
+      continue;
+
+    AnnotationToPrs aUpdatedToPrs;
+    AnnotationToPrs& anAnnotationToPrs = anEntryToAnnotation[theEntry];
+    AnnotationToPrs::iterator anAnnotationIt = anAnnotationToPrs.begin();
+    for ( ; anAnnotationIt != anAnnotationToPrs.end(); ++anAnnotationIt ) {
+
+      const int aIndex = anAnnotationIt.key();
+      SALOME_Prs* aPrs = anAnnotationIt.value();
+      if ( aIndex > theIndex ) {
+        aUpdatedToPrs[aIndex - 1] = aPrs;
+      }
+      else if ( aIndex != theIndex ) {
+        aUpdatedToPrs[aIndex] = aPrs;
+      }
+      else {
+        ((SALOME_View*)aView)->Erase( getDisplayer(), aPrs );
+      }
+    }
+
+    anAnnotationToPrs = aUpdatedToPrs;
+  }
+  getDisplayer()->UpdateViewer();
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations
+// purpose  : 
+//=======================================================================
+void GEOMGUI_AnnotationMgr::UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !myVisualized.contains( aView ) )
+    return;
+
+  EntryToAnnotations& anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( theEntry ) )
+    return;
+
+  AnnotationToPrs& anAnnotationToPrs = anEntryToAnnotation[theEntry];
+  AnnotationToPrs::iterator anIt = anAnnotationToPrs.begin();
+  for (; anIt != anAnnotationToPrs.end(); ++anIt ) {
+    SOCC_Prs* aPrs =
+      dynamic_cast<SOCC_Prs*> (anIt.value());
+
+    GEOMGUI_AnnotationAttrs::Properties aProperty;
+    GEOM::GEOM_Object_ptr anObject;
+    getObject( theEntry, anIt.key(), anObject, aProperty );
+    TopoDS_Shape aShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), anObject );
+    gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+
+    AIS_ListOfInteractive aIObjects;
+    aPrs->GetObjects( aIObjects );
+    AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
+    for ( ; aIOIt.More(); aIOIt.Next() ) {
+
+      Handle(GEOM_Annotation) aPresentation =
+        Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
+
+      if ( aPresentation.IsNull() )
+        continue;
+
+      if ( !aShape.IsNull() ) {
+
+        GEOMGUI_AnnotationAttrs::SetupPresentation( aPresentation, aProperty, aShapeLCS );
+        if ( aProperty.ShapeType == TopAbs_SHAPE ) {
+          aPresentation->SetHilightShape( aShape );
+        }
+        else if ( aProperty.ShapeIndex > 0 ) {
+          TopTools_IndexedMapOfShape aSubShapeMap;
+          TopExp::MapShapes( aShape, static_cast<TopAbs_ShapeEnum>( aProperty.ShapeType ), aSubShapeMap );
+          if ( aProperty.ShapeIndex <= aSubShapeMap.Extent() ) {
+            aPresentation->SetHilightShape( aSubShapeMap( aProperty.ShapeIndex ) );
+          }
+        }
+      }
+
+      setDisplayProperties( aPresentation, aView, theEntry );
+
+      aView->getAISContext()->Redisplay( aPresentation, Standard_True );
+    }
+  }
+  getDisplayer()->UpdateViewer();
+}
+
+void GEOMGUI_AnnotationMgr::DisplayAllAnnotations( SOCC_Viewer* theView )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !myVisualized.contains( aView ) )
+    return;
+
+  GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( getApplication()->activeModule() );
+  GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
+  QList<QString> anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  for ( int i = 0, aCount = anEntries.size(); i < aCount; i++ ) {
+     QString anEntry = anEntries[i];
+
+    _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( anEntry.toStdString() );
+    if ( !aSObj )
+      continue;
+
+    const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+    if ( aShapeAnnotations.IsNull() )
+      continue;
+
+    int anAnnotationsCount = aShapeAnnotations->GetNbAnnotation();
+    for ( int anIndex = 0; anIndex < anAnnotationsCount; ++anIndex )
+    {
+      Display( anEntry, anIndex, aView, false, false );
+    }
+    getDisplayer()->UpdateViewer();
+    storeVisibleState( anEntry, aView );
+    storeFixedPosition( anEntry, aView );
+  }
+}
+
+void GEOMGUI_AnnotationMgr::EraseAllAnnotations( SOCC_Viewer* theView )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !myVisualized.contains( aView ) )
+    return;
+
+  GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( getApplication()->activeModule() );
+  GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
+  QList<QString> anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
+
+  for ( int i = 0, aCount = anEntries.size(); i < aCount; i++ ) {
+    QString anEntry = anEntries[i];
+    EraseVisibleAnnotations( anEntry, aView, false );
+    storeVisibleState( anEntry, aView );
+  }
+  getDisplayer()->UpdateViewer();
+}
+
+void GEOMGUI_AnnotationMgr::SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview )
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 255, 255, 255 ) );
+  const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 255, 255, 255 ) );
+
+  const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB );
+  const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB );
+
+  QMap<SOCC_Viewer*, EntryToAnnotations>::Iterator aViewIt = myVisualized.begin();
+  for (; aViewIt != myVisualized.end(); ++aViewIt ) {
+
+    Handle(GEOM_Annotation) aPresentation = getAISPresentation ( theEntry, theIndex, aViewIt.key() );
+    if ( aPresentation.IsNull() ) {
+      continue;
+    }
+
+    if ( theIsPreview ) {
+      aPresentation->SetTextColor( Quantity_NOC_VIOLET );
+      aPresentation->SetLineColor( Quantity_NOC_VIOLET );
+      aPresentation->SetDepthCulling( Standard_False );
+    }
+    else {
+      aPresentation->SetTextColor( aOcctFontColor );
+      aPresentation->SetLineColor( aOcctLineColor );
+      aPresentation->SetDepthCulling( Standard_True );
+    }
+  }
+  getDisplayer()->UpdateViewer();
+}
+
+Handle(SALOME_InteractiveObject) GEOMGUI_AnnotationMgr::FindInteractiveObject( const QString& theEntry,
+                                                                               const int theIndex,
+                                                                               SOCC_Viewer* theView ) const
+{
+  Handle(SALOME_InteractiveObject) anIO;
+
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !myVisualized.contains( aView ) )
+    return anIO;
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( theEntry ) )
+    return anIO;
+
+  AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[theEntry];
+  if ( !anAnnotationToPrs.contains(theIndex) )
+    return anIO;
+
+  SALOME_Prs* aPrs = anAnnotationToPrs[theIndex];
+  SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
+  if ( !anOCCPrs )
+    return anIO;
+
+  AIS_ListOfInteractive anIOs;
+  anOCCPrs->GetObjects( anIOs );
+  AIS_ListIteratorOfListOfInteractive anIter( anIOs );
+  for ( ; anIter.More() && anIO.IsNull(); anIter.Next() ) {
+    Handle(AIS_InteractiveObject) aPrs = anIter.Value();
+    if ( aPrs->GetOwner() )
+      anIO = Handle(SALOME_InteractiveObject)::DownCast( aPrs->GetOwner() );
+  }
+  return anIO;
+}
+
+int GEOMGUI_AnnotationMgr::FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
+                                                SOCC_Viewer* theView )
+{
+  int anIndex = -1;
+
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !myVisualized.contains( aView ) )
+    return anIndex;
+
+  QString anEntry = theIO->getEntry();
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  if ( !anEntryToAnnotation.contains( anEntry ) )
+    return anIndex;
+
+  AnnotationToPrs anAnnotationToPrs = anEntryToAnnotation[anEntry];
+  //typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
+  AnnotationToPrs::const_iterator anIt = anAnnotationToPrs.begin(),
+                                  aLast = anAnnotationToPrs.end();
+  for (; anIt != aLast && anIndex < 0; anIt++) {
+    SALOME_Prs* aPrs = anIt.value();
+    SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
+    if ( !anOCCPrs )
+      continue;
+
+    AIS_ListOfInteractive anIOs;
+    anOCCPrs->GetObjects( anIOs );
+    AIS_ListIteratorOfListOfInteractive anIter( anIOs );
+    for ( ; anIter.More() && anIndex < 0; anIter.Next() ) {
+      Handle(AIS_InteractiveObject) aPrs = anIter.Value();
+      if ( aPrs->GetOwner() ) {
+        Handle(SALOME_InteractiveObject) aPrsOwner = Handle(SALOME_InteractiveObject)::DownCast(aPrs->GetOwner());
+        if ( aPrsOwner == theIO )
+          anIndex = anIt.key();
+      }
+    }
+  }
+
+  return anIndex;
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::RemoveView
+// purpose  : 
+//=======================================================================
+void GEOMGUI_AnnotationMgr::RemoveView( SOCC_Viewer* theView )
+{
+  if ( !theView && myVisualized.contains( theView ) )
+    myVisualized.remove( theView );
+}
+
+QString GEOMGUI_AnnotationMgr::getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const
+{
+  QString aDisplayedIndices;
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
+  if ( !aSObj )
+  {
+    return aDisplayedIndices;
+  }
+  const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+  if ( !aShapeAnnotations.IsNull() )
+  {
+    const int aCount = aShapeAnnotations->GetNbAnnotation();
+    QStringList anIndices;
+    for ( int anIndex = 0; anIndex < aCount; ++anIndex )
+    {
+      if (IsDisplayed( theEntry, anIndex, theView ) )
+        anIndices.append( QString::number(anIndex) );
+    }
+    aDisplayedIndices = anIndices.join(";");
+  }
+  return aDisplayedIndices;
+}
+
+void GEOMGUI_AnnotationMgr::setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView,
+                                                     const QString theIndicesInfo )
+{
+  if ( theIndicesInfo.isEmpty() )
+    return;
+
+  QStringList anIndices = theIndicesInfo.split( ";" );
+  for ( int i = 0, aCount = anIndices.size(); i < aCount; i++ ) {
+    Display( theEntry, anIndices[i].toInt(), theView );
+  }
+}
+
+GEOM_Displayer* GEOMGUI_AnnotationMgr::getDisplayer() const
+{
+  LightApp_Module* aModule = dynamic_cast<LightApp_Module*>( getApplication()->activeModule() );
+  return dynamic_cast<GEOM_Displayer*>( aModule->displayer() );
+}
+
+SOCC_Viewer* GEOMGUI_AnnotationMgr::viewOrActiveView( SOCC_Viewer* theView ) const
+{
+  SOCC_Viewer* aView = theView;
+  if ( !aView ) {
+    SalomeApp_Application* anApp = getApplication();
+    SUIT_ViewWindow* anActiveWindow = anApp->desktop()->activeWindow();
+    if ( anActiveWindow ) {
+      aView = dynamic_cast<SOCC_Viewer*>( anActiveWindow->getViewManager()->getViewModel() );
+    }
+  }
+  return aView;
+}
+
+QString GEOMGUI_AnnotationMgr::makeAnnotationEntry( const QString& theEntry, const int theIndex )
+{
+  return QString("%1%2%3").arg(theEntry).arg(GetEntrySeparator()).arg(theIndex);
+}
+
+bool GEOMGUI_AnnotationMgr::getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex )
+{
+  QStringList aSplit = theEntry.split( GetEntrySeparator() );
+  if ( aSplit.size() < 2 )
+    return false;
+
+  bool isOk = true;
+  theObjEntry = aSplit.at( 0 );
+  theIndex = aSplit.at( 1 ).toInt( &isOk );
+  return isOk;
+}
+
+void GEOMGUI_AnnotationMgr::getObject( const QString& theEntry, const int theIndex,
+                                       GEOM::GEOM_Object_ptr& theObject,
+                                       GEOMGUI_AnnotationAttrs::Properties& theProperty )
+{
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
+  const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+  if ( !aShapeAnnotations.IsNull() ) {
+    aShapeAnnotations->GetProperties( theIndex, theProperty );
+
+    theObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject(aSObj) );
+  }
+}
+
+void GEOMGUI_AnnotationMgr::storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView || !myVisualized.contains( aView ) )
+    return;
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
+  const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+  if ( aShapeAnnotations.IsNull() )
+    return;
+
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  AnnotationToPrs anAnnotationToPrs;
+  if ( anEntryToAnnotation.contains( theEntry ) )
+    anAnnotationToPrs = anEntryToAnnotation[theEntry];
+
+  AnnotationToPrs::iterator anIt = anAnnotationToPrs.begin();
+  for (; anIt != anAnnotationToPrs.end(); ++anIt ) {
+    int anIndex = anIt.key();
+    bool isFixedAnnotation = aShapeAnnotations->GetIsScreenFixed( anIndex );
+    if ( !isFixedAnnotation )
+      continue;
+
+    SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*> (anIt.value());
+    Handle(GEOM_Annotation) anAnnotationPresentation;
+
+    AIS_ListOfInteractive aIObjects;
+    aPrs->GetObjects( aIObjects );
+    AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
+    for ( ; aIOIt.More(); aIOIt.Next() ) {
+      anAnnotationPresentation = Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
+      if ( !anAnnotationPresentation.IsNull() )
+        break;
+    }
+    if ( !anAnnotationPresentation.IsNull() )
+      aShapeAnnotations->SetPosition( anIndex, anAnnotationPresentation->GetPosition() );
+  }
+}
+
+void GEOMGUI_AnnotationMgr::storeVisibleState( const QString& theEntry, SOCC_Viewer* theView )
+{
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( !aView || !myVisualized.contains( aView ) )
+    return;
+
+  EntryToAnnotations anEntryToAnnotation = myVisualized[aView];
+  AnnotationToPrs anAnnotationToPrs;
+  if ( anEntryToAnnotation.contains( theEntry ) )
+    anAnnotationToPrs = anEntryToAnnotation[theEntry];
+
+
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( theEntry.toStdString() );
+  const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+  if ( !aShapeAnnotations.IsNull() ) {
+    const int aCount = aShapeAnnotations->GetNbAnnotation();
+    for ( int anIndex = 0; anIndex < aCount; ++anIndex ) {
+      bool aVisible = anAnnotationToPrs.contains( anIndex );
+      aShapeAnnotations->SetIsVisible( anIndex, aVisible );
+    }
+  }
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::getEntry
+// purpose  : 
+//=======================================================================
+std::string GEOMGUI_AnnotationMgr::getEntry( const GEOM::GEOM_Object_ptr theObject )
+{
+  SUIT_Session* session = SUIT_Session::session();
+  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
+  if ( app )
+  {
+    CORBA::String_var IOR = app->orb()->object_to_string( theObject );
+    if ( strcmp(IOR.in(), "") != 0 )
+    {
+      SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
+      _PTR(SObject) SO ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
+      if ( SO )
+        return SO->GetID();
+    }
+  }
+  return std::string();
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::getName
+// purpose  : 
+//=======================================================================
+std::string GEOMGUI_AnnotationMgr::getName( const GEOM::GEOM_Object_ptr theObject )
+{
+  SUIT_Session* session = SUIT_Session::session();
+  SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
+  if ( app )
+  {
+    CORBA::String_var IOR = app->orb()->object_to_string( theObject );
+    if ( strcmp(IOR.in(), "") != 0 )
+    {
+      SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
+      _PTR(SObject) aSObj ( study->studyDS()->FindObjectIOR( std::string(IOR) ) );
+
+      _PTR(GenericAttribute) anAttr;
+
+      if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
+      {
+        _PTR(AttributeName) aNameAttr( anAttr );
+        return aNameAttr->Value();
+      }
+    }
+  }
+  return std::string();
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::setDisplayProperties
+// purpose  : 
+//=======================================================================
+void GEOMGUI_AnnotationMgr::setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
+                                                  SOCC_Viewer* theView,
+                                                  const QString& theEntry )
+{
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  const QFont  aFont      = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
+  const QColor aFontColor = aResMgr->colorValue( "Geometry", "shape_annotation_font_color", QColor( 0, 0, 127 ) );
+  const QColor aLineColor = aResMgr->colorValue( "Geometry", "shape_annotation_line_color", QColor( 0, 0, 127 ) );
+  const double aLineWidth = aResMgr->doubleValue( "Geometry", "shape_annotation_line_width", 1.0 );
+  const int aLineStyle    = aResMgr->integerValue( "Geometry", "shape_annotation_line_style", 0 );
+  const bool isAutoHide   = aResMgr->booleanValue( "Geometry", "shape_annotation_autohide", false );
+
+  const Quantity_Color aOcctFontColor( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB );
+  const Quantity_Color aOcctLineColor( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB );
+  const Standard_Real aFontHeight = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize();
+
+  thePrs->SetFont( TCollection_AsciiString( aFont.family().toLatin1().data() ) );
+  thePrs->SetTextHeight( aFontHeight );
+  thePrs->SetTextColor( Quantity_Color( aFontColor.redF(), aFontColor.greenF(), aFontColor.blueF(), Quantity_TOC_RGB ) );
+  thePrs->SetLineColor( Quantity_Color( aLineColor.redF(), aLineColor.greenF(), aLineColor.blueF(), Quantity_TOC_RGB ) );
+  thePrs->SetLineWidth( aLineWidth );
+  thePrs->SetLineStyle( static_cast<Aspect_TypeOfLine>( aLineStyle ) );
+  thePrs->SetAutoHide( isAutoHide ? Standard_True : Standard_False );
+  thePrs->SetDepthCulling( Standard_True );
+
+  SOCC_Viewer* aView = viewOrActiveView( theView );
+  if ( aView && !theEntry.isEmpty() ) {
+
+    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( getApplication()->activeStudy() );
+    int aMgrId = dynamic_cast< SUIT_ViewModel* >( aView )->getViewManager()->getGlobalId();
+    QVariant aVal = aStudy->getObjectProperty( aMgrId, theEntry, GEOM::propertyName( GEOM::TopLevel ), QVariant() );
+    bool isBringToFront = aVal.isValid() ? aVal.toBool() : false;
+    if( isBringToFront ) {
+      thePrs->SetZLayer( Graphic3d_ZLayerId_Topmost );
+    }
+    else {
+      thePrs->SetDefaultZLayer();
+    }
+  }
+  else {
+    thePrs->SetDefaultZLayer();
+  }
+}
+
+//=======================================================================
+// function : GEOMGUI_AnnotationMgr::getAISPresentation
+// purpose  : 
+//=======================================================================
+Handle(GEOM_Annotation) GEOMGUI_AnnotationMgr::getAISPresentation ( const QString& theEntry,
+                                                                    const int theIndex,
+                                                                    SOCC_Viewer* theView )
+{
+  if ( !myVisualized.contains( theView ) ) {
+    return Handle(GEOM_Annotation)();
+  }
+
+  EntryToAnnotations& aEntryToAnnotation = myVisualized[theView];
+  if ( !aEntryToAnnotation.contains( theEntry ) ) {
+    return Handle(GEOM_Annotation)();
+  }
+
+  AnnotationToPrs& aAnnotationToPrs = aEntryToAnnotation[theEntry];
+  if ( !aAnnotationToPrs.contains( theIndex ) ) {
+    return Handle(GEOM_Annotation)();
+  }
+
+  SALOME_Prs* aPrs = aAnnotationToPrs[theIndex];
+
+  // set or unset preview style for the presentation
+  AIS_ListOfInteractive aIObjects;
+  ((SOCC_Prs*)aPrs)->GetObjects( aIObjects );
+  AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
+  for ( ; aIOIt.More(); aIOIt.Next() ) {
+    return Handle(GEOM_Annotation)::DownCast( aIOIt.Value() );
+  }
+
+  return Handle(GEOM_Annotation)();
+}
diff --git a/src/GEOMGUI/GEOMGUI_AnnotationMgr.h b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h
new file mode 100755 (executable)
index 0000000..52d3b12
--- /dev/null
@@ -0,0 +1,136 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef GEOMGUI_ANNOTATIONMGR_H
+#define GEOMGUI_ANNOTATIONMGR_H
+
+#include "GEOM_GEOMGUI.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
+#include <QObject>
+#include <GEOMGUI_AnnotationAttrs.h>
+
+#include <SALOME_Prs.h>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SOCC_ViewModel.h>
+
+class SalomeApp_Application;
+class GEOM_Annotation;
+class GEOM_Displayer;
+
+/*!
+ * \brief A help class to process visualizatin of annotation presentations.
+ * It contains a map of presentations shown in each viewer.
+ * and correct 2D position persistent properties of annotations of active viewer.
+ * When the viewer is closed, information about the viewer is removed from the manager 
+ */
+class GEOMGUI_EXPORT GEOMGUI_AnnotationMgr : public QObject
+{
+  Q_OBJECT;
+
+public:
+  GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication );
+  ~GEOMGUI_AnnotationMgr() {}
+
+  static QString GetEntrySeparator();
+
+  SALOME_Prs* CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
+                                  GEOM::GEOM_Object_ptr theObject,
+                                  SOCC_Viewer* theView = 0,
+                                  const QString& theEntry = QString() );
+
+  bool IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0 ) const;
+  void Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
+                const bool isStoreViewState = true, const bool isUpdateViewer = true );
+  void Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
+              const bool isUpdateViewer = true );
+  void EraseRemovedAnnotation( const QString& theEntry, const int theIndex );
+  void Redisplay( const QString& theEntry, const int theIndex,
+                  const GEOMGUI_AnnotationAttrs::Properties& theProperties);
+  void Redisplay( const QString& theEntry, const int theIndex,
+                  const GEOMGUI_AnnotationAttrs::Properties& theProperties, SOCC_Viewer* theView );
+
+  void DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
+                                  const bool isUpdateViewer = true );
+  void EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
+                                const bool isUpdateViewer = true );
+  void UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
+
+  void DisplayAllAnnotations( SOCC_Viewer* theView = 0 );
+  void EraseAllAnnotations( SOCC_Viewer* theView = 0 );
+
+  void SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview );
+
+  void RemoveView( SOCC_Viewer* theView );
+
+  int FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
+                           SOCC_Viewer* theView = 0 );
+
+  Handle(SALOME_InteractiveObject) FindInteractiveObject( const QString& theEntry, const int theIndex,
+                                                          SOCC_Viewer* theView = 0 ) const;
+
+  QString getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const;
+
+  void setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView, const QString theIndicesInfo );
+
+  QString makeAnnotationEntry( const QString& theEntry, const int theIndex );
+
+  void storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView );
+
+  bool getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex );
+
+  bool isAnnotationEntry( const QString& theEntry ) { return theEntry.indexOf( GetEntrySeparator() ) != -1; }
+
+protected:
+
+  SalomeApp_Application* getApplication() const { return myApplication; }
+
+  GEOM_Displayer* getDisplayer() const;
+
+  SOCC_Viewer* viewOrActiveView( SOCC_Viewer* theView ) const;
+
+  void getObject( const QString& theEntry, const int theIndex,
+                  GEOM::GEOM_Object_ptr& anObject,
+                  GEOMGUI_AnnotationAttrs::Properties& aProperty );
+
+  void storeVisibleState( const QString& theEntry, SOCC_Viewer* theView );
+
+  std::string getEntry( const GEOM::GEOM_Object_ptr theObject );
+
+  std::string getName( const GEOM::GEOM_Object_ptr theObject );
+
+  void setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
+                             SOCC_Viewer* theView = 0,
+                             const QString& theEntry = QString() );
+
+  Handle(GEOM_Annotation) getAISPresentation ( const QString& theEntry,
+                                               const int theIndex,
+                                               SOCC_Viewer* theView );
+
+private:
+  SalomeApp_Application* myApplication;
+
+  typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
+  typedef QMap<QString, AnnotationToPrs> EntryToAnnotations;
+  QMap<SOCC_Viewer*, EntryToAnnotations> myVisualized;
+};
+#endif
index 3ff770055b1b31a242ef84d48ce1468020543571..a2397968cce67a1c4565bd7adffeb430f188e547 100644 (file)
@@ -42,6 +42,9 @@
 
 class SalomeApp_Study;
 
+class GEOMGUI_DimensionProperty;
+typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
+
 /*!
  * \brief Utility class to unpack/pack dimension presentations as object property of study.
  *
index b79ea3d350a7f6ea381854b8f6b8b2192c5957d7..4ab85d38aaef72bab3eb7d43aaf3f102085ba833 100644 (file)
@@ -24,6 +24,7 @@
 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S. (alexander.solovyov@opencascade.com)
 //
 #include "GEOMGUI_OCCSelector.h"
+#include "GEOM_Annotation.hxx"
 
 #include <Basics_OCCTVersion.hxx>
 
@@ -300,8 +301,16 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
       {
         anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i ));
 
-        if ( anOwner.IsNull() || !anOwner->HasShape() )
+        if ( anOwner.IsNull() || !anOwner->HasShape() ) {
+          if ( globalSelMap.contains( entryStr ) ) {
+            Handle(GEOM_Annotation::GEOM_AnnotationOwner) anAnnotationOwner =
+                               Handle(GEOM_Annotation::GEOM_AnnotationOwner)::DownCast(owners( i ));
+            if ( !anAnnotationOwner.IsNull() ) {
+              ownersmap.Add( anAnnotationOwner );
+            }
+          }
           continue;
+        }
 
         // GLOBAL selection
         if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) )
index 51fd1788927a8f834e3b52c82f085532a9bff0b2..0644ff317015fe5f28cdcde47e4db086dde88495 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "GEOMGUI_Selection.h"
 #include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOMGUI_AnnotationMgr.h>
 
 #include "GeometryGUI.h"
 #include "GEOM_Displayer.h"
@@ -151,6 +153,8 @@ QVariant GEOMGUI_Selection::parameter( const QString& p ) const
     v = hasImported();
   else if ( p == "allImported" )
     v = allImported();
+  else if (p == "annotationsCount")
+    v = annotationsCount();
   else
     v = LightApp_Selection::parameter( p );
   return v;
@@ -198,6 +202,10 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
     v = hasHiddenDimensions(idx);
   else if ( p == "hasVisibleDimensions" )
     v = hasVisibleDimensions(idx);
+  else if ( p == "hasHiddenAnnotations" )
+    v = hasHiddenAnnotations(idx);
+  else if ( p == "hasVisibleAnnotations" )
+    v = hasVisibleAnnotations(idx);
   else
     v = LightApp_Selection::parameter( idx, p );
 
@@ -207,6 +215,9 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
 // the method to skip temporary objects from selection (called from LightApp)
 bool GEOMGUI_Selection::processOwner( const LightApp_DataOwner* theOwner )
 {
+  if ( theOwner->entry().contains( GEOMGUI_AnnotationMgr::GetEntrySeparator() ) ) {
+    myAnnotationEntries.append( theOwner->entry() );
+  }
   return !theOwner->entry().contains("_");
 }
 
@@ -527,10 +538,8 @@ bool GEOMGUI_Selection::isNameMode( const int index ) const
 
 bool GEOMGUI_Selection::hasChildren( const _PTR(SObject)& obj )
 {
-  if ( obj ) {
-    // as soon as Use Case browser data tree was added
-    return obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj );
-  }
+  // as soon as Use Case browser data tree was added
+  return obj ? obj->GetStudy()->GetUseCaseBuilder()->HasChildren( obj ) : false;
 }
 
 bool GEOMGUI_Selection::expandable( const _PTR(SObject)& obj )
@@ -853,3 +862,63 @@ bool GEOMGUI_Selection::hasVisibleDimensions( const int theIndex ) const
   return isAnyVisible;
 }
 
+int GEOMGUI_Selection::annotationsCount() const
+{
+  return myAnnotationEntries.size();
+}
+
+bool GEOMGUI_Selection::hasAnnotations( 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;
+
+  _PTR(SObject) aSObj = appStudy->studyDS()->FindObjectID( anEntry.toStdString() );\r
+
+  const Handle(GEOMGUI_AnnotationAttrs)\r
+    aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );\r
+
+  if ( aShapeAnnotations.IsNull() )\r
+    return false;\r
+
+  theHidden  = false;
+  theVisible = false;
+
+  const int aCount = aShapeAnnotations->GetNbAnnotation();
+  for ( int anI = 0; anI < aCount; ++anI )
+  {
+    if ( aShapeAnnotations->GetIsVisible( anI ) )
+      theVisible = true;
+    else
+      theHidden = true;
+  }
+
+  return aCount > 0;
+}
+
+bool GEOMGUI_Selection::hasHiddenAnnotations( const int theIndex ) const
+{
+  bool isAnyVisible, isAnyHidden = false;
+  if ( !hasAnnotations( theIndex, isAnyHidden, isAnyVisible ) )
+  {
+    return false;
+  }
+
+  return isAnyHidden;
+}
+
+bool GEOMGUI_Selection::hasVisibleAnnotations( const int theIndex ) const
+{
+  bool isAnyVisible, isAnyHidden = false;
+  if ( !hasAnnotations( theIndex, isAnyHidden, isAnyVisible ) )
+  {
+    return false;
+  }
+
+  return isAnyVisible;
+}
index c5d229aa8a9b88073d3fbcee31113082a4e3d261..76dda787c30b473f2eff936f65d538162ccd40c7 100644 (file)
@@ -85,6 +85,12 @@ private:
   bool                  hasHiddenDimensions( const int ) const;
   bool                  hasVisibleDimensions( const int ) const;
 
+  int                   annotationsCount() const;
+
+  bool                  hasAnnotations( const int, bool&, bool& ) const;
+  bool                  hasHiddenAnnotations( const int ) const;
+  bool                  hasVisibleAnnotations( const int ) const;
+
   GEOM::GEOM_Object_ptr getObject( const int ) const;
   GEOM::GEOM_BaseObject_ptr getBaseObject( const int ) const;
 
@@ -98,6 +104,7 @@ private:
 
 private:
   GeomObjectVector      myObjects;
+  QStringList           myAnnotationEntries;
 };
 
 #endif
diff --git a/src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx b/src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx
new file mode 100644 (file)
index 0000000..8d77a3d
--- /dev/null
@@ -0,0 +1,168 @@
+// Copyright (C) 2015-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : GEOMGUI_TextTreeSelector.cxx
+// Author :
+//
+#include "GEOMGUI_TextTreeSelector.h"
+#include "GEOMGUI_TextTreeWdg.h"
+#include "GEOMGUI_AnnotationMgr.h"
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
+#include "LightApp_Application.h"
+#include <SUIT_Session.h>
+#include <SUIT_DataObjectIterator.h>
+
+/*!
+  \class GEOMGUI_TextTreeSelector
+  \brief Text tree selection handler class. It provides selection synchronization between
+  application and text tree widget. This selector listens item selection changed signal of
+  text tree widget to emit common selection changed signal of SUIT selector to start selection
+  synchronization. In get/setSelection selector processes annotation items. These items have
+  specific entry generated in annotation manager, having the "object entry:annotation_id" structure.
+*/
+
+/*!
+  \brief Constructor.
+  \param widget text tree widget
+  \param theManager selection manager
+*/
+GEOMGUI_TextTreeSelector::GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget,
+                                                    GEOMGUI_AnnotationMgr* theAnnotationMgr,
+                                                    SUIT_SelectionMgr* theManager )
+: SUIT_Selector( theManager, theWidget ),
+  myTextTree( theWidget ), myAnnotationMgr( theAnnotationMgr )
+{
+  if ( myTextTree ) {
+    connect( myTextTree, SIGNAL( itemSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
+  }
+}
+
+/*!
+  \brief Destructor.
+*/
+GEOMGUI_TextTreeSelector::~GEOMGUI_TextTreeSelector()
+{
+}
+
+/*!
+  \brief Get object browser.
+  \return a pointer to the text tree widget
+*/
+GEOMGUI_TextTreeWdg* GEOMGUI_TextTreeSelector::textTree() const
+{
+  return myTextTree;
+}
+
+/*!
+  \brief Get selector unique type.
+  \return selector type
+*/
+QString GEOMGUI_TextTreeSelector::type() const
+{ 
+  return "TextTree";
+}
+
+/*!
+  \brief Called when the Object browser selection is changed. It emits signal to synchronize
+  selection in application.
+*/
+void GEOMGUI_TextTreeSelector::onSelectionChanged()
+{
+  mySelectedList.clear();
+  selectionChanged();
+}
+
+/*!
+  \brief Get list of currently selected annotation objects.
+  \param theList list to be filled with the selected objects owners
+  The list contains owners for interactive objects of annotations
+*/
+void GEOMGUI_TextTreeSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
+{
+  if ( mySelectedList.count() == 0 ) {
+
+    GEOMGUI_TextTreeSelector* aThisSelector = (GEOMGUI_TextTreeSelector*)this;
+    QMap<QString, QList<int> > aSelectedAnnotations;
+    myTextTree->getSelected(aSelectedAnnotations);
+
+    QMap<QString, QList<int> >::const_iterator anIt = aSelectedAnnotations.begin(),
+                                               aLast = aSelectedAnnotations.end();
+    for ( ; anIt != aLast; anIt++ ) {
+      QString anEntry = anIt.key();
+      QList<int> anIndices = anIt.value();
+      QList<int>::const_iterator anIdIt = anIndices.begin(), anIdLast = anIndices.end();
+      for ( ; anIdIt != anIdLast; anIdIt++ ) {
+        int anIndex = *anIdIt;
+        Handle(SALOME_InteractiveObject) anIO = myAnnotationMgr->FindInteractiveObject( anEntry, anIndex );
+        if ( anIO.IsNull() )
+          continue;
+
+        LightApp_DataOwner* owner = new LightApp_DataOwner( anIO );
+        aThisSelector->mySelectedList.append( SUIT_DataOwnerPtr( owner ) );
+      }
+    }
+  }
+  theList = mySelectedList;
+}
+
+/*!
+  \brief Set selection.
+  \param theList list of the object owners to be set selected
+*/
+void GEOMGUI_TextTreeSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
+{
+  if ( !myTextTree )
+    return;
+
+  QMap<QString, QList<int> > aSelectedAnnotations;
+  DataObjectList objList;
+  for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); 
+        it != theList.end(); ++it ) {
+    const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+    if ( !anOwner )
+      continue;
+    Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
+    if ( anIO.IsNull() )
+      continue;
+
+    QString anIOEntry = anIO->getEntry();
+    QStringList anAnnotationInfo = anIOEntry.split(GEOMGUI_AnnotationMgr::GetEntrySeparator());
+    if (anAnnotationInfo.size() != 2 )
+      continue;
+
+    QString anEntry = anAnnotationInfo[0];
+    int anAnnotationId = anAnnotationInfo[1].toInt();
+    if ( anAnnotationId <  0)
+      continue;
+
+    QList<int> anIndices;
+    if ( aSelectedAnnotations.contains( anEntry ) )
+      anIndices = aSelectedAnnotations[anEntry];
+
+    if ( !anIndices.contains( anAnnotationId ) )
+      anIndices.append( anAnnotationId );
+
+    aSelectedAnnotations[anEntry] = anIndices;
+  }
+  myTextTree->setSelected(aSelectedAnnotations);
+  mySelectedList.clear();
+}
+
diff --git a/src/GEOMGUI/GEOMGUI_TextTreeSelector.h b/src/GEOMGUI/GEOMGUI_TextTreeSelector.h
new file mode 100644 (file)
index 0000000..7ae8876
--- /dev/null
@@ -0,0 +1,63 @@
+// Copyright (C) 2015-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File   : GEOMGUI_TextTreeSelector.h
+// Author :
+//
+#ifndef GEOMGUI_TEXTTREESELECTOR_H
+#define GEOMGUI_TEXTTREESELECTOR_H
+
+#include "GEOM_GEOMGUI.hxx"
+
+#include <SUIT_Selector.h>
+#include <SUIT_DataOwner.h>
+
+#include <QObject>
+
+class GEOMGUI_TextTreeWdg;
+class GEOMGUI_AnnotationMgr;
+
+class GEOMGUI_EXPORT GEOMGUI_TextTreeSelector : public QObject, public SUIT_Selector
+{
+  Q_OBJECT
+
+public:
+  GEOMGUI_TextTreeSelector( GEOMGUI_TextTreeWdg* theWidget,
+                            GEOMGUI_AnnotationMgr* theAnnotationMgr,
+                            SUIT_SelectionMgr* theManager );
+  virtual ~GEOMGUI_TextTreeSelector();
+
+  GEOMGUI_TextTreeWdg* textTree() const;
+
+  virtual QString type() const;
+
+private slots:
+  void onSelectionChanged();
+
+protected:
+  virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+  virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+  GEOMGUI_TextTreeWdg* myTextTree;
+  GEOMGUI_AnnotationMgr* myAnnotationMgr;
+  SUIT_DataOwnerPtrList mySelectedList;
+};
+
+#endif
old mode 100644 (file)
new mode 100755 (executable)
index 2e3218b..70d7547
@@ -22,6 +22,8 @@
 #include "GEOMGUI_TextTreeWdg.h"
 
 #include "GEOMGUI_DimensionProperty.h"
+#include "GEOMGUI_AnnotationAttrs.h"
+#include "GEOMGUI_AnnotationMgr.h"
 #include "GeometryGUI.h"
 #include "GeometryGUI_Operations.h"
 #include <GEOM_Constants.h>
 #include <QHBoxLayout>
 #include <QHash>
 
+// ----------------------------------------------------------------------------
+// Common style interface for managing dimension and annotation properties
+// ----------------------------------------------------------------------------
+namespace
+{
+  //! Access interface implementation for shape dimension attribute/property.
+  class DimensionsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
+  {
+  public:
+
+    DimensionsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) :
+      myStudy( theStudy ), myEntry( theEntry ) {
+      myAttr.LoadFromAttribute( theStudy, theEntry );
+    }
+    virtual int GetNumber() Standard_OVERRIDE {
+      return myAttr.GetNumber();
+    }
+    virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
+      return myAttr.GetName( theIndex );
+    }
+    virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
+      return myAttr.IsVisible( theIndex );
+    }
+    virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
+      myAttr.SetVisible( theIndex, theIsVisible );
+    }
+    virtual void Save() Standard_OVERRIDE {
+      myAttr.SaveToAttribute( myStudy, myEntry );
+    }
+    GEOMGUI_DimensionProperty& Attr() { return myAttr; }
+
+  private:
+    GEOMGUI_DimensionProperty myAttr;
+    SalomeApp_Study* myStudy;
+    std::string myEntry;
+  };
+
+  //! Access interface implementation for shape annotation attribute.
+  class AnnotationsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
+  {
+  public:
+
+    AnnotationsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) {
+      myEntry = theEntry.c_str();
+      myStudy = theStudy;
+      _PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
+      if ( aSObj ) {
+        myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+      }
+    }
+    virtual int GetNumber() Standard_OVERRIDE {
+      return !myAttr.IsNull() ? myAttr->GetNbAnnotation() : 0;
+    }
+    virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
+      return !myAttr.IsNull() ? myAttr->GetText( theIndex ) : QString();
+    }
+    virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
+      GEOMGUI_AnnotationMgr* aMgr = annotationMgr();
+      if (!aMgr) {
+        return false;
+      }
+      return aMgr->IsDisplayed( myEntry, theIndex );
+    }
+    virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
+      GEOMGUI_AnnotationMgr* aMgr = annotationMgr();
+      if (!aMgr) {
+        return;
+      }
+      if (theIsVisible)
+        annotationMgr()->Display(myEntry, theIndex);
+      else
+        annotationMgr()->Erase(myEntry, theIndex);
+    }
+    virtual void Save() Standard_OVERRIDE {
+      /* every change is automatically saved */
+    }
+    Handle(GEOMGUI_AnnotationAttrs) Attr() { return myAttr; }
+
+protected:
+    GEOMGUI_AnnotationMgr* annotationMgr() const
+    {
+      CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+      GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
+      if (!aModule) {
+        return NULL;
+      }
+      return aModule->GetAnnotationMgr();
+    }
+
+private:
+    QString myEntry;
+    Handle(GEOMGUI_AnnotationAttrs) myAttr;
+    SalomeApp_Study* myStudy;
+  };
+}
+
+// ----------------------------------------------------------------------------
+// Text tree widget implementation
+// ----------------------------------------------------------------------------
+
+//=================================================================================
+// function : Constructor
+// purpose  :
+//=================================================================================
 GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
   : myDisplayer(NULL)
 {
@@ -84,6 +190,12 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
   myDimensionsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
   addTopLevelItem( myDimensionsItem );
 
+  rootNames.clear();
+  rootNames << tr("GEOM_ANNOTATIONS") << "";
+  myAnnotationsItem = new QTreeWidgetItem( this, rootNames );
+  myAnnotationsItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+  addTopLevelItem( myAnnotationsItem );
+
   // get a free dockable window id
   myWindowID = 11;
   while( app->dockWindow( myWindowID ))
@@ -93,18 +205,28 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
   createActions();
   setContextMenuPolicy( Qt::CustomContextMenu );
   connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
-          this, SLOT( showContextMenu(const QPoint&) ) );
+           this, SLOT( showContextMenu(const QPoint&) ) );
 
-  connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ), 
-          this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
   connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
+
   GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
-  connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
-  connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), 
-          this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
+  connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ),
+           this, SLOT( updateDimensionBranch( const QString& ) ) );
+  connect( aGeomGUI, SIGNAL( SignalAnnotationsUpdated( const QString& ) ),
+           this, SLOT( updateAnnotationBranch( const QString& ) ) );
+  connect( aGeomGUI, SIGNAL( SignalTextTreeRenameObject( const QString& ) ),
+           this, SLOT( updateObjectName( const QString& ) ) );
 
+  connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ), 
+           this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
+  connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
+         this, SLOT( onUpdateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
 }
 
+//=================================================================================
+// function : Destructor
+// purpose  :
+//=================================================================================
 GEOMGUI_TextTreeWdg::~GEOMGUI_TextTreeWdg()
 {
   //std::cout<<"~GEOMGUI_TextTreeWdg"<<std::endl;
@@ -127,7 +249,8 @@ void GEOMGUI_TextTreeWdg::createActions()
 
 //=================================================================================
 // function : updateTree
-// purpose  :
+// purpose  : Rebuild branches of objects and remove objects if there are no more annotations
+//            for it
 //=================================================================================
 void GEOMGUI_TextTreeWdg::updateTree()
 {
@@ -138,91 +261,174 @@ void GEOMGUI_TextTreeWdg::updateTree()
     if ( SC ) {
       _PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
       anIter->InitEx( true );
-      QList<QString> objEntries = myObjects.keys();
+      QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
+      QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
       while( anIter->More() ) {
-       _PTR(SObject) valSO ( anIter->Value() );
-       _PTR(SObject) refSO;
-       if ( !valSO->ReferencedObject( refSO ) ) {
-         // update tree of object's dimensions
-         QString anEntry = valSO->GetID().c_str();
-         updateBranch( anEntry );
-         objEntries.removeAll( anEntry );
-       }
-       anIter->Next();
+        _PTR(SObject) valSO ( anIter->Value() );
+        _PTR(SObject) refSO;
+        if ( !valSO->ReferencedObject( refSO ) ) {
+          // update tree of object's dimensions
+          QString anEntry = valSO->GetID().c_str();
+          updateBranches( anEntry );
+          aDimensionObjEntries.removeAll( anEntry );
+          anAnnotationObjEntries.removeAll( anEntry );
+        }
+        anIter->Next();
       }
-      foreach (QString entry, objEntries) {
-       removeBranch( entry, true );
+      foreach ( QString entry, aDimensionObjEntries ) {
+        removeBranch( DimensionShape, entry, true );
+      }
+      foreach ( QString entry, anAnnotationObjEntries ) {
+        removeBranch( AnnotationShape, entry, true );
       }
     }
   }
 }
-  
+
 //=================================================================================
-// function : updateBranch
-// purpose  :
+// function : updateBranches
+// purpose  : Rebuild branches for object of the given entry
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateBranches( const QString& theEntry )
+{
+  updateDimensionBranch( theEntry );
+  updateAnnotationBranch( theEntry );
+}
+
+//=================================================================================
+// function : updateDimensionBranch
+// purpose  : Rebuild branch of dimension type for object of the given entry
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateDimensionBranch( const QString& theEntry )
+{
+  fillBranch( DimensionShape, theEntry );
+}
+
+//=================================================================================
+// function : updateAnnotationBranch
+// purpose  : Rebuild branch of annotation type for object of the given entry
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateAnnotationBranch( const QString& theEntry )
+{
+  fillBranch( AnnotationShape, theEntry );
+}
+
+//=================================================================================
+// function : updateObjectName
+// purpose  : Find name of the given object and set the name for corresponded tree item
 //=================================================================================
-void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
+void GEOMGUI_TextTreeWdg::updateObjectName( const QString& theEntry )
 {
+  QTreeWidgetItem* anObjectItem = 0;
+
+  QHash<QString, QTreeWidgetItem*> anObjects = getObjects( DimensionShape );
+  if ( anObjects.contains( theEntry ) )
+    anObjectItem = anObjects.value( theEntry );
+  else {
+    anObjects = getObjects( AnnotationShape );
+    if ( anObjects.contains( theEntry ) )
+      anObjectItem = anObjects.value( theEntry );
+  }
+  if ( !anObjectItem )
+    return;
+
   myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
   if ( myStudy ) {
+    _PTR(Study) aStudyDS = myStudy->studyDS();
+    if ( aStudyDS ) {
+      _PTR(SObject) anObject( aStudyDS->FindObjectID( theEntry.toStdString() ) );
+      if ( anObject.get() )
+        anObjectItem->setText( 0, anObject->GetName().c_str() );
+    }
+  }
+}
+
+//=================================================================================
+// function : fillBranch
+// purpose  :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
+{
+  myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+
+  if ( myStudy && !theEntry.isEmpty() ) {
+    QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
+    if ( !aProp ) {
+      return;
+    }
+
     _PTR(Study) aStudyDS = myStudy->studyDS();
     if ( aStudyDS ) {
       _PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
-      QString aName = obj->GetName().c_str();
-  
-      GEOMGUI_DimensionProperty aProp;
-      aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
-      int nbProps = aProp.GetNumber();
+      const QString aName = obj->GetName().c_str();
+      const int nbProps = aProp->GetNumber();
 
-      QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
+      QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
       if ( objectItem ) {
-       removeBranch( theEntry, nbProps > 0 ? false : true );
+        removeBranch( theBranchType, theEntry, nbProps > 0 ? false : true );
       }
       QStringList itemName;
       if ( nbProps > 0 ) {
-       itemName << aName << "";
-       if ( !objectItem ) {
-         objectItem = new QTreeWidgetItem( myDimensionsItem, itemName );
-         objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
-         objectItem->setData( 1, Qt::UserRole, theEntry );
-         myDimensionsItem->addChild( objectItem );
-         myObjects.insert( theEntry, objectItem );
-         if ( myDimensionsItem->childCount() == 1 )
-           myDimensionsItem->setExpanded( true );
-       }
-       bool isDisplayed = myDisplayer.IsDisplayed( theEntry );
-       // read dimension records from property
-       for ( int anIt = 0; anIt < aProp.GetNumber(); ++anIt )
-         {
-           QString aName  = aProp.GetName( anIt );
-           bool isVisible = aProp.IsVisible( anIt );
-
-           QTreeWidgetItem* anItem = new QTreeWidgetItem;
-           anItem->setText( 0, aName );
-           //  if ( isDisplayed )
-           anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
-           anItem->setData( 0, Qt::UserRole, anIt );
-           anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
-           objectItem->addChild( anItem ); 
-         }
+        itemName << aName << "";
+        if ( !objectItem ) {
+          QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
+
+          objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
+          objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+          objectItem->setData( 1, Qt::UserRole, theEntry );
+          aPropRootItem->addChild( objectItem );
+          getObjects( theBranchType ).insert( theEntry, objectItem );
+          if ( aPropRootItem->childCount() == 1 )
+            aPropRootItem->setExpanded( true );
+        }
+        for ( int anIt = 0; anIt < nbProps; ++anIt ) {
+          const QString aPropName  = aProp->GetName( anIt );
+          const bool isVisible = aProp->GetIsVisible( anIt );
+          QTreeWidgetItem* anItem = new QTreeWidgetItem;
+          anItem->setText( 0, aPropName );
+          anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
+          anItem->setData( 0, Qt::UserRole, anIt );
+          anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+          objectItem->addChild( anItem );
+        }
       }
     }
   }
 }
 
+//=================================================================================
+// function : getVisualProperty
+// purpose  :
+//=================================================================================
+QSharedPointer<GEOMGUI_TextTreeWdg::VisualProperty>
+  GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType,
+                                          SalomeApp_Study* theStudy,
+                                          const std::string& theEntry )
+{
+  switch ( theBranchType )
+  {
+    case DimensionShape  : return QSharedPointer<VisualProperty>( new DimensionsProperty( theStudy, theEntry ) );
+    case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theStudy, theEntry ) );
+    default: break;
+  }
+  return QSharedPointer<VisualProperty>();
+}
+
 //=================================================================================
 // function : removeBranch
 // purpose  :
 //=================================================================================
-void GEOMGUI_TextTreeWdg::removeBranch( const QString& theEntry, bool force )
+void GEOMGUI_TextTreeWdg::removeBranch( const BranchType& theBranchType, const QString& theEntry,
+                                        bool force )
 {
-  QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
+  QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
   if ( !objectItem )
     return;
   qDeleteAll( objectItem->takeChildren() );
   if ( force ) {
-    myDimensionsItem->removeChild( objectItem );
-    myObjects.remove( theEntry );
+    QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
+    aPropRootItem->removeChild( objectItem );
+    getObjects( theBranchType ).remove( theEntry );
   }
 }
 
@@ -236,17 +442,22 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
     return;
   
   std::string anEntry = entryFromItem( theItem->parent() ).toStdString();
+  BranchType aBranchType = branchTypeFromItem( theItem );
+
   int aDimIndex = idFromItem( theItem );
-  GEOMGUI_DimensionProperty aProp;
-  aProp.LoadFromAttribute( myStudy, anEntry );
-  if ( aProp.IsVisible( aDimIndex ) ) {
-    aProp.SetVisible( aDimIndex, false );
+
+  QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
+
+  CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+  GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
+  if ( aProp->GetIsVisible( aDimIndex ) ) {
+    aModule->GetAnnotationMgr()->Erase(anEntry.c_str(), aDimIndex);
     theItem->setIcon( 1, myInvisibleIcon );
   } else {
-    aProp.SetVisible( aDimIndex, true );
+    aModule->GetAnnotationMgr()->Display(anEntry.c_str(), aDimIndex);
+
     theItem->setIcon( 1, myVisibleIcon );
   }
-  aProp.SaveToAttribute( myStudy, anEntry );
   redisplay( anEntry.c_str() );
 }
 
@@ -269,7 +480,7 @@ int GEOMGUI_TextTreeWdg::idFromItem( QTreeWidgetItem* theItem )
 // function : entryFromItem
 // purpose  :
 //=================================================================================
-QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
+QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem ) const
 {
   if ( !theShapeItem )
     return "";
@@ -281,33 +492,49 @@ QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
 // function : itemFromEntry
 // purpose  :
 //=================================================================================
-QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( QString theEntry )
+QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranchType, QString theEntry )
 {
   if ( theEntry.isEmpty() )
     return 0;
 
-  return myObjects.value( theEntry, 0 );
+  return getObjects(theBranchType).value( theEntry, 0 );
+}
+
+//=================================================================================
+// function : onUpdateVisibilityColumn
+// purpose  : Update visible state of icons of entry items.
+//=================================================================================
+void GEOMGUI_TextTreeWdg::onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
+{
+  // dimension property branch
+  updateVisibilityColumn( DimensionShape, theEntry, theState );
+
+  // annotation property branch
+  updateVisibilityColumn( AnnotationShape, theEntry, theState );
 }
 
 //=================================================================================
 // function : updateVisibilityColumn
 // purpose  : Update icons of dimension items.
 //=================================================================================
-void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
+void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchType, QString theEntry,
+                                                  Qtx::VisibilityState theState )
 {
-  QTreeWidgetItem* anItem = itemFromEntry( theEntry );
+  QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
   if ( !anItem )
     return;
   anItem->setDisabled( theState != Qtx::ShownState );
   QTreeWidgetItem* aChildItem;
-  GEOMGUI_DimensionProperty aProp;
+
+  QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
+
   for ( int i=0; i < anItem->childCount(); i++ ) {
     aChildItem = anItem->child( i );
     if ( theState == Qtx::ShownState ) {
-      aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
-      if ( aProp.GetNumber() == 0 )
-       continue;
-      aChildItem->setIcon( 1, aProp.IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon : myInvisibleIcon );
+      if ( aProp->GetNumber() == 0 )
+        continue;
+      aChildItem->setIcon( 1, aProp->GetIsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
+                                                                              : myInvisibleIcon );
       aChildItem->setDisabled( false );
     } else {
       aChildItem->setIcon( 1, QIcon() );
@@ -322,95 +549,278 @@ void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::Visibil
 //=================================================================================
 void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
 {
-  if ( selectedItems().isEmpty() )
-    return;
+  CAM_Application* anApp = dynamic_cast<CAM_Application*>(myStudy->application());
+  GeometryGUI* aModule = dynamic_cast<GeometryGUI*>(anApp->activeModule());
+
   QMenu aMenu;
-  aMenu.addAction( myActions[GEOMOp::OpShow] );
-  aMenu.addAction( myActions[GEOMOp::OpHide] );
-  if ( selectedItems().count() == 1 ) {
+  if ( !selectedItems().isEmpty() && selectedItems().count() == 1 ) {
     QTreeWidgetItem* anItem = selectedItems().first();
     QString anEntry = entryFromItem( anItem->parent() );
     if ( !anEntry.isEmpty() ) {
-      GEOMGUI_DimensionProperty aProp;
-      aProp.LoadFromAttribute( myStudy, anEntry.toStdString() );
-      if ( aProp.GetNumber() == 0 )
-       return;
-      aMenu.clear();
-      if ( aProp.IsVisible( idFromItem( anItem ) ) )
-       aMenu.addAction( myActions[GEOMOp::OpHide] );
+      BranchType aBranchType = branchTypeFromItem( anItem );
+      QSharedPointer<VisualProperty>
+        aProp = getVisualProperty( aBranchType, myStudy, anEntry.toStdString() );
+
+      if ( aProp->GetNumber() == 0 )
+        return;
+      // Edit annotation action
+      QAction* anEditAction = aModule->action(GEOMOp::OpEditAnnotation);
+      if ( anEditAction )
+        aMenu.addAction( anEditAction );
+      QAction* aDeleteAction = aModule->action(GEOMOp::OpDeleteAnnotation);
+      if ( aDeleteAction )
+        aMenu.addAction( aDeleteAction );
+      // Show/Hide actions
+      if ( aProp->GetIsVisible( idFromItem( anItem ) ) )
+        aMenu.addAction( myActions[GEOMOp::OpHide] );
       else
-       aMenu.addAction( myActions[GEOMOp::OpShow] );
+        aMenu.addAction( myActions[GEOMOp::OpShow] );
+    }
+  }
+
+  if (selectedItems().isEmpty() && currentItem()) {
+    QTreeWidgetItem* anItem = currentItem();
+    bool aShowAll = false;
+    if (anItem == getPropertyRootItem(AnnotationShape))
+      aShowAll = true;
+    else {
+      QHash<QString, QTreeWidgetItem*> anObjects = getObjects( AnnotationShape );
+      QHash<QString, QTreeWidgetItem*>::const_iterator anIt = anObjects.begin(),
+                                                       aLast = anObjects.end();
+      for (; anIt != aLast && !aShowAll; anIt++) {
+        aShowAll = anIt.value() == anItem;
+      }
+    }
+    if (aShowAll) {
+      aMenu.addAction( aModule->action(GEOMOp::OpShowAllAnnotations) );
+      aMenu.addAction( aModule->action(GEOMOp::OpHideAllAnnotations) );
     }
   }
   QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
-  if ( selPopupItem == myActions[GEOMOp::OpShow] )
-    setVisibility( true );
-  else if ( selPopupItem == myActions[GEOMOp::OpHide] )
-    setVisibility( false );
+
+  if ( selPopupItem == myActions[GEOMOp::OpShow] ||
+       selPopupItem == myActions[GEOMOp::OpHide] ) {
+    bool isVisible = selPopupItem == myActions[GEOMOp::OpShow];
+    foreach ( QTreeWidgetItem* anItem, selectedItems() ) {
+      setVisibility( anItem, isVisible );
+    }
+  }
 }
 
 //=================================================================================
 // function : setVisibility
-// purpose  : 
+// purpose  : set item visible
 //=================================================================================
-void GEOMGUI_TextTreeWdg::setVisibility( bool theVisibility )
+void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisibility )
 {
-  if ( myDimensionsItem->isSelected() ) {
-    // set visibility for all dimensions
+  BranchType aBranchType = branchTypeFromItem( theItem );
+  if ( theItem == myDimensionsItem ||
+       theItem == myAnnotationsItem ) {
+
     QTreeWidgetItem* anItem;
-    foreach ( QString entry, myObjects.keys() ) {
-      anItem = itemFromEntry( entry );
+    foreach ( QString entry, getObjects( aBranchType ).keys() ) {
+      anItem = itemFromEntry( aBranchType, entry );
       if ( !anItem->isDisabled() )
-       setShapeDimensionsVisibility( entry, theVisibility );
+        setAllShapeItemsVisibility( aBranchType, entry, theVisibility );
     }
     return;
   }
-  foreach ( QTreeWidgetItem* item, selectedItems() ) {
-    if ( item->isDisabled() || item->parent()->isSelected() )
-      continue;
-    QString anEntry = entryFromItem( item );
-    if ( !anEntry.isEmpty() ) {
-      // it is a shape item
-      setShapeDimensionsVisibility( anEntry, theVisibility );
-    } else {
-      // it is a dimension item
-      anEntry = entryFromItem( item->parent() );
-      setDimensionVisibility( anEntry, item, theVisibility );
+  else {
+    if ( !theItem->isDisabled() && !theItem->parent()->isSelected() ) {
+      QString anEntry = entryFromItem( theItem );
+      if ( !anEntry.isEmpty() ) {
+        // it is a shape item
+        setAllShapeItemsVisibility( aBranchType, anEntry, theVisibility );
+      } else {
+        // it is a dimension item
+        anEntry = entryFromItem( theItem->parent() );
+        setShapeItemVisibility( aBranchType, anEntry, theItem, theVisibility );
+      }
     }
   }
 }
 
 //=================================================================================
-// function : setShapeDimensionsVisibility
+// function : setAllShapeItemsVisibility
 // purpose  : 
 //=================================================================================
-void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( QString theEntry, bool theVisibility )
+void GEOMGUI_TextTreeWdg::setAllShapeItemsVisibility( const BranchType& theBranchType,
+                                                      const QString& theEntry,
+                                                      const bool theVisibility )
 {
-  QTreeWidgetItem* anItem = itemFromEntry( theEntry );
+  QSharedPointer<VisualProperty>
+    aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
+
+  QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
   QTreeWidgetItem* aChildItem;
   for ( int i=0; i < anItem->childCount(); i++ ) {
     aChildItem = anItem->child( i );
-    setDimensionVisibility( theEntry, aChildItem, theVisibility );
+    setShapeItemVisibility( aProp, aChildItem, theVisibility );
   }
+
+  aProp->Save();
+
   redisplay( theEntry );
 }
 
 //=================================================================================
-// function : setDimensionVisibility
+// function : setShapeItemVisibility
 // purpose  : 
 //=================================================================================
-void GEOMGUI_TextTreeWdg::setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility )
+void GEOMGUI_TextTreeWdg::setShapeItemVisibility( const BranchType& theBranchType,
+                                                  const QString& theEntry,
+                                                  QTreeWidgetItem* theWidgetItem,
+                                                  const bool theVisibility )
 {
-  GEOMGUI_DimensionProperty aProp;
-  aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
-  int aDimIndex = idFromItem( theDimItem );
-  if ( aProp.GetNumber() == 0  || aProp.IsVisible( aDimIndex ) == theVisibility )
-    return;;
-  aProp.SetVisible( aDimIndex, theVisibility );
-  aProp.SaveToAttribute( myStudy, theEntry.toStdString() );
+  QSharedPointer<VisualProperty>
+    aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
 
-  theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
-  redisplay( theEntry );
+  if ( setShapeItemVisibility( aProp, theWidgetItem, theVisibility ) ) {
+    aProp->Save();
+    redisplay( theEntry );
+  }
+}
+
+//=================================================================================
+// function : setShapeItemVisibility
+// purpose  : 
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateVisibility()
+{
+  //QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
+  BranchType aBranchType = AnnotationShape;
+
+  QList<QString> anAnnotationObjEntries = getObjects( aBranchType ).keys();
+
+  QTreeWidgetItem* anEntryItem;
+  foreach ( QString anEntry, getObjects( aBranchType ).keys() )
+  {
+    anEntryItem = itemFromEntry( aBranchType, anEntry );
+
+    QTreeWidgetItem* anItem;
+    for ( int i = 0; i < anEntryItem->childCount(); i++ ) {
+      anItem = anEntryItem->child( i );
+      int aDimIndex = idFromItem( anItem );
+      QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy,
+                                                                anEntry.toStdString() );
+      bool isItemVisible = aProp->GetIsVisible( aDimIndex );
+      anItem->setIcon( 1, isItemVisible ? myVisibleIcon : myInvisibleIcon );
+    }
+
+    redisplay( anEntry );
+  }
+}
+
+//=================================================================================
+// function : getSelected
+// purpose  :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::getSelected( QMap<QString, QList<int> >& theAnnotations )
+{
+  theAnnotations.clear();
+
+  QItemSelectionModel* aSelectionModel = selectionModel();
+  QModelIndexList aSelectedIndices = aSelectionModel->selectedIndexes();
+
+  for (int i = 0, aNbItems = aSelectedIndices.size(); i < aNbItems; i++) {
+    QTreeWidgetItem* anItem = itemFromIndex( aSelectedIndices[i] );
+    if ( !anItem )
+      continue;
+    QString anEntry = entryFromItem( anItem->parent() );
+    int aDimIndex = idFromItem( anItem );
+    if ( aDimIndex < 0 )
+      continue;
+
+    if ( theAnnotations.contains( anEntry ) )
+      theAnnotations[anEntry].append( aDimIndex );
+    else {
+      QList<int> anIndices;
+      anIndices.append( aDimIndex );
+      theAnnotations[anEntry] = anIndices;
+    }
+  }
+}
+
+//=================================================================================
+// function : setSelected
+// purpose  :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::setSelected( const QMap<QString, QList<int> >& theAnnotations )
+{
+  QItemSelectionModel* aSelectionModel = selectionModel();
+  aSelectionModel->clearSelection();
+
+  QMap<QString, QList<int> >::const_iterator anIt = theAnnotations.begin(),
+                                             aLast = theAnnotations.end();
+  BranchType aBranchType = AnnotationShape;
+  for ( ; anIt != aLast; anIt++ ) {
+    QString anEntry = anIt.key();
+    QTreeWidgetItem* anEntryItem = itemFromEntry( aBranchType, anEntry );
+    if ( !anEntryItem )
+      continue;
+
+    QList<int> anAnnotationIds = anIt.value();
+    QTreeWidgetItem* anItem;
+    for ( int i = 0; i < anEntryItem->childCount(); i++ ) {
+      anItem = anEntryItem->child( i );
+      int aDimIndex = idFromItem( anItem );
+      if ( anAnnotationIds.contains( aDimIndex ) ) {
+        QModelIndex anIndex = indexFromItem( anItem );
+        aSelectionModel->select( anIndex, QItemSelectionModel::Select );
+      }
+    }
+  }
+}
+
+//=================================================================================
+// function : getAllEntries
+// purpose  :
+//=================================================================================
+QList<QString> GEOMGUI_TextTreeWdg::getAllEntries( const BranchType& theBranchType )
+{
+  return getObjects( theBranchType ).keys();
+}
+
+//=================================================================================
+// function : getSingleSelectedObject
+// purpose  :
+//=================================================================================
+QString GEOMGUI_TextTreeWdg::getSingleSelectedObject()
+{
+  QString anEntry;
+  QTreeWidgetItem* anItem = currentItem();
+  if (anItem) {
+    QHash<QString, QTreeWidgetItem*> anObjects = getObjects( AnnotationShape );
+    QHash<QString, QTreeWidgetItem*>::const_iterator anIt = anObjects.begin(),
+                                                     aLast = anObjects.end();
+    for (; anIt != aLast; anIt++) {
+      if ( anIt.value() == anItem ) {
+        anEntry = anIt.key();
+        break;
+      }
+    }
+  }
+  return anEntry;
+}
+
+//=================================================================================
+// function : setShapeItemVisibility
+// purpose  :
+//=================================================================================
+bool GEOMGUI_TextTreeWdg::setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
+                                                  QTreeWidgetItem* theWidgetItem,
+                                                  const bool theVisibility )
+{
+  int aDimIndex = idFromItem( theWidgetItem );
+  if ( theProps->GetNumber() == 0 
+    || theProps->GetIsVisible( aDimIndex ) == theVisibility ) {
+    return false;
+  }
+  theProps->SetIsVisible( aDimIndex, theVisibility );
+
+  theWidgetItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
+
+  return true;
 }
 
 //=================================================================================
@@ -422,3 +832,45 @@ void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
   Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toLatin1().constData(), "GEOM", "TEMP_IO" );
   myDisplayer.Redisplay( io );
 }
+
+//=================================================================================
+// function : getPropertyRootItem
+// purpose  :
+//=================================================================================
+QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType )
+{
+  return (theBranchType == DimensionShape) ? myDimensionsItem : myAnnotationsItem;
+}
+
+//=================================================================================
+// function : getObjects
+// purpose  :
+//=================================================================================
+QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType )
+{
+  return (theBranchType == DimensionShape) ? myDimensionObjects : myAnnotationObjects;
+}
+
+//=================================================================================
+// function : branchTypeFromItem
+// purpose  :
+//=================================================================================
+GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem )
+{
+  BranchType aBranchType = DimensionShape;
+
+  bool aBranchTypeFound = false;
+  QTreeWidgetItem* anItem = theItem;
+  while( !aBranchTypeFound && anItem ) {
+    if ( anItem == myDimensionsItem ||
+         anItem == myAnnotationsItem) {
+      aBranchTypeFound = true;
+      aBranchType = (anItem == myDimensionsItem) ? DimensionShape : AnnotationShape;
+    }
+    else {
+      anItem = anItem->parent();
+    }
+  }
+
+  return aBranchType;
+}
index 4f6677c88047b0fefdf6ab3057a620fd52b23123..abce0083f1165a2d1e8eedd38ae18906692f57d8 100644 (file)
 #include "GEOM_GEOMGUI.hxx"
 #include "GEOM_Displayer.h"
 
-#include <QTreeWidget>
 #include <QHash>
+#include <QMap>
+#include <QList>
+#include <QSharedPointer>
+#include <QTreeWidget>
 
 #include <SALOMEDSClient.hxx>
 
@@ -44,46 +47,97 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
 {
   Q_OBJECT
 
- public:
+public:
+  enum BranchType { DimensionShape, AnnotationShape };
+
+public:
   GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
   ~GEOMGUI_TextTreeWdg();
 
   int getWinID() { return myWindowID; }
 
-  void                          removeBranch( const QString& theEntry, 
-                                             bool force = true );
+  void                          removeBranch( const BranchType& theBranchType, const QString& theEntry,
+                                              bool force = true );
   int                           idFromItem( QTreeWidgetItem* theItem );
-  QString                       entryFromItem( QTreeWidgetItem* theShapeItem );
-  QTreeWidgetItem*              itemFromEntry( QString theEntry );
-  void                          setShapeDimensionsVisibility( QString theEntry, bool theVisibility );
-  void                          setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility );
+  QString                       entryFromItem( QTreeWidgetItem* theShapeItem ) const;
+  QTreeWidgetItem*              itemFromEntry( const BranchType& theBranchType, QString theEntry );
+  void                          setAllShapeItemsVisibility( const BranchType& theBranchType,
+                                                            const QString& theEntry,
+                                                            const bool theVisibility );
+  void                          setShapeItemVisibility( const BranchType& theBranchType,
+                                                        const QString& theEntry,
+                                                        QTreeWidgetItem* theWidgetItem,
+                                                        const bool theVisibility );
+  void                          updateVisibility();
+
+  void                          getSelected( QMap<QString, QList<int> >& theAnnotations );
+  void                          setSelected( const QMap<QString, QList<int> >& theAnnotations );
+
+  QList<QString>                getAllEntries( const BranchType& theBranchType );
+
+  QString                       getSingleSelectedObject();
 
 protected:
   void                          createActions();
   void                          redisplay( QString theEntry );
 
- public slots:
+public slots:
   void                          updateTree();
-  void                          updateBranch( const QString& theEntry );
+  void                          updateBranches( const QString& theEntry );
+  void                          updateDimensionBranch( const QString& theEntry );
+  void                          updateAnnotationBranch( const QString& theEntry );
+  void                          updateObjectName( const QString& theEntry );
 
 private slots:
+  void                          onUpdateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
   void                          onItemClicked(QTreeWidgetItem*, int );
-  void                          updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
-  void                          setVisibility( bool visibility );
+  void                          setVisibility( QTreeWidgetItem* theItem, bool visibility );
   void                          showContextMenu( const QPoint& pos );
 
- private:
-
-  int                           myWindowID;
-
-  QIcon                         myVisibleIcon;
-  QIcon                         myInvisibleIcon;
-  QHash<QString, QTreeWidgetItem*> myObjects;
-  SalomeApp_Study*              myStudy;
-  QTreeWidgetItem*              myDimensionsItem;
-  GEOM_Displayer                myDisplayer;
-
-  QMap<int, QAction*>           myActions;   //!< menu actions list
-
+public:
+
+  /*!
+   * \brief Common interface for working with shape dimension and annotation properties
+   *        of object in a unified way irrespectively of the implementation.
+   */ 
+  class VisualProperty
+  {
+  public:
+    virtual int GetNumber() = 0;
+    virtual QString GetName( const int theIndex ) = 0;
+    virtual bool GetIsVisible( const int theIndex ) = 0;
+    virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) = 0;
+    virtual void Save() = 0;
+  };
+
+private:
+  bool                              setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
+                                                            QTreeWidgetItem* theWidgetItem,
+                                                            const bool theVisibility );
+  QSharedPointer<VisualProperty>    getVisualProperty( const BranchType& theBranchType,
+                                                       SalomeApp_Study* theStudy,
+                                                       const std::string& theEntry );
+  void                              fillBranch( const BranchType& theBranchType,
+                                                const QString& theEntry );
+  void                              updateVisibilityColumn( const BranchType& theBranchType,
+                                                            QString theEntry,
+                                                            Qtx::VisibilityState theState );
+  QTreeWidgetItem*                  getPropertyRootItem( const BranchType& theBranchType );
+  QHash<QString, QTreeWidgetItem*>& getObjects( const BranchType& theBranchType );
+  BranchType                        branchTypeFromItem( QTreeWidgetItem* theItem );
+
+private:
+
+  int                              myWindowID;
+  QIcon                            myVisibleIcon;
+  QIcon                            myInvisibleIcon;
+  QHash<QString, QTreeWidgetItem*> myDimensionObjects;
+  QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
+  SalomeApp_Study*                 myStudy;
+  QTreeWidgetItem*                 myDimensionsItem;
+  QTreeWidgetItem*                 myAnnotationsItem;
+  GEOM_Displayer                   myDisplayer;
+  QMap<int, QAction*>              myActions; //!< menu actions list
 };
+
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 3ed44e1..be8d25b
@@ -25,7 +25,6 @@
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 
 #include "GEOM_Displayer.h"
-#include "GEOMGUI_DimensionProperty.h"
 #include "GeometryGUI.h"
 
 #include <GEOM_Constants.h>
 
 #include <GEOM_Actor.h>
 #include <GEOM_AISDimension.hxx>
+#include <GEOM_Annotation.hxx>
 #include <GEOM_TopWireframeShape.hxx>
 #include <GEOM_AISVector.hxx>
 #include <GEOM_AISTrihedron.hxx>
 #include <GEOM_VTKTrihedron.hxx>
 #include <GEOM_VTKPropertyMaterial.hxx>
 
+#include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOMGUI_AnnotationMgr.h>
+
 #include <GEOMUtils.hxx>
 
 #include <Material_Model.h>
@@ -167,7 +171,7 @@ namespace
     if ( aPixmap.IsNull() ) {
       QPixmap px(":images/default_texture.png");
       if ( !px.isNull() )
-       aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
+        aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage() );
     }
     return aPixmap;
   }
@@ -460,6 +464,7 @@ static std::string getName( GEOM::GEOM_BaseObject_ptr object )
  */
 //=================================================================
 GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
+  : myUpdateColorScale(true), myIsRedisplayed( false )
 {
   if( st )
     myApp = dynamic_cast<SalomeApp_Application*>( st->application() );
@@ -496,21 +501,22 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
   // This parameter is used for activisation/deactivisation (selection) of objects to be displayed
   myToActivate = true;
 
-  // Activate parallel vizualisation only for testing purpose
-  // and if the corresponding env variable is set to 1
-  char* parallel_visu = getenv("PARALLEL_VISU");
-  if (parallel_visu && atoi(parallel_visu))
-  {
-    MESSAGE("Parallel visualisation on");
-    BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
-  }
+  // Activate parallel vizualisation by default.
+  // It can be switched OFF via the environment variable:
+  //     export PARALLEL_VISU=0
+  Standard_Boolean parallel_visu = Standard_True;
+  char* parallel_visu_env = getenv("PARALLEL_VISU");
+  if (parallel_visu_env && atoi(parallel_visu_env) == 0)
+    parallel_visu = Standard_False;
+  BRepMesh_IncrementalMesh::SetParallelDefault(parallel_visu);
 
   myViewFrame = 0;
 
 #if OCC_VERSION_MAJOR >= 7
   myColorScale = new AIS_ColorScale;
   myColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD);
-  myColorScale->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
+  myColorScale->SetTransformPersistence (
+    Graphic3d_TransformPers::FromDeprecatedParams(Graphic3d_TMF_2d, gp_Pnt (-1,-1,0)));
 #endif
 
   myFieldDataType = GEOM::FDT_Double;
@@ -636,6 +642,8 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
                                 const bool updateViewer,
                                 const bool checkActiveViewer )
 {
+  bool aRedisplayed = myIsRedisplayed;
+  myIsRedisplayed = true;
   // Remove the object permanently (<forced> == true)
   SUIT_Session* ses = SUIT_Session::session();
   SUIT_Application* app = ses->activeApplication();
@@ -665,6 +673,7 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
       }
     }
   }
+  myIsRedisplayed = aRedisplayed;
 }
 
 //=================================================================
@@ -684,8 +693,23 @@ void GEOM_Displayer::Redisplay( const Handle(SALOME_InteractiveObject)& theIO,
     return;
   }
 
+  bool aRedisplayed = myIsRedisplayed;
+  myIsRedisplayed = true;
   Erase( theIO, true, false, theViewFrame );
   Display( theIO, theUpdateViewer, theViewFrame );
+  myIsRedisplayed = aRedisplayed;
+  // hide annotations for erased presentation
+  SUIT_Session* session = SUIT_Session::session();
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
+  GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
+  if ( aModule ) {
+    if ( !theViewFrame->isVisible( theIO ) ) {
+      aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast<SOCC_Viewer*>( theViewFrame ));
+    }
+    else {
+      aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast<SOCC_Viewer*>( theViewFrame ));
+    }
+  }
 }
 
 //=================================================================
@@ -714,7 +738,7 @@ void GEOM_Displayer::UpdateVisibility( SALOME_View* v, const SALOME_Prs* p, bool
     QString entry = p->GetEntry();
     if ( !entry.isEmpty() ) {
       if ( vId != -1 )
-       aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on );
+        aStudy->setObjectProperty( vId, entry, GEOM::propertyName( GEOM::Visibility ), on );
       setVisibilityState( entry, on ? Qtx::ShownState : Qtx::HiddenState );
     }
   }
@@ -990,9 +1014,9 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
       if ( !aTexture.IsNull() ) {
         Handle(Prs3d_PointAspect) aTextureAspect =
           new Prs3d_PointAspect( HasColor() ? 
-                                // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
-                                (Quantity_NameOfColor)GetColor() : 
-                                // color from properties 
+                                 // predefined color, manually set to displayer via GEOM_Displayer::SetColor() function
+                                 (Quantity_NameOfColor)GetColor() : 
+                                 // color from properties 
                                  SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::PointColor ) ).value<QColor>() ),
                                  aWidth, aHeight,
                                  aTexture );
@@ -2044,7 +2068,7 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
     if ( !ic.IsNull() )
     {
       if ( ic->HasOpenedContext() )
-      ic->CloseAllContexts();
+      ic->CloseAllContexts(Standard_True);
     }
   }
 }
@@ -2052,6 +2076,18 @@ void GEOM_Displayer::BeforeDisplay( SALOME_View* v, const SALOME_OCCPrs* )
 void GEOM_Displayer::AfterDisplay( SALOME_View* v, const SALOME_OCCPrs* p )
 {
   UpdateColorScale(false,false);
+
+  // visualize annotations for displayed presentation
+  SUIT_Session* session = SUIT_Session::session();
+  SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
+  GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
+  if ( aModule ) {
+    if ( !myIsRedisplayed ) {
+      aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
+    } else {
+      aModule->GetAnnotationMgr()->UpdateVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
+    }
+  }
 }
 
 void GEOM_Displayer::BeforeErase( SALOME_View* v, const SALOME_OCCPrs* p )
@@ -2064,6 +2100,15 @@ void GEOM_Displayer::AfterErase( SALOME_View* v, const SALOME_OCCPrs* p )
 {
   LightApp_Displayer::AfterErase( v, p );
   UpdateColorScale(false,false);
+
+  if ( !myIsRedisplayed ) {
+    // hide annotations for erased presentation
+    SUIT_Session* session = SUIT_Session::session();
+    SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
+    GeometryGUI* aModule = dynamic_cast<GeometryGUI*>( anApp->activeModule() );
+    if ( aModule )
+      aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), dynamic_cast<SOCC_Viewer*>( v ));
+  }
 }
 
 //=================================================================
@@ -2561,7 +2606,7 @@ PropMap GEOM_Displayer::getDefaultPropertyMap()
 
   // - transparency (opacity = 1-transparency)
   propMap.insert( GEOM::propertyName( GEOM::Transparency ),
-                 resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. );
+                  resMgr->integerValue( "Geometry", "transparency", 0 ) / 100. );
 
   // - display mode (take default value from preferences)
   propMap.insert( GEOM::propertyName( GEOM::DisplayMode ),
@@ -3001,43 +3046,41 @@ void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, cons
   Standard_Real aColorScaleMin = 0, aColorScaleMax = 0;
   Standard_Boolean anIsBoolean = Standard_False;
 
-  SALOME_ListIO aSelectedObjects;
-  myApp->selectionMgr()->selectedObjects( aSelectedObjects );
-  if( aSelectedObjects.Extent() == 1 )
+  Handle(SALOME_InteractiveObject) anIO;
+  if ( myUpdateColorScale )
+    anIO = myApp->selectionMgr()->soleSelectedObject();
+
+  if( !anIO.IsNull() )
   {
-    Handle(SALOME_InteractiveObject) anIO = aSelectedObjects.First();
-    if( !anIO.IsNull() )
+    SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
+    if( aPrs )
     {
-      SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( aViewModel->CreatePrs( anIO->getEntry() ) );
-      if( aPrs )
+      AIS_ListOfInteractive aList;
+      aPrs->GetObjects( aList );
+      AIS_ListIteratorOfListOfInteractive anIter( aList );
+      for( ; anIter.More(); anIter.Next() )
       {
-        AIS_ListOfInteractive aList;
-        aPrs->GetObjects( aList );
-        AIS_ListIteratorOfListOfInteractive anIter( aList );
-        for( ; anIter.More(); anIter.Next() )
+        Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
+        if( !aShape.IsNull() )
         {
-          Handle(GEOM_AISShape) aShape = Handle(GEOM_AISShape)::DownCast( anIter.Value() );
-          if( !aShape.IsNull() )
+          GEOM::field_data_type aFieldDataType;
+          int aFieldDimension;
+          QList<QVariant> aFieldStepData;
+          TCollection_AsciiString aFieldStepName;
+          double aFieldStepRangeMin, aFieldStepRangeMax;
+          aShape->getFieldStepInfo( aFieldDataType,
+                                    aFieldDimension,
+                                    aFieldStepData,
+                                    aFieldStepName,
+                                    aFieldStepRangeMin,
+                                    aFieldStepRangeMax );
+          if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
           {
-            GEOM::field_data_type aFieldDataType;
-            int aFieldDimension;
-            QList<QVariant> aFieldStepData;
-            TCollection_AsciiString aFieldStepName;
-            double aFieldStepRangeMin, aFieldStepRangeMax;
-            aShape->getFieldStepInfo( aFieldDataType,
-                                      aFieldDimension,
-                                      aFieldStepData,
-                                      aFieldStepName,
-                                      aFieldStepRangeMin,
-                                      aFieldStepRangeMax );
-            if( !aFieldStepData.isEmpty() && aFieldDataType != GEOM::FDT_String )
-            {
-              anIsDisplayColorScale = Standard_True;
-              aColorScaleTitle = aFieldStepName;
-              aColorScaleMin = aFieldStepRangeMin;
-              aColorScaleMax = aFieldStepRangeMax;
-              anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
-            }
+            anIsDisplayColorScale = Standard_True;
+            aColorScaleTitle = aFieldStepName;
+            aColorScaleMin = aFieldStepRangeMin;
+            aColorScaleMax = aFieldStepRangeMax;
+            anIsBoolean = aFieldDataType == GEOM::FDT_Bool;
           }
         }
       }
@@ -3083,11 +3126,11 @@ void GEOM_Displayer::UpdateColorScale( const bool theIsRedisplayFieldSteps, cons
       aView->ColorScaleErase();
 #else
     if( !aViewModel->getAISContext()->IsDisplayed( myColorScale ) )
-      aViewModel->getAISContext()->Display( myColorScale );
+      aViewModel->getAISContext()->Display( myColorScale, Standard_True);
   }
   else
     if( aViewModel->getAISContext()->IsDisplayed( myColorScale ) )
-      aViewModel->getAISContext()->Erase( myColorScale );
+      aViewModel->getAISContext()->Erase( myColorScale, Standard_True );
 #endif
 
   if( theIsRedisplayFieldSteps )
old mode 100644 (file)
new mode 100755 (executable)
index cf5a9df..50b6c17
@@ -230,6 +230,7 @@ public:
 
   /* Update visibility and parameters of the currently selected field step's color scale */
   void UpdateColorScale( const bool theIsRedisplayFieldSteps = false, const bool updateViewer = true );
+  void SetUpdateColorScale(bool toUpdate) { myUpdateColorScale = toUpdate; } // IPAL54049
 
 protected:
   /* internal methods */
@@ -263,6 +264,7 @@ protected:
   void           updateShapeProperties( const Handle(GEOM_AISShape)&, bool );
   void           updateActorProperties( GEOM_Actor*, bool );
   void           updateDimensions( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
+  void           updateShapeAnnotations( const Handle(SALOME_InteractiveObject)&, SALOME_OCCPrs*, const gp_Ax3& );
 
   PropMap getObjectProperties( SalomeApp_Study*, const QString&, SALOME_View* = 0 );
   PropMap getDefaultPropertyMap();
@@ -303,6 +305,7 @@ protected:
 #if OCC_VERSION_MAJOR >= 7
   Handle(AIS_ColorScale)           myColorScale;
 #endif
+  int                              myUpdateColorScale; // IPAL54049
 
   // Attributes
   Quantity_Color                   myShadingColor;
@@ -317,6 +320,7 @@ protected:
   Aspect_TypeOfMarker              myTypeOfMarker;
   double                           myScaleOfMarker;
   double                           myTransparency;
+  bool                             myIsRedisplayed;
 
 private:
   SalomeApp_Application* myApp;
index aeaedb609bd94f05a2489509fcb8611f83569641..4b1c19571d8d41262e7088c7fb5cee0736c59704 100644 (file)
             <source>ICO_MANAGE_DIMENSIONS</source>
             <translation>managedimensions.png</translation>
         </message>
+        <message>
+            <source>ICO_ANNOTATION</source>
+            <translation>annotation.png</translation>
+        </message>
         <message>
             <source>ICO_POINT</source>
             <translation>point2.png</translation>
old mode 100644 (file)
new mode 100755 (executable)
index 7591ab0..22fc71a
@@ -575,6 +575,10 @@ Please, select face, shell or solid and try again</translation>
         <source>GEOM_DIMENSIONS</source>
         <translation>Dimensions</translation>
     </message>
+    <message>
+        <source>GEOM_ANNOTATIONS</source>
+        <translation>Annotations</translation>
+    </message>
     <message>
         <source>GEOM_SKETCHER_DIST</source>
         <translation>Distance</translation>
@@ -3500,6 +3504,50 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_DIMENSIONS_USE_TEXT3D</source>
         <translation>Use 3D text</translation>
     </message>
+    <message>
+         <source>PREF_SHAPE_ANNOTATIONS</source>
+         <translation>Shape annotations</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_FONT</source>
+        <translation>Font</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_FONT_COLOR</source>
+        <translation>Font color</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINE_COLOR</source>
+        <translation>Line color</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINE_WIDTH</source>
+        <translation>Line width</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINE_STYLE</source>
+        <translation>Line style</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_AUTOHIDE</source>
+        <translation>Hide when attachment is invisible</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID</source>
+        <translation>Solid</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH</source>
+        <translation>Dashed</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT</source>
+        <translation>Dotted</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH</source>
+        <translation>Mixed</translation>
+    </message>
     <message>
         <source>PREF_HIDE_INPUT_OBJECT</source>
         <translation>Hide input objects from the viewer</translation>
@@ -4956,6 +5004,42 @@ Please, select face, shell or solid and try again</translation>
         <source>STB_MANAGE_DIMENSIONS</source>
         <translation>Manage measurement dimensions of an object</translation>
     </message>
+    <message>
+        <source>TOP_ANNOTATION</source>
+        <translation>Annotation</translation>
+    </message>
+    <message>
+        <source>MEN_ANNOTATION</source>
+        <translation>Annotation</translation>
+    </message>
+    <message>
+        <source>STB_ANNOTATION</source>
+        <translation>Annotation</translation>
+    </message>
+    <message>
+        <source>TOP_EDIT_ANNOTATION</source>
+        <translation>Edit Annotation</translation>
+    </message>
+    <message>
+        <source>MEN_EDIT_ANNOTATION</source>
+        <translation>Edit</translation>
+    </message>
+    <message>
+        <source>STB_EDIT_ANNOTATION</source>
+        <translation>Edit Annotation</translation>
+    </message>
+    <message>
+      <source>TOP_DELETE_ANNOTATION</source>
+      <translation>Delete Annotation</translation>
+    </message>
+    <message>
+      <source>MEN_DELETE_ANNOTATION</source>
+      <translation>Delete</translation>
+    </message>
+    <message>
+      <source>STB_DELETE_ANNOTATION</source>
+      <translation>Delete Annotation</translation>
+    </message>
     <message>
         <source>MEN_POP_SHOW_DEPENDENCY_TREE</source>
         <translation>Show dependency tree</translation>
@@ -4996,6 +5080,30 @@ Please, select face, shell or solid and try again</translation>
         <source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
         <translation>Show all visible measures (dimension) created for the object</translation>
     </message>
+    <message>
+      <source>MEN_POP_SHOW_ALL_ANNOTATIONS</source>
+      <translation>Show all annotations</translation>
+    </message>
+    <message>
+      <source>STB_POP_SHOW_ALL_ANNOTATIONS</source>
+      <translation>Show all shape annotations for the object</translation>
+    </message>
+    <message>
+      <source>TOP_POP_SHOW_ALL_ANNOTATIONS</source>
+      <translation>Show all shape annotations for the object</translation>
+    </message>
+    <message>
+      <source>MEN_POP_HIDE_ALL_ANNOTATIONS</source>
+      <translation>Hide all annotations</translation>
+    </message>
+    <message>
+      <source>STB_POP_HIDE_ALL_ANNOTATIONS</source>
+      <translation>Hide all shape annotations for the object</translation>
+    </message>
+    <message>
+      <source>TOP_POP_HIDE_ALL_ANNOTATIONS</source>
+      <translation>Hide all shape annotations for the object</translation>
+    </message>
     <message>
         <source>TOP_POP_AUTO_COLOR</source>
         <translation>Auto color</translation>
@@ -6675,6 +6783,61 @@ Do you want to continue?</translation>
 Please specify suitable arguments.</translation>
     </message>
 </context>
+<context>
+    <name>MeasureGUI_AnnotationDlg</name>
+    <message>
+        <source>CREATE_ANNOTATION_TITLE</source>
+        <translation>Create annotation</translation>
+    </message>
+    <message>
+        <source>EDIT_ANNOTATION_TITLE</source>
+        <translation>Edit annotation</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_PREFIX</source>
+        <translation>Annotation</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_NAME</source>
+        <translation>Annotation name</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_PROPERTIES</source>
+        <translation>Properties</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_TEXT</source>
+        <translation>Text</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_SHAPE</source>
+        <translation>Shape</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_TYPE</source>
+        <translation>Type</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_SUB_SHAPE</source>
+        <translation>Sub-shape type</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_IS_SCREEN_FIXED</source>
+        <translation>Fixed screen position</translation>
+    </message>
+    <message>
+        <source>WHOLE_SHAPE</source>
+        <translation>Whole shape</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_STYLE</source>
+        <translation>Style</translation>
+    </message>
+    <message>
+        <source>ANNOTATION_FONT</source>
+        <translation>Font</translation>
+    </message>
+</context>
 <context>
     <name>MeasureGUI_CheckShapeDlg</name>
     <message>
old mode 100644 (file)
new mode 100755 (executable)
index 8c16f25..75e6aab
@@ -3492,6 +3492,50 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>PREF_DIMENSIONS_USE_TEXT3D</source>
         <translation>Utiliser du texte 3D</translation>
     </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS</source>
+        <translation type="unfinished">Shape annotations</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_FONT</source>
+        <translation type="unfinished">Font</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_FONT_COLOR</source>
+        <translation type="unfinished">Font color</translation>
+    </message>
+    <message>
+        <source>PREF_SHAPE_ANNOTATIONS_LINE_COLOR</source>
+        <translation type="unfinished">Line color</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_LINE_WIDTH</source>
+       <translation type="unfinished">Line width</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_LINE_STYLE</source>
+       <translation type="unfinished">Line style</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_AUTOHIDE</source>
+       <translation type="unfinished">Hide when attachment is invisible</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID</source>
+       <translation type="unfinished">Solid</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH</source>
+       <translation type="unfinished">Dashed</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT</source>
+       <translation type="unfinished">Dotted</translation>
+    </message>
+    <message>
+       <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH</source>
+       <translation type="unfinished">Mixed</translation>
+    </message>
     <message>
         <source>PREF_HIDE_INPUT_OBJECT</source>
         <translation>Cacher dans la vue les objets en entrée</translation>
@@ -4988,6 +5032,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
         <translation>Afficher toutes les cotations visibles créées sur l&apos;objet</translation>
     </message>
+    <message>
+        <source>MEN_POP_SHOW_ALL_ANNOTATIONS</source>
+        <translation type="unfinished">Show all annotations</translation>
+    </message>
+    <message>
+        <source>STB_POP_SHOW_ALL_ANNOTATIONS</source>
+        <translation type="unfinished">Show all shape annotations for the object</translation>
+    </message>
+    <message>
+        <source>TOP_POP_SHOW_ALL_ANNOTATIONS</source>
+        <translation type="unfinished">Show all shape annotations for the object</translation>
+    </message>
+    <message>
+        <source>MEN_POP_HIDE_ALL_ANNOTATIONS</source>
+        <translation type="unfinished">Hide all annotations</translation>
+    </message>
+    <message>
+        <source>STB_POP_HIDE_ALL_ANNOTATIONS</source>
+        <translation type="unfinished">Hide all shape annotations for the object</translation>
+    </message>
+    <message>
+        <source>TOP_POP_HIDE_ALL_ANNOTATIONS</source>
+        <translation type="unfinished">Hide all shape annotations for the object</translation>
+    </message>
     <message>
         <source>TOP_POP_AUTO_COLOR</source>
         <translation>Couleur automatique</translation>
old mode 100644 (file)
new mode 100755 (executable)
index c0c9cdd..3ed5307
       <source>PREF_DIMENSIONS_USE_TEXT3D</source>
       <translation>3Dテキストの使用</translation>
     </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS</source>
+      <translation type="unfinished">Shape annotations</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_FONT</source>
+      <translation type="unfinished">Font</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_FONT_COLOR</source>
+      <translation type="unfinished">Font color</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINE_COLOR</source>
+      <translation type="unfinished">Line color</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINE_WIDTH</source>
+      <translation type="unfinished">Line width</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINE_STYLE</source>
+      <translation type="unfinished">Line style</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_AUTOHIDE</source>
+      <translation type="unfinished">Hide when attachment is invisible</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID</source>
+      <translation type="unfinished">Solid</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH</source>
+      <translation type="unfinished">Dashed</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT</source>
+      <translation type="unfinished">Dotted</translation>
+    </message>
+    <message>
+      <source>PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH</source>
+      <translation type="unfinished">Mixed</translation>
+    </message>
     <message>
       <source>PREF_HIDE_INPUT_OBJECT</source>
       <translation>ビューワから入力したオブジェクトの非表示</translation>
       <source>TOP_POP_HIDE_ALL_DIMENSIONS</source>
       <translation>オブジェクトのために作成されたすべての見える基準寸法を表示</translation>
     </message>
+    <message>
+      <source>MEN_POP_SHOW_ALL_ANNOTATIONS</source>
+      <translation type="unfinished">Show all annotations</translation>
+    </message>
+    <message>
+      <source>STB_POP_SHOW_ALL_ANNOTATIONS</source>
+      <translation type="unfinished">Show all shape annotations for the object</translation>
+    </message>
+    <message>
+      <source>TOP_POP_SHOW_ALL_ANNOTATIONS</source>
+      <translation type="unfinished">Show all shape annotations for the object</translation>
+    </message>
+    <message>
+      <source>MEN_POP_HIDE_ALL_ANNOTATIONS</source>
+      <translation type="unfinished">Hide all annotations</translation>
+    </message>
+    <message>
+      <source>STB_POP_HIDE_ALL_ANNOTATIONS</source>
+      <translation type="unfinished">Hide all shape annotations for the object</translation>
+    </message>
+    <message>
+      <source>TOP_POP_HIDE_ALL_ANNOTATIONS</source>
+      <translation type="unfinished">Hide all shape annotations for the object</translation>
+    </message>
     <message>
       <source>TOP_POP_AUTO_COLOR</source>
       <translation>自動色</translation>
old mode 100644 (file)
new mode 100755 (executable)
index eb9c53f..c15469d
@@ -39,6 +39,8 @@
 #include "GEOM_Displayer.h"
 #include "GEOM_AISShape.hxx"
 #include "GEOMUtils_XmlHandler.hxx"
+#include "GEOMGUI_AnnotationMgr.h"
+#include "GEOMGUI_TextTreeSelector.h"
 
 #include "GEOM_Actor.h"
 
@@ -227,6 +229,7 @@ GeometryGUI::GeometryGUI() :
 
   myCreationInfoWdg = 0;
   myTextTreeWdg = 0;
+  myAnnotationMgr = 0;
 
   connect( Material_ResourceMgr::resourceMgr(), SIGNAL( changed() ), this, SLOT( updateMaterials() ) );
 
@@ -257,13 +260,19 @@ GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName )
 {
   if ( !myGUIMap.contains( libraryName ) ) {
     // try to load library if it is not loaded yet
-#ifndef WIN32
-    QString dirs = getenv( "LD_LIBRARY_PATH" );
-    QString sep  = ":";
-#else
+#if defined(WIN32)
     QString dirs = getenv( "PATH" );
+#elif defined(__APPLE__)
+    QString dirs = getenv( "DYLD_LIBRARY_PATH" );
+#else
+    QString dirs = getenv( "LD_LIBRARY_PATH" );
+#endif
+#if defined(WIN32)
     QString sep  = ";";
+#else
+    QString sep  = ":";
 #endif
+
     if ( !dirs.isEmpty() ) {
       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
       QListIterator<QString> it( dirList ); it.toBack();
@@ -301,13 +310,20 @@ GEOMPluginGUI* GeometryGUI::getPluginLibrary( const QString& libraryName )
 {
   if ( !myGUIMap.contains( libraryName ) ) {
     // try to load library if it is not loaded yet
-#ifndef WIN32
-    QString dirs = getenv( "LD_LIBRARY_PATH" );
-    QString sep  = ":";
-#else
+
+#if defined(WIN32)
     QString dirs = getenv( "PATH" );
+#elif defined(__APPLE__)
+    QString dirs = getenv( "DYLD_LIBRARY_PATH" );
+#else
+    QString dirs = getenv( "LD_LIBRARY_PATH" );
+#endif
+#if defined(WIN32)
     QString sep  = ";";
+#else
+    QString sep  = ":";
 #endif
+
     if ( !dirs.isEmpty() ) {
       QStringList dirList = dirs.split(sep, QString::SkipEmptyParts ); // skip empty entries
       QListIterator<QString> it( dirList ); it.toBack();
@@ -373,6 +389,26 @@ void GeometryGUI::ActiveWorkingPlane()
   }
 }
 
+//=======================================================================
+// function : GeometryGUI::SetActiveDialogBox()
+// purpose  : Set active dialog box
+//=======================================================================
+GEOMGUI_AnnotationMgr* GeometryGUI::GetAnnotationMgr()
+{
+  if ( !myAnnotationMgr )
+    myAnnotationMgr = new GEOMGUI_AnnotationMgr( getApp() );
+  return myAnnotationMgr;
+}
+
+//=======================================================================
+// function : GeometryGUI::SetActiveDialogBox()
+// purpose  : Set active dialog box
+//=======================================================================
+GEOMGUI_TextTreeWdg* GeometryGUI::GetTextTreeWdg() const
+{
+  return myTextTreeWdg;
+}
+
 //=======================================================================
 // function : GeometryGUI::SetActiveDialogBox()
 // purpose  : Set active dialog box
@@ -661,11 +697,16 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
   case GEOMOp::OpCheckSelfInters:    // MENU MEASURE - CHECK SELF INTERSECTIONS
   case GEOMOp::OpFastCheckInters:    // MENU MEASURE - FAST CHECK INTERSECTIONS
   case GEOMOp::OpManageDimensions:   // MENU MEASURE - MANAGE DIMENSIONS
+  case GEOMOp::OpAnnotation:         // MENU MEASURE - ANNOTATION
+  case GEOMOp::OpEditAnnotation:     // POPUP MENU - EDIT ANNOTATION
+  case GEOMOp::OpDeleteAnnotation:   // POPUP MENU - DELETE ANNOTATION
 #ifndef DISABLE_PLOT2DVIEWER
   case GEOMOp::OpShapeStatistics:    // MENU MEASURE - SHAPE STATISTICS
 #endif
   case GEOMOp::OpShowAllDimensions:  // POPUP MENU - SHOW ALL DIMENSIONS
   case GEOMOp::OpHideAllDimensions:  // POPUP MENU - HIDE ALL DIMENSIONS
+  case GEOMOp::OpShowAllAnnotations: // POPUP MENU - SHOW ALL ANNOTATIONS
+  case GEOMOp::OpHideAllAnnotations: // POPUP MENU - HIDE ALL ANNOTATIONS
     libName = "MeasureGUI";
     break;
   case GEOMOp::OpGroupCreate:        // MENU GROUP - CREATE
@@ -698,10 +739,12 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
 
       GEOMPluginGUI* library = 0;
       if ( !libName.isEmpty() ) {
-#ifndef WIN32
-        libName = QString( "lib" ) + libName + ".so";
-#else
+#if defined(WIN32)
         libName = libName + ".dll";
+#elif defined(__APPLE__)
+        libName = QString( "lib" ) + libName + ".dylib";
+#else
+        libName = QString( "lib" ) + libName + ".so";
 #endif
         library = getPluginLibrary( libName );
       }
@@ -727,10 +770,12 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
 
   GEOMGUI* library = 0;
   if ( !libName.isEmpty() ) {
-#ifndef WIN32
-    libName = QString( "lib" ) + libName + ".so";
-#else
+#if defined(WIN32)
     libName = libName + ".dll";
+#elif defined(__APPLE__)
+    libName = QString( "lib" ) + libName + ".dylib";
+#else
+    libName = QString( "lib" ) + libName + ".so";
 #endif
     library = getLibrary( libName );
   }
@@ -1042,6 +1087,9 @@ void GeometryGUI::initialize( CAM_Application* app )
   createGeomAction( GEOMOp::OpMinDistance,      "MIN_DIST" );
   createGeomAction( GEOMOp::OpAngle,            "MEASURE_ANGLE" );
   createGeomAction( GEOMOp::OpManageDimensions, "MANAGE_DIMENSIONS" );
+  createGeomAction( GEOMOp::OpAnnotation,       "ANNOTATION" );
+  createGeomAction( GEOMOp::OpEditAnnotation,   "EDIT_ANNOTATION" );
+  createGeomAction( GEOMOp::OpDeleteAnnotation, "DELETE_ANNOTATION" );
 
   createGeomAction( GEOMOp::OpTolerance,        "TOLERANCE" );
   createGeomAction( GEOMOp::OpWhatIs,           "WHAT_IS" );
@@ -1115,9 +1163,11 @@ void GeometryGUI::initialize( CAM_Application* app )
 #ifndef DISABLE_GRAPHICSVIEW
   createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
 #endif
-  createGeomAction( GEOMOp::OpReduceStudy,       "POP_REDUCE_STUDY" );
-  createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
-  createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
+  createGeomAction( GEOMOp::OpReduceStudy,        "POP_REDUCE_STUDY" );
+  createGeomAction( GEOMOp::OpShowAllDimensions,  "POP_SHOW_ALL_DIMENSIONS" );
+  createGeomAction( GEOMOp::OpHideAllDimensions,  "POP_HIDE_ALL_DIMENSIONS" );
+  createGeomAction( GEOMOp::OpShowAllAnnotations, "POP_SHOW_ALL_ANNOTATIONS" );
+  createGeomAction( GEOMOp::OpHideAllAnnotations, "POP_HIDE_ALL_ANNOTATIONS" );
 
   // Create actions for increase/decrease transparency shortcuts
   createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
@@ -1139,7 +1189,7 @@ void GeometryGUI::initialize( CAM_Application* app )
 
   // ---- create menus --------------------------
 
-  int fileId = createMenu( tr( "MEN_FILE" ), -1, -1 );
+  /*int fileId =*/ createMenu( tr( "MEN_FILE" ), -1, -1 );
 
   int editId = createMenu( tr( "MEN_EDIT" ), -1, -1 );
   createMenu( GEOMOp::OpDelete, editId, -1 );
@@ -1310,6 +1360,8 @@ void GeometryGUI::initialize( CAM_Application* app )
   createMenu( GEOMOp::OpAngle,            dimId, -1 );
   createMenu( GEOMOp::OpManageDimensions, dimId, -1 );
 
+  createMenu( GEOMOp::OpAnnotation,       measurId, -1 );
+
   createMenu( separator(),               measurId, -1 );
   createMenu( GEOMOp::OpTolerance,       measurId, -1 );
   createMenu( separator(),               measurId, -1 );
@@ -1466,6 +1518,7 @@ void GeometryGUI::initialize( CAM_Application* app )
   createTool( GEOMOp::OpBoundingBox,      measureTbId );
   createTool( GEOMOp::OpMinDistance,      measureTbId );
   createTool( GEOMOp::OpAngle,            measureTbId );
+  createTool( GEOMOp::OpAnnotation,       measureTbId );
   createTool( GEOMOp::OpTolerance  ,      measureTbId );
   createTool( separator(),                measureTbId );
   createTool( GEOMOp::OpFreeBoundaries,   measureTbId );
@@ -1586,6 +1639,12 @@ void GeometryGUI::initialize( CAM_Application* app )
   mgr->setRule( action( GEOMOp::OpNoAutoColor ), autoColorPrefix + " and isAutoColor=true", QtxPopupMgr::VisibleRule );
   mgr->insert( separator(), -1, -1 );     // -----------
 
+  mgr->insert( action(  GEOMOp::OpEditAnnotation ), -1, -1 );  // edit annotation
+  mgr->setRule( action( GEOMOp::OpEditAnnotation ),  clientOCC + " and annotationsCount=1", QtxPopupMgr::VisibleRule );
+  mgr->insert( action(  GEOMOp::OpDeleteAnnotation ), -1, -1 );  // delete annotation
+  mgr->setRule( action( GEOMOp::OpDeleteAnnotation ),  clientOCC + " and annotationsCount>0", QtxPopupMgr::VisibleRule );
+  mgr->insert( separator(), -1, -1 );     // -----------
+
   QString canDisplay = "($component={'GEOM'}) and (selcount>0) and ({true} in $canBeDisplayed) ",
           onlyComponent = "((type='Component') and selcount=1)",
           rule = canDisplay + "and ((($type in {%1}) and( %2 )) or " + onlyComponent + ")",
@@ -1640,6 +1699,10 @@ void GeometryGUI::initialize( CAM_Application* app )
   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( action( GEOMOp::OpShowAllAnnotations ), -1, -1 ); // show all annotations
+  mgr->setRule( action( GEOMOp::OpShowAllAnnotations ), aDimensionRule.arg( "hasHiddenAnnotations" ), QtxPopupMgr::VisibleRule );
+  mgr->insert( action( GEOMOp::OpHideAllAnnotations ), -1, -1 ); // hide all annotations
+  mgr->setRule( action( GEOMOp::OpHideAllAnnotations ), aDimensionRule.arg( "hasVisibleAnnotations" ), QtxPopupMgr::VisibleRule );
 
   mgr->insert( separator(), -1, -1 );     // -----------
   mgr->insert( action(  GEOMOp::OpUnpublishObject ), -1, -1 ); // Unpublish object
@@ -1821,8 +1884,11 @@ bool GeometryGUI::activateModule( SUIT_Study* study )
   getApp()->insertDockWindow( myCreationInfoWdg->getWinID(), myCreationInfoWdg );
   getApp()->placeDockWindow( myCreationInfoWdg->getWinID(), Qt::LeftDockWidgetArea );
 
-  if ( !myTextTreeWdg )
+  if ( !myTextTreeWdg ) {
     myTextTreeWdg = new GEOMGUI_TextTreeWdg( getApp() );
+    new GEOMGUI_TextTreeSelector( myTextTreeWdg, GetAnnotationMgr(), getApp()->selectionMgr() );
+  }
+
   getApp()->insertDockWindow( myTextTreeWdg->getWinID(), myTextTreeWdg );
   getApp()->placeDockWindow( myTextTreeWdg->getWinID(), Qt::LeftDockWidgetArea );
 
@@ -2028,6 +2094,10 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
           break;
         }
   }
+  SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>(viewer);
+  if ( aSOCCView ) {
+    GetAnnotationMgr()->RemoveView( aSOCCView );
+  }
 }
 
 //================================================================================
@@ -2176,7 +2246,7 @@ Handle(TColStd_HArray1OfByte) GeometryGUI::getTexture
 
           aTexture  = new TColStd_HArray1OfByte (1, aStream->length());
 
-          for (int i = 0; i < aStream->length(); i++)
+          for ( CORBA::ULong i = 0; i < aStream->length(); i++)
             aTexture->SetValue( i+1, (Standard_Byte)aStream[i] );
           aTextureMap[ theId ] = aTexture;
         }
@@ -2355,6 +2425,10 @@ void GeometryGUI::createPreferences()
   addPreference( tr( "PREF_AUTO_BRING_TO_FRONT" ), genGroup,
                  LightApp_Preferences::Bool, "Geometry", "auto_bring_to_front" );
 
+  // --------------------------------------------------------------------------
+  // Dimensions (Measurements) preferences
+  // --------------------------------------------------------------------------
+
   int aDimGroupId = addPreference( tr( "PREF_DIMENSIONS" ), tabId );
   setPreferenceProperty( aDimGroupId, "columns", 2 );
 
@@ -2378,7 +2452,7 @@ void GeometryGUI::createPreferences()
   resMgr->value("resources", "GEOM", aFontFile);
   aFontFile = aFontFile + QDir::separator() + "Y14.5M-2009.ttf";
   // add enginier font into combobox
-  int fontID = QFontDatabase::addApplicationFont( aFontFile );
+  /*int fontID =*/ QFontDatabase::addApplicationFont( aFontFile );
   Handle(Font_SystemFont) sf = new Font_SystemFont( 
     new TCollection_HAsciiString("Y14.5M-2009"), 
     Font_FA_Regular, 
@@ -2438,6 +2512,53 @@ void GeometryGUI::createPreferences()
   addPreference( tr( "PREF_DIMENSIONS_USE_TEXT3D" ), aDimGroupId,
                  LightApp_Preferences::Bool, "Geometry", "dimensions_use_text3d" );
 
+  // --------------------------------------------------------------------------
+  // Shape annotation preferences
+  // --------------------------------------------------------------------------
+
+  const int aShapeAnnGroupId = addPreference( tr( "PREF_SHAPE_ANNOTATIONS" ), tabId );
+  setPreferenceProperty( aShapeAnnGroupId, "columns", 2 );
+
+  addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_font_color" );
+  addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_COLOR" ), aShapeAnnGroupId, LightApp_Preferences::Color, "Geometry", "shape_annotation_line_color" );
+  const int aShapeAnnFont = 
+    addPreference( tr( "PREF_SHAPE_ANNOTATIONS_FONT" ), aShapeAnnGroupId, LightApp_Preferences::Font, "Geometry", "shape_annotation_font" );
+
+  int aShapeAnnFontFeatures = QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::Bold | QtxFontEdit::Italic;
+  setPreferenceProperty( aShapeAnnFont, "features", aShapeAnnFontFeatures );
+  setPreferenceProperty( aShapeAnnFont, "mode", QtxFontEdit::Custom );
+  setPreferenceProperty( aShapeAnnFont, "fonts", anOCCFonts );
+
+  const int aShapeAnnLineWidth = 
+    addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_WIDTH" ), aShapeAnnGroupId, LightApp_Preferences::IntSpin, "Geometry", "shape_annotation_line_width" );
+
+  setPreferenceProperty( aShapeAnnLineWidth, "min", 1 );
+  setPreferenceProperty( aShapeAnnLineWidth, "max", 5 );
+
+  addPreference( tr( "PREF_SHAPE_ANNOTATIONS_AUTOHIDE" ), aShapeAnnGroupId, LightApp_Preferences::Bool, "Geometry", "shape_annotation_autohide" );
+
+  const int aShapeAnnLineStyle =
+    addPreference( tr( "PREF_SHAPE_ANNOTATIONS_LINE_STYLE" ), aShapeAnnGroupId, LightApp_Preferences::Selector, "Geometry", "shape_annotation_line_style" );
+
+  QStringList aLineStyleList;
+  aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID") );
+  aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH") );
+  aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT") );
+  aLineStyleList.append( tr("PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH") );
+
+  QList<QVariant> aLineStyleIds;
+  aLineStyleIds.append(0);
+  aLineStyleIds.append(1);
+  aLineStyleIds.append(2);
+  aLineStyleIds.append(3);
+
+  setPreferenceProperty( aShapeAnnLineStyle, "strings", aLineStyleList );
+  setPreferenceProperty( aShapeAnnLineStyle, "indexes", aLineStyleIds );
+
+  // --------------------------------------------------------------------------
+  // Isoline drawing preferences
+  // --------------------------------------------------------------------------
+
   int isoGroup = addPreference( tr( "PREF_ISOS" ), tabId );
   setPreferenceProperty( isoGroup, "columns", 2 );
   int isoU = addPreference( tr( "PREF_ISOS_U" ), isoGroup,
@@ -2703,14 +2824,21 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
         aDisplayer.UpdateColorScale( anIsRedisplayFieldSteps, true );
       }
     }
-    else if ( param == QString("dimensions_color")        ||
-              param == QString("dimensions_line_width")   ||
-              param == QString("dimensions_font")         ||
-              param == QString("dimensions_arrow_length") ||
-              param == QString("dimensions_show_units")   ||
-              param == QString("dimensions_length_units") ||
-              param == QString("dimensions_angle_units")  ||
-              param == QString("dimensions_use_text3d")  ||
+    else if ( param == QString("dimensions_color")            ||
+              param == QString("dimensions_line_width")       ||
+              param == QString("dimensions_font")             ||
+              param == QString("dimensions_arrow_length")     ||
+              param == QString("dimensions_show_units")       ||
+              param == QString("dimensions_length_units")     ||
+              param == QString("dimensions_angle_units")      ||
+              param == QString("dimensions_use_text3d")       ||
+              param == QString("shape_annotation_font_color") ||
+              param == QString("shape_annotation_line_color") ||
+              param == QString("shape_annotation_font")       ||
+              param == QString("shape_annotation_line_width") ||
+              param == QString("shape_annotation_autohide")   ||
+              param == QString("shape_annotation_line_style") ||
+              param == QString("shape_annotation_line_style") ||
               param == QString("label_color") )
     {
       SalomeApp_Application* anApp = getApp();
@@ -2740,6 +2868,20 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
 
         SALOME_ListIO aVisible;
         aViewer->GetVisible( aVisible );
+
+        GEOMGUI_AnnotationMgr* anAnnotationMgr = GetAnnotationMgr();
+        if ( anAnnotationMgr ) {
+          SALOME_ListIteratorOfListIO anIter( aVisible );
+          while ( anIter.More() ) {
+            if ( anAnnotationMgr->isAnnotationEntry( anIter.Value()->getEntry() ) ) {
+              aVisible.Remove( anIter );
+            }
+            else {
+              anIter.Next();
+            }
+          }
+        }
+
         aDisplayer.Redisplay( aVisible, false, aViewer );
       }
       if ( param == QString( "label_color" ) ) {
@@ -2796,6 +2938,7 @@ void GeometryGUI::storeVisualParameters (int savePoint)
   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
   if ( !appStudy || !appStudy->studyDS() )
     return;
+
   _PTR(Study) studyDS = appStudy->studyDS();
 
   // componentName is used for encoding of entries when storing them in IParameters
@@ -2813,12 +2956,17 @@ void GeometryGUI::storeVisualParameters (int savePoint)
   QList<SUIT_ViewManager*> lst;
   QList<SUIT_ViewManager*>::Iterator it;
 
+  GEOMGUI_AnnotationMgr* aAnnotationMgr = GetAnnotationMgr();
+
   // main cycle to store parameters of displayed objects
   lst.clear();
   getApp()->viewManagers(lst);
   for (it = lst.begin(); it != lst.end(); it++) {
     SUIT_ViewManager* vman = *it;
     QString vType = vman->getType();
+    SUIT_ViewModel* vmodel = vman->getViewModel();
+    SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
+
     int aMgrId = vman->getGlobalId();
     // saving VTK actors properties
     QVector<SUIT_ViewWindow*> views = vman->getViews();
@@ -2940,28 +3088,41 @@ void GeometryGUI::storeVisualParameters (int savePoint)
           param = occParam + GEOM::propertyName( GEOM::IsosWidth );
           ip->setParameter(entry, param.toStdString(), aProps.value(GEOM::propertyName( GEOM::IsosWidth )).toString().toStdString());
         }
+
+        if ( vType == SOCC_Viewer::Type() && aAnnotationMgr ) {
+          std::string anAnnotationInfo = GetAnnotationMgr()->getDisplayedIndicesInfo(
+                                            o_it.key().toLatin1().data(), dynamic_cast<SOCC_Viewer*>(aView) ).toStdString();
+          if (!anAnnotationInfo.empty()) {
+            param = occParam + "ShapeAnnotationVisibleItems";
+            ip->setParameter(entry, param.toStdString(), anAnnotationInfo);
+          }
+        }
       } // object iterator
     } // for (views)
   } // for (viewManagers)
 
-  // store dimension attributes of objects:
+  // store shape annotation and dimension attributes of objects:
   // since the displayed object always persists in property map, we remember the object entries
   // on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
-  QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
+  const QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
+  const QString aAnnotationParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::ShapeAnnotations );
   QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
   for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
   {
     std::string aStudyEntry = (*aEntryIt).toLatin1().data();
-    std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName);
+    std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName );
 
+    // store dimension parameters
     GEOMGUI_DimensionProperty aDimensions( appStudy, aStudyEntry );
-
-    if ( aDimensions.GetNumber() == 0 )
-    {
-      continue;
+    if ( aDimensions.GetNumber() != 0 ) {
+      ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
     }
 
-    ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
+    _PTR(SObject) aObj( studyDS->FindObjectID( aStudyEntry ) );
+    const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aObj );
+    if ( !aShapeAnnAttr.IsNull() ) {
+      ip->setParameter( aStoreEntry, aAnnotationParam.toStdString(), aShapeAnnAttr->ExportAsPropertyString().toLatin1().data() );
+    }
   }
 }
 
@@ -3044,6 +3205,13 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
           GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
           aDimensionProp.SaveToAttribute( appStudy, entry.toLatin1().data() );
         }
+        else if ( aParamNameStr == GEOM::propertyName( GEOM::ShapeAnnotations ) )
+        {
+          Handle(GEOMGUI_AnnotationAttrs) anAttr =
+            GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( so, appStudy );
+
+          anAttr->ImportFromPropertyString( aValuesStr );
+        }
 
         continue;
       }
@@ -3099,7 +3267,10 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::LineWidth ), val.toInt());
       } else if (paramNameStr == GEOM::propertyName( GEOM::IsosWidth )) {
         aListOfMap[viewIndex].insert( GEOM::propertyName( GEOM::IsosWidth ), val.toInt());
+      } else if (paramNameStr == "ShapeAnnotationVisibleItems") {
+        aListOfMap[viewIndex].insert( "ShapeAnnotationVisibleItems", val);
       }
+
     } // for names/parameters iterator
 
     QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
@@ -3111,7 +3282,16 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
       if (aListOfMap[index].value(GEOM::propertyName( GEOM::Visibility )) == 1) {
         SUIT_ViewManager* vman = lst.at(index);
         SUIT_ViewModel* vmodel = vman->getViewModel();
-        displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
+        SALOME_View* aView = dynamic_cast<SALOME_View*>(vmodel);
+        displayer()->Display(entry, true, aView);
+
+        if ( vmodel->getType() == SOCC_Viewer::Type() ) {
+          PropMap& aProps = aListOfMap[index];
+          if ( aProps.contains( "ShapeAnnotationVisibleItems" ) ) {
+            SOCC_Viewer* aSOCCView = dynamic_cast<SOCC_Viewer*>( aView );
+            GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
+          }
+        }
       }
     }
   } // for entries iterator
@@ -3135,6 +3315,10 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
         occVMod->Repaint();
     }
   }
+
+  if ( myTextTreeWdg ) {
+    myTextTreeWdg->updateTree();
+  }
 }
 
 // Compute current name mode of the viewer
@@ -3367,6 +3551,7 @@ bool GeometryGUI::renameObject( const QString& entry, const QString& name)
       if (!CORBA::is_nil(anObj)) {
         anObj->SetName( name.toLatin1().data() );  // Rename the corresponding GEOM_Object
         emit SignalDependencyTreeRenameObject( anObj->GetEntry() );
+        emit SignalTextTreeRenameObject( entry );
       }
       result = true;
     }
@@ -3534,3 +3719,8 @@ void GeometryGUI::emitDimensionsUpdated( QString entry )
 {
   emit DimensionsUpdated( entry );
 }
+
+void GeometryGUI::emitAnnotationsUpdated( QString entry )
+{
+  emit SignalAnnotationsUpdated( entry );
+}
index f92d92ab7b03b375beacf2adfafad914027a3706..78a067a672c5620f859df1b4b765e2ede18fe955 100644 (file)
@@ -36,6 +36,7 @@
 #include <GEOM_Client.hxx>
 #include <SALOME_InteractiveObject.hxx>
 #include <SALOMEDSClient.hxx>
+#include <Qtx.h>
 
 #include "GEOMGUI.h"
 #include "GEOMPluginGUI.h"
@@ -65,6 +66,7 @@ class SUIT_ViewManager;
 class SalomeApp_Study;
 class GEOMGUI_CreationInfoWdg;
 class GEOMGUI_TextTreeWdg;
+class GEOMGUI_AnnotationMgr;
 
 //=================================================================================
 // class    : GeometryGUI
@@ -98,6 +100,10 @@ public:
 
   GEOM_Client&                GetShapeReader()    { static SHAPE_READER(myShapeReader);return myShapeReader; }
 
+  GEOMGUI_AnnotationMgr*      GetAnnotationMgr();
+
+  GEOMGUI_TextTreeWdg*        GetTextTreeWdg() const;
+
   // Get active dialog box
   QDialog*                    GetActiveDialogBox(){ return myActiveDialogBox; }
   // Set active dialog box
@@ -150,6 +156,7 @@ public:
                                            const int row, Qt::DropAction action );
 
   void                        emitDimensionsUpdated( QString entry );
+  void                        emitAnnotationsUpdated( QString entry );
 
 public slots:
   virtual bool                deactivateModule( SUIT_Study* );
@@ -179,6 +186,8 @@ signals :
   void                        SignalDefaultStepValueChanged( double newVal );
   void                        SignalDependencyTreeParamChanged( const QString&, const QString& );
   void                        SignalDependencyTreeRenameObject( const QString& );
+  void                        SignalTextTreeRenameObject( const QString& );
+  void                        SignalAnnotationsUpdated( const QString& );
   void                        DimensionsUpdated( const QString& );
 
 protected:
@@ -228,7 +237,8 @@ private:
 
   GEOMGUI_CreationInfoWdg*    myCreationInfoWdg;
   
-  GEOMGUI_TextTreeWdg*       myTextTreeWdg;
+  GEOMGUI_TextTreeWdg*        myTextTreeWdg;
+  GEOMGUI_AnnotationMgr*      myAnnotationMgr;
   
   SALOME_ListIO               myTopLevelIOList;               
 
old mode 100644 (file)
new mode 100755 (executable)
index cc44ca9..da8ae79
@@ -207,6 +207,11 @@ namespace GEOMOp {
 #ifndef DISABLE_PLOT2DVIEWER
     OpShapeStatistics    = 5019,   // MENU MEASURES - SHAPE STATISTICS
 #endif
+    OpAnnotation          = 5020,   // MENU MEASURES - ANNOTATION
+    OpEditAnnotation      = 5021,   // POPUP MENU - EDIT ANNOTATION
+    OpShowAllAnnotations  = 5022,   // POPUP MENU - SHOW ALL ANNOTATIONS
+    OpHideAllAnnotations  = 5023,   // POPUP MENU - HIDE ALL ANNOTATIONS
+    OpDeleteAnnotation    = 5024,   // POPUP MENU - DELETE ANNOTATION
     // GroupGUI --------------------//--------------------------------
     OpGroupCreate         = 6000,   // MENU GROUP - CREATE
     OpGroupEdit           = 6001,   // MENU GROUP - EDIT
index f9a7d0a72568d379ee21b0e2204dd1c9f687bb5b..6c2e34a89e01654ef16afe41a677bb6346857040 100644 (file)
@@ -191,7 +191,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const
       if (nbShapes > 0) {
         aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(1));
         aShape = aRefShape->GetValue();
-       
+
         if (!aShape.IsNull()) {
           // check arguments for Mantis issue 0021019
           if (!GEOMUtils::CheckShape(aShape, true))
@@ -218,12 +218,12 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const
           aShape = aShapeCopy;
 
           for (i = 2; i <= nbShapes; i++) {
-           aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(i));
-           aShape2 = aRefShape->GetValue();
-            
+            aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(i));
+            aShape2 = aRefShape->GetValue();
+
             if (!GEOMUtils::CheckShape(aShape2, true))
-             StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
-           
+              StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
+
             if (isCheckSelfInte) {
               BOPCol_ListOfShape aList2;
               aList2.Append(aShape2);
@@ -237,17 +237,17 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const
             // Copy shape
             aShapeCopy.Nullify();
             TNaming_CopyShape::CopyTool(aShape2, aMapTShapes, aShapeCopy);
-           aShape = performOperation (aShape, aShapeCopy, aSimpleType);
+            aShape = performOperation (aShape, aShapeCopy, aSimpleType);
 
             if (isRmExtraEdges) {
               aShape = RemoveExtraEdges(aShape);
             }
-           
-           if (aShape.IsNull()) {
-             return 0;
-           }
-         }
-       }
+
+            if (aShape.IsNull()) {
+              return 0;
+            }
+          }
+        }
       }
     }
     break;
@@ -262,7 +262,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const
         if (!GEOMUtils::CheckShape(aShape, true))
           StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
 
-       BOPAlgo_CheckerSI aCSI;  // checker of self-interferences
+        BOPAlgo_CheckerSI aCSI;  // checker of self-interferences
 
         if (isCheckSelfInte) {
           aCSI.SetLevelOfCheck(BOP_SELF_INTERSECTIONS_LEVEL);
@@ -281,7 +281,7 @@ Standard_Integer GEOMImpl_BooleanDriver::Execute(LOGBOOK& log) const
 
         TNaming_CopyShape::CopyTool(aShape, aMapTShapes, aShapeCopy);
         aShape = aShapeCopy;
-       
+
         Handle(TColStd_HSequenceOfTransient) aTools = aCI.GetShapes();
         const Standard_Integer nbShapes = aTools->Length();
         Standard_Integer i;
@@ -342,16 +342,30 @@ TopoDS_Shape GEOMImpl_BooleanDriver::makeCompoundShellFromFaces
   if (theShape.ShapeType() != TopAbs_COMPOUND)
     return theShape;
 
+  BRep_Builder B;
+  TopoDS_Compound aFaces;
+  B.MakeCompound(aFaces);
+
+  // simplify compound structure for
+  // Mantis issue 0023419 (note 0021712)
+  TopExp_Explorer aExp;
+  TopTools_MapOfShape aMapFaces;
+  aExp.Init(theShape, TopAbs_FACE);
+  for (; aExp.More(); aExp.Next()) {
+    const TopoDS_Shape& aFace = aExp.Current();
+    if (aMapFaces.Add(aFace)) {
+      B.Add(aFaces, aFace);
+    }
+  }
+
   BOPCol_ListOfShape aListShapes;
-  BOPTools_AlgoTools::MakeConnexityBlocks(theShape, TopAbs_EDGE, TopAbs_FACE, aListShapes);
+  BOPTools_AlgoTools::MakeConnexityBlocks(aFaces, TopAbs_EDGE, TopAbs_FACE, aListShapes);
 
   if (aListShapes.IsEmpty())
     return theShape;
 
   TopoDS_Compound aResult;
-  BRep_Builder B;
   B.MakeCompound(aResult);
-  TopExp_Explorer aExp;
   BOPCol_ListIteratorOfListOfShape anIter(aListShapes);
 
   for (; anIter.More(); anIter.Next()) {
@@ -373,6 +387,7 @@ TopoDS_Shape GEOMImpl_BooleanDriver::makeCompoundShellFromFaces
 
   return aResult;
 }
+
 //=======================================================================
 //function : performOperation
 //purpose  :
@@ -415,11 +430,12 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation
           // This allows to avoid adding empty compounds,
           // resulting from COMMON on two non-intersecting shapes.
           if (aStepResult.ShapeType() == TopAbs_COMPOUND) {
-          #if OCC_VERSION_MAJOR >= 7
-            if (aValue1.ShapeType() == TopAbs_FACE && aValue2.ShapeType() == TopAbs_FACE) {
+#if OCC_VERSION_MAJOR >= 7
+            if ((aValue1.ShapeType() == TopAbs_FACE || aValue1.ShapeType() == TopAbs_SHELL) &&
+                (aValue2.ShapeType() == TopAbs_FACE || aValue2.ShapeType() == TopAbs_SHELL)) {
               aStepResult = makeCompoundShellFromFaces(aStepResult);
             }
-          #endif
+#endif
             TopoDS_Iterator aCompIter (aStepResult);
             for (; aCompIter.More(); aCompIter.Next()) {
               // add shape in a result
@@ -477,11 +493,12 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation
         // This allows to avoid adding empty compounds,
         // resulting from CUT of parts
         if (aCut.ShapeType() == TopAbs_COMPOUND) {
-        #if OCC_VERSION_MAJOR >= 7
-          if (itSub1.Value().ShapeType() == TopAbs_FACE) {
+#if OCC_VERSION_MAJOR >= 7
+          if (itSub1.Value().ShapeType() == TopAbs_FACE ||
+              itSub1.Value().ShapeType() == TopAbs_SHELL) {
             aCut = makeCompoundShellFromFaces(aCut);
           }
-        #endif
+#endif
           TopoDS_Iterator aCompIter (aCut);
           for (; aCompIter.More(); aCompIter.Next()) {
             // add shape in a result
@@ -509,7 +526,7 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation
 
   // perform FUSE operation
   else if (theType == BOOLEAN_FUSE) {
-  #if OCC_VERSION_MAJOR >= 7
+#if OCC_VERSION_MAJOR >= 7
     Standard_Boolean isFaces = Standard_False;
     TopTools_ListOfShape listShape1, listShape2;
     GEOMUtils::AddSimpleShapes(theShape1, listShape1);
@@ -521,7 +538,8 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation
       TopTools_ListIteratorOfListOfShape itSub2 (listShape2);
       for (; itSub2.More(); itSub2.Next()) {
         TopoDS_Shape aValue2 = itSub2.Value();
-        if (aValue1.ShapeType() == TopAbs_FACE && aValue2.ShapeType() == TopAbs_FACE) {
+        if ((aValue1.ShapeType() == TopAbs_FACE || aValue1.ShapeType() == TopAbs_SHELL) &&
+            (aValue2.ShapeType() == TopAbs_FACE || aValue2.ShapeType() == TopAbs_SHELL)) {
           isFaces = Standard_True;
         }
       }
@@ -534,10 +552,10 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation
       StdFail_NotDone::Raise("Fuse operation can not be performed on the given shapes");
     }
     aShape = BO.Shape();
-  #if OCC_VERSION_MAJOR >= 7
+#if OCC_VERSION_MAJOR >= 7
     if (isFaces)
       aShape = makeCompoundShellFromFaces(aShape);
-  #endif
+#endif
   }
 
   // perform SECTION operation
@@ -569,7 +587,7 @@ TopoDS_Shape GEOMImpl_BooleanDriver::performOperation
         BO.ComputePCurveOn1(Standard_True);
         BO.ComputePCurveOn2(Standard_True);
         //modified by NIZNHY-PKV Tue Oct 18 14:34:18 2011t
-  
+
         BO.Build();
         if (!BO.IsDone()) {
           StdFail_NotDone::Raise("Section operation can not be performed on the given shapes");
index 7ac4978e652dad9d01b7cbc9fbf8f03f1694f561..7b6cd60e164e6ba53a70457fd0e3c2d59c4465a6 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "GEOMImpl_Fillet1d.hxx"
 
+#include <Basics_OCCTVersion.hxx>
+
 #include <BRep_Tool.hxx>
 #include <BRepAdaptor_Curve.hxx>
 #include <BRepBuilderAPI_MakeEdge.hxx>
@@ -39,6 +41,8 @@
 #include <IntRes2d_IntersectionSegment.hxx>
 #include <TopExp.hxx>
 
+#include <Standard_NotImplemented.hxx>
+
 
 /**
  * This function returns Standard_True if it is possible to divide edge, i.e.
@@ -61,7 +65,7 @@ static Standard_Boolean IsDivideEdge(const TopoDS_Edge   &theEdge,
   gp_Pnt             aPStart   = aCurve->Value(theStart);
   gp_Pnt             aPEnd     = aCurve->Value(theEnd);
   TopoDS_Vertex      aVFirst   = TopExp::FirstVertex(theEdge);
-  TopoDS_Vertex      aVLast    = TopExp::FirstVertex(theEdge);
+  TopoDS_Vertex      aVLast    = TopExp::LastVertex(theEdge);
   Standard_Real      aTolFirst = BRep_Tool::Tolerance(aVFirst);
   Standard_Real      aTolLast  = BRep_Tool::Tolerance(aVLast);
   Standard_Real      aTolConf  = Precision::Confusion();
@@ -77,7 +81,11 @@ static Standard_Boolean IsDivideEdge(const TopoDS_Edge   &theEdge,
       aDistSL <= aTolLast  + aTolConf) {
     if (aDistEF <= aTolFirst + aTolConf ||
         aDistEL <= aTolLast  + aTolConf) {
-      isSplit   = Standard_False;
+
+      isSplit = Standard_False;
+      // in this case the original edge is thrown, and distance (gap) from new arc end
+      // to a vertex of original wire can reach (aVertexTolerance + Precision::Confusion()).
+      // Resulting wire is fixed (Mantis issue 0023411) in GEOMImpl_Fillet1dDriver::MakeFillet()
     }
   }
 
@@ -156,8 +164,8 @@ static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve
 {
   const Standard_Real aTol = Precision::Confusion();
   const Standard_Real anAngTol = Precision::Angular();
-  Geom2dAPI_InterCurveCurve anInter(theCurve, new Geom2d_Line(theStart,
-    gp_Dir2d(gp_Vec2d(theStart, theEnd))), aTol);
+  Handle(Geom2d_Line) aRadiusLine = new Geom2d_Line (theStart, gp_Dir2d(gp_Vec2d(theStart, theEnd)));
+  Geom2dAPI_InterCurveCurve anInter (theCurve, aRadiusLine, aTol);
   Standard_Integer a;
   gp_Pnt2d aPoint;
   for(a = anInter.NbPoints(); a > 0; a--)
@@ -173,6 +181,16 @@ static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve
   Handle(Geom2d_Curve) aCurve;
   for(a = anInter.NbSegments(); a > 0; a--)
   {
+    // Porting to DEV version of OCCT 10.02.2017 BEGIN
+#if OCC_VERSION_LARGE > 0x07010000
+    Standard_NotImplemented::Raise("The treatment of tangential intersection is not implemented");
+#else
+    // This piece of code seems never worked, because:
+    // 1. In case of two curves intersection
+    //    method Segment with TWO output curves HAS TO be used.
+    // 2. Method Segment with ONE output curve (as below) just raises
+    //    Standard_NotImplemented exception since 05.03.2012 (at least)
+    //    and that is why has been eliminated 03.02.2017.
     anInter.Segment(a, aCurve);
     aPoint = aCurve->Value(aCurve->FirstParameter());
     if (aPoint.Distance(theStart) < aTol)
@@ -190,6 +208,8 @@ static Standard_Boolean isRadiusIntersected(const Handle(Geom2d_Curve)& theCurve
       return Standard_True;
     if (gp_Vec2d(aPoint, theStart).IsOpposite(gp_Vec2d(aPoint, theEnd), anAngTol))
       return Standard_True;
+#endif
+    // Porting to DEV version of OCCT 10.02.2017 END
   }
   return Standard_False;
 }
@@ -351,7 +371,7 @@ Standard_Boolean GEOMImpl_Fillet1d::Perform(const Standard_Real theRadius)
           aParam2 > myStart1 + aTol && aParam2 < myEnd1 - aTol) {
         // Add the point in the list in increasing order.
         const Standard_Real aParam = 0.5*(aParam1 + aParam2);
-  
+
         for(anIter.Initialize(aParams); anIter.More(); anIter.Next()) {
           if (anIter.Value() > aParam) {
             aParams.InsertBefore(aParam, anIter);
index 34efa40cd333fa70e69f8e0078f8f6895d41b492..bd2ece120db5678151902b23d1198430c167be4b 100644 (file)
@@ -48,6 +48,7 @@
 #include <TopTools_IndexedMapOfShape.hxx>
 
 #include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
 #include <BRepTools.hxx>
 #include <BRepBuilderAPI_MakeWire.hxx>
 #include <BRepCheck_Analyzer.hxx>
@@ -270,11 +271,11 @@ Standard_Integer GEOMImpl_Fillet1dDriver::Execute(LOGBOOK& log) const
 //function : MakeFillet
 //purpose  :
 //=======================================================================
-bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& aWire,
-                                         const TopTools_ListOfShape& aVertexList,
-                                         const Standard_Real rad,
+bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& theWire,
+                                         const TopTools_ListOfShape& theVertexList,
+                                         const Standard_Real theRadius,
                                          bool isFinalPass,
-                                         TopoDS_Wire& aResult) const
+                                         TopoDS_Wire& theResult) const
 {
   // this variable is needed to break execution
   // in case of fillet failure and try to fuse edges
@@ -290,8 +291,8 @@ bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& aWire,
   TopTools_ListOfShape aListOfNewEdge;
   // remember relation between initial and modified map
   TopTools_IndexedDataMapOfShapeListOfShape aMapVToEdges;
-  TopExp::MapShapesAndAncestors( aWire, TopAbs_VERTEX, TopAbs_EDGE, aMapVToEdges );
-  TopTools_ListIteratorOfListOfShape anIt( aVertexList );
+  TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, aMapVToEdges );
+  TopTools_ListIteratorOfListOfShape anIt( theVertexList );
   for ( ; anIt.More(); anIt.Next() ) {
     TopoDS_Vertex aV = TopoDS::Vertex( anIt.Value() );
     if ( aV.IsNull() || !aMapVToEdges.Contains( aV ) )
@@ -313,7 +314,7 @@ bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& aWire,
       continue; // seems edges does not belong to same plane or parallel (fillet can not be build)
 
     GEOMImpl_Fillet1d aFilletAlgo (anEdge1, anEdge2, aPlane);
-    if (!aFilletAlgo.Perform(rad)) {
+    if (!aFilletAlgo.Perform(theRadius)) {
       if (isFinalPass)
         continue; // can not create fillet with given radius
       else {
@@ -356,23 +357,59 @@ bool GEOMImpl_Fillet1dDriver::MakeFillet(const TopoDS_Wire& aWire,
     return false;
 
   // create new wire instead of original
-  for (TopExp_Explorer anExp (aWire, TopAbs_EDGE); anExp.More(); anExp.Next()) {
+  Standard_Real aTol;
+  Standard_Real aVertMaxTol = -RealLast();
+  for (TopExp_Explorer anExp (theWire, TopAbs_EDGE); anExp.More(); anExp.Next()) {
     TopoDS_Shape anEdge = anExp.Current();
     if (!anEdgeToEdgeMap.IsBound(anEdge))
       aListOfNewEdge.Append(anEdge);
     else if (!anEdgeToEdgeMap.Find(anEdge).IsNull())
       aListOfNewEdge.Append(anEdgeToEdgeMap.Find(anEdge));
-  }
-
-  GEOMUtils::SortShapes(aListOfNewEdge);
 
-  BRepBuilderAPI_MakeWire aWireTool;
-  aWireTool.Add(aListOfNewEdge);
-  aWireTool.Build();
-  if (!aWireTool.IsDone())
-    return 0;
+    // calculate maximum vertex tolerance of the initial wire
+    // to be used for resulting wire fixing (some gaps are possible)
+    for (TopExp_Explorer anExV (anEdge, TopAbs_VERTEX); anExV.More(); anExV.Next()) {
+      TopoDS_Vertex aVert = TopoDS::Vertex(anExV.Current());
+      aTol = BRep_Tool::Tolerance(aVert);
+      if (aTol > aVertMaxTol)
+        aVertMaxTol = aTol;
+    }
+  }
 
-  aResult = aWireTool.Wire();
+  // Fix for Mantis issue 0023411: BEGIN
+  BRep_Builder B;
+  TopoDS_Wire aResWire;
+  B.MakeWire(aResWire);
+  TopTools_ListIteratorOfListOfShape anItNewEdge (aListOfNewEdge);
+  for (; anItNewEdge.More(); anItNewEdge.Next()) {
+    B.Add(aResWire, TopoDS::Edge(anItNewEdge.Value()));
+  }
+  Handle(ShapeFix_Wire) aFW = new ShapeFix_Wire;
+  aFW->Load(aResWire);
+  aFW->FixReorder();
+  aFW->ClosedWireMode() = theWire.Closed();
+  // Fix for Mantis issue 0023411
+  // We forced to do this because of fillet 1d algorithm feature
+  // (see function DivideEdge in file GEOMImpl_Fillet1d.cxx):
+  // a distance (gap) from new arc end to a vertex of original wire
+  // can reach (aVertexTolerance + Precision::Confusion()),
+  // so a distance between two adjacent arcs will be covered by value below
+  aFW->FixConnected(aVertMaxTol*2.0 + Precision::Confusion()*3.0);
+  theResult = aFW->WireAPIMake();
+  GEOMUtils::FixShapeTolerance(theResult, TopAbs_VERTEX, Precision::Confusion());
+
+  // In OCCT 7.0.0 and earlier this gap was successfully covered by
+  // implementation of BRepBuilderAPI_MakeWire::Add(TopTools_ListOfShape)
+  // (in the case described in Mantis issue 0023411)
+
+  //GEOMUtils::SortShapes(aListOfNewEdge);
+  //BRepBuilderAPI_MakeWire aWireTool;
+  //aWireTool.Add(aListOfNewEdge);
+  //aWireTool.Build();
+  //if (!aWireTool.IsDone())
+  //  return 0;
+  //theResult = aWireTool.Wire();
+  // Fix for Mantis issue 0023411: END
 
   return isAllStepsOk;
 }
@@ -408,7 +445,7 @@ GetCreationInformation(std::string&             theOperationName,
   default:
     return false;
   }
-  
+
   return true;
 }
 
index ba76b62c31275ef08c0a664483473bdf124c0b7d..dd3318aac518bad0c98814d385db7af2e05ca565 100644 (file)
 #include <BOPCol_ListOfShape.hxx>
 #include <BOPDS_DS.hxx>
 #include <BOPDS_MapOfPassKey.hxx>
+#if OCC_VERSION_LARGE > 0x07010000
+#include <BOPDS_MapOfPair.hxx>
+#include <BOPDS_Pair.hxx>
+#endif
 #include <BRepBndLib.hxx>
 #include <BRepBuilderAPI_Copy.hxx>
 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
@@ -1574,18 +1578,31 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
 
   //
   Standard_Integer aNbS, n1, n2;
+#if OCC_VERSION_LARGE > 0x07010000
+  BOPDS_MapIteratorOfMapOfPair aItMPK;
+#else  
   BOPDS_MapIteratorMapOfPassKey aItMPK;
+#endif
   //
   // 2. Take the shapes from DS
   const BOPDS_DS& aDS = aCSI.DS();
   aNbS=aDS.NbShapes();
   //
   // 3. Get the pairs of interfered shapes
+#if OCC_VERSION_LARGE > 0x07010000
+  const BOPDS_MapOfPair& aMPK=aDS.Interferences();
+#else
   const BOPDS_MapOfPassKey& aMPK=aDS.Interferences();
+#endif  
   aItMPK.Initialize(aMPK);
   for (; aItMPK.More(); aItMPK.Next()) {
+#if OCC_VERSION_LARGE > 0x07010000
+    const BOPDS_Pair& aPK=aItMPK.Value();
+    aPK.Indices(n1, n2);
+#else      
     const BOPDS_PassKey& aPK=aItMPK.Value();
     aPK.Ids(n1, n2);
+#endif    
     //
     if (n1 > aNbS || n2 > aNbS){
       return false; // Error
index d5bf48b4f74e035b907390ae401095e1ab934e98..6fd616265cc2c2fa1dd067318308a5751356e83f 100644 (file)
@@ -105,7 +105,7 @@ Standard_Integer GEOMImpl_OffsetDriver::Execute(LOGBOOK& log) const
 
     if (aType == TopAbs_FACE || aType == TopAbs_SHELL) {
       // Create a thick solid.
-      BRepClass3d_SolidClassifier aClassifier = BRepClass3d_SolidClassifier(aShapeBase);
+      BRepClass3d_SolidClassifier aClassifier(aShapeBase);
       aClassifier.PerformInfinitePoint(Precision::Confusion());
       if (aClassifier.State()==TopAbs_IN)
       {
@@ -125,7 +125,7 @@ Standard_Integer GEOMImpl_OffsetDriver::Execute(LOGBOOK& log) const
 
       // Control the solid orientation. This is mostly done to fix a bug in case of extrusion
       // of a circle. The built solid is then badly oriented
-      BRepClass3d_SolidClassifier anotherClassifier = BRepClass3d_SolidClassifier(aShape);
+      BRepClass3d_SolidClassifier anotherClassifier(aShape);
       anotherClassifier.PerformInfinitePoint(Precision::Confusion());
       if (anotherClassifier.State()==TopAbs_IN)
       {
index f3bd9189aa12f6965ac7018e30ebd5d468c52b40..ca48f41bfb916b7de7b65bac5363b429515beccc 100644 (file)
@@ -117,11 +117,14 @@ static bool FillGroups(const TopTools_SequenceOfShape         *theGroups,
 static void StoreGroups(GEOMImpl_IPipe                   *theCI,
                         Handle(TColStd_HArray1OfInteger) *theGroups);
 
-static bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
-                     TopTools_SequenceOfShape    *theGroups);
+// after OCCT improvement
+static bool DoGroups1(const TopoDS_Shape          &theProfile,
+                     BRepOffsetAPI_MakePipeShell &theSweep,
+                     TopTools_SequenceOfShape    *theGroups);
 
-static bool CreateGroups(BRepOffsetAPI_MakePipeShell &theSweep,
-                         GEOMImpl_IPipe              *theCI);
+static bool CreateGroups1(const TopoDS_Shape          &theProfile,
+                         BRepOffsetAPI_MakePipeShell &theSweep,
+                         GEOMImpl_IPipe              *theCI);
 
 //=======================================================================
 //function : GetID
@@ -1068,7 +1071,8 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections
           // Make groups.
           TopTools_SequenceOfShape aGroups[5];
 
-          if (!DoGroups(aBuilder, aGroups)) {
+         TopoDS_Shape aProfile = aTmpSeqBases.Value(1);
+          if (!DoGroups1(aProfile, aBuilder, aGroups)) {
             Standard_ConstructionError::Raise("Generate groups failure");
           }
 
@@ -1130,7 +1134,8 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections
         // Make groups.
         TopTools_SequenceOfShape aGroups[5];
 
-        if (!DoGroups(aBuilder, aGroups)) {
+       TopoDS_Shape aProfile = aTmpSeqBases.Value(1);
+        if (!DoGroups1(aProfile, aBuilder, aGroups)) {
           Standard_ConstructionError::Raise("Generate groups failure");
         }
 
@@ -1277,7 +1282,8 @@ TopoDS_Shape GEOMImpl_PipeDriver::CreatePipeWithDifferentSections
           // Make groups.
           TopTools_SequenceOfShape aSeqGroups[5];
 
-          if (!DoGroups(aBuilder, aSeqGroups)) {
+         TopoDS_Shape aProfile = usedBases.Value(1);
+          if (!DoGroups1(aProfile, aBuilder, aSeqGroups)) {
             Standard_ConstructionError::Raise("Generate groups failure");
           }
 
@@ -1632,7 +1638,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath,
         // Create groups.
         if (isGenerateGroups) {
           // Make groups.
-          if (!DoGroups(aBuilder, aLocalGroups)) {
+          if (!DoGroups1(aWire1, aBuilder, aLocalGroups)) {
             if (aCI) delete aCI;
             Standard_ConstructionError::Raise("Generate groups failure");
           }
@@ -1919,7 +1925,7 @@ static TopoDS_Shape CreatePipeForShellSections(const TopoDS_Wire& aWirePath,
           // Create groups.
           if (isGenerateGroups) {
             // Make groups.
-            if (!DoGroups(aBuilder, aLocalGroups)) {
+            if (!DoGroups1(aWire1, aBuilder, aLocalGroups)) {
               if (aCI) delete aCI;
               Standard_ConstructionError::Raise("Generate groups failure");
             }
@@ -2603,7 +2609,7 @@ static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath,
       PipeBuilder.MakeSolid();
   }
 
-  if (!CreateGroups(PipeBuilder, aCIBN)) {
+  if (!CreateGroups1(aProf, PipeBuilder, aCIBN)) {
     if (aCIBN) delete aCIBN;
     Standard_ConstructionError::Raise("Generate groups failure");
   }
@@ -2738,11 +2744,12 @@ static bool CreateDownUpGroups(BRepPrimAPI_MakeSweep    *theSweep,
 }
 
 //=======================================================================
-//function : DoGroups
-//purpose  : auxilary for CreateGroups()
+//function : DoGroups1
+//purpose  : auxilary for CreateGroups1()
 //=======================================================================
-bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
-              TopTools_SequenceOfShape    *theGroups)
+bool DoGroups1 (const TopoDS_Shape          &theProfile,
+               BRepOffsetAPI_MakePipeShell &theSweep,
+               TopTools_SequenceOfShape    *theGroups)
 {
   Standard_Boolean isDoSides = Standard_False;
 
@@ -2751,7 +2758,8 @@ bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
     return false;
   }
 
-  const TopoDS_Shape aDownShape = theSweep.FirstShape();
+  TopoDS_Shape aDownShape = theProfile;
+  if (aDownShape.IsNull()) aDownShape = theSweep.FirstShape();
 
   if (isDoSides) {
     // Create Side1 and Side2 groups.
@@ -2782,8 +2790,15 @@ bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
               if (aMapFence.Add(aSideShape)) {
                 theGroups[anIdSide].Append(aSideShape);
               }
+            } else if (aSideShape.ShapeType() == TopAbs_WIRE) {
+              if (aMapFence.Add(aSideShape)) {
+               TopExp_Explorer anExpWE (aSideShape, TopAbs_EDGE);
+               for (; anExpWE.More(); anExpWE.Next()) {
+                 theGroups[anIdSide].Append(anExpWE.Current());
+               }
+             }
             } else {
-              // Only edges can be is Side1 and Side2 groups.
+              // Only edges can be in Side1 and Side2 groups.
               return false;
             }
           }
@@ -2791,7 +2806,7 @@ bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
       }
     }
   } else {
-    // Create Other group. Get boudnary edges of the profile.
+    // Create Other group. Get boundary edges of the profile.
     TopTools_MapOfShape aMapBndEdges;
     TopExp_Explorer     anExp(aDownShape, TopAbs_EDGE);
 
@@ -2820,6 +2835,13 @@ bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
             if (aMapFence.Add(anOtherShape)) {
               theGroups[GROUP_OTHER].Append(anOtherShape);
             }
+          } else if (anOtherShape.ShapeType() == TopAbs_SHELL) {
+            if (aMapFence.Add(anOtherShape)) {
+             TopExp_Explorer anExpSHF (anOtherShape, TopAbs_FACE);
+             for (; anExpSHF.More(); anExpSHF.Next()) {
+               theGroups[GROUP_OTHER].Append(anExpSHF.Current());
+             }
+            }
           } else {
             // Only faces can be in Other group.
             return false;
@@ -2833,11 +2855,12 @@ bool DoGroups(BRepOffsetAPI_MakePipeShell &theSweep,
 }
 
 //=======================================================================
-//function : CreateGroups
+//function : CreateGroups1
 //purpose  : auxilary for Execute()
 //=======================================================================
-bool CreateGroups(BRepOffsetAPI_MakePipeShell &theSweep,
-                  GEOMImpl_IPipe              *theCI)
+bool CreateGroups1 (const TopoDS_Shape          &theProfile,
+                   BRepOffsetAPI_MakePipeShell &theSweep,
+                   GEOMImpl_IPipe              *theCI)
 {
   if (!theCI->GetGenerateGroups()) {
     // Nothing to do.
@@ -2847,7 +2870,7 @@ bool CreateGroups(BRepOffsetAPI_MakePipeShell &theSweep,
   // Make groups.
   TopTools_SequenceOfShape aGroups[5];
 
-  if (!DoGroups(theSweep, aGroups)) {
+  if (!DoGroups1(theProfile, theSweep, aGroups)) {
     return false;
   }
 
@@ -2869,13 +2892,13 @@ bool CreateGroups(BRepOffsetAPI_MakePipeShell &theSweep,
 }
 
 //=======================================================================
-//function : DoGroups
+//function : DoGroups2
 //purpose  : auxilary for CreateGroups()
 //=======================================================================
-static bool DoGroups(const TopoDS_Shape             &theProfile,
-                     const TopoDS_Shape             &thePath,
-                           BRepOffsetAPI_MakePipe   &theSweep,
-                           TopTools_SequenceOfShape *theGroups)
+static bool DoGroups2(const TopoDS_Shape             &theProfile,
+                     const TopoDS_Shape             &thePath,
+                           BRepOffsetAPI_MakePipe   &theSweep,
+                            TopTools_SequenceOfShape *theGroups)
 {
   Standard_Boolean isDoSides = Standard_False;
 
@@ -2919,7 +2942,7 @@ static bool DoGroups(const TopoDS_Shape             &theProfile,
       }
     }
   } else {
-    // Create Other group. Get boudnary edges of the profile.
+    // Create Other group. Get boundary edges of the profile.
     TopTools_MapOfShape aMapBndEdges;
     TopExp_Explorer     anExp(theProfile, TopAbs_EDGE);
 
@@ -2960,10 +2983,10 @@ static bool DoGroups(const TopoDS_Shape             &theProfile,
 //function : CreateGroups
 //purpose  : auxilary for Execute()
 //=======================================================================
-static bool CreateGroups(const TopoDS_Shape     &theProfile,
-                         const TopoDS_Shape     &thePath,
-                         BRepOffsetAPI_MakePipe &theSweep,
-                         GEOMImpl_IPipe         *theCI)
+static bool CreateGroups2(const TopoDS_Shape     &theProfile,
+                         const TopoDS_Shape     &thePath,
+                         BRepOffsetAPI_MakePipe &theSweep,
+                         GEOMImpl_IPipe         *theCI)
 {
   if (!theCI->GetGenerateGroups()) {
     // Nothing to do.
@@ -2973,7 +2996,7 @@ static bool CreateGroups(const TopoDS_Shape     &theProfile,
   // Make groups.
   TopTools_SequenceOfShape aGroups[5];
 
-  if (!DoGroups(theProfile, thePath, theSweep, aGroups)) {
+  if (!DoGroups2(theProfile, thePath, theSweep, aGroups)) {
     return false;
   }
 
@@ -3093,21 +3116,21 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(LOGBOOK& log) const
     if (aShapeBase.ShapeType() == TopAbs_EDGE ||
         aShapeBase.ShapeType() == TopAbs_WIRE)
     {
-      TopoDS_Wire Profile;
+      TopoDS_Wire aProfile;
       if (aShapeBase.ShapeType() == TopAbs_WIRE)
-        Profile = TopoDS::Wire(aShapeBase);
+        aProfile = TopoDS::Wire(aShapeBase);
       else
       {
         BRep_Builder BB;
-        BB.MakeWire(Profile);
-        BB.Add(Profile, aShapeBase);
+        BB.MakeWire(aProfile);
+        BB.Add(aProfile, aShapeBase);
       }
 
       BRepOffsetAPI_MakePipeShell Sweep (aWirePath);
       BRepBuilderAPI_MakeFace FaceBuilder (aWirePath, Standard_True); //to find the plane of spine
       if (FaceBuilder.IsDone())
         Sweep.SetMode(FaceBuilder.Face());
-      Sweep.Add(Profile);
+      Sweep.Add(aProfile);
 
       Standard_Boolean isDone = BuildPipeShell(Sweep);
 
@@ -3119,7 +3142,7 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(LOGBOOK& log) const
       else
         aShape = Sweep.Shape(); //result is good
 
-      if (!CreateGroups(Sweep, aCI)) {
+      if (!CreateGroups1(aProfile, Sweep, aCI)) {
         if (aCI) delete aCI;
         Standard_ConstructionError::Raise("Generate groups failure");
       }
@@ -3133,7 +3156,7 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(LOGBOOK& log) const
       if (aMkPipe.IsDone() && aMkPipe.ErrorOnSurface() <= TolPipeSurf) {
         aShape = aMkPipe.Shape();
 
-        if (!CreateGroups(aShapeBase, aWirePath, aMkPipe, aCI)) {
+        if (!CreateGroups2(aShapeBase, aWirePath, aMkPipe, aCI)) {
           if (aCI) delete aCI;
           Standard_ConstructionError::Raise("Generate groups failure");
         }
@@ -3145,7 +3168,7 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(LOGBOOK& log) const
         if (aMkPipeDescrete.IsDone()) {
           aShape = aMkPipeDescrete.Shape();
 
-          if (!CreateGroups(aShapeBase, aWirePath, aMkPipeDescrete, aCI)) {
+          if (!CreateGroups2(aShapeBase, aWirePath, aMkPipeDescrete, aCI)) {
             if (aCI) delete aCI;
             Standard_ConstructionError::Raise("Generate groups failure");
           }
index a5e9d98fe3d11c21d9023e7f4a936f4664c922da..002ae127ebeaf69b33878911e2d087acb6f604c3 100644 (file)
@@ -90,54 +90,61 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
   QMap<QString, GEOM::GEOM_BaseObject_var> gobjects;
   QMap<QString, QString>::ConstIterator oit;
   std::list<_PTR(SObject)> aSelectedSO;
-  for ( oit = objects.begin(); oit != objects.end(); ++oit ) {
+  for ( oit = objects.begin(); oit != objects.end(); ++oit )
+  {
     _PTR(SObject) so = study->FindObjectID( oit.key().toLatin1().data() );
     if ( !so )
       continue;
     aSelectedSO.push_back(so);
-    CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject( so );
+    CORBA::Object_var        corbaObj_rem = GeometryGUI::ClientSObjectToObject( so );
     GEOM::GEOM_BaseObject_var geomObj_rem = GEOM::GEOM_BaseObject::_narrow( corbaObj_rem );
-    if( CORBA::is_nil( geomObj_rem ) )
-      continue;
-    gobjects.insert( oit.key(), geomObj_rem );
+    if ( ! CORBA::is_nil( geomObj_rem ))
+      gobjects.insert( oit.key(), geomObj_rem );
   }
 
   // Search References with other Modules
   std::list< _PTR(SObject) >::iterator itSO = aSelectedSO.begin();
-  for ( ; itSO != aSelectedSO.end(); ++itSO ) {
+  for ( ; itSO != aSelectedSO.end(); ++itSO )
+  {
     std::vector<_PTR(SObject)> aReferences = study->FindDependances( *itSO  );
     int aRefLength = aReferences.size();
-    if (aRefLength) {
-      for (int i = 0; i < aRefLength; i++) {
-        _PTR(SObject) firstSO( aReferences[i] );
-        _PTR(SComponent) aComponent = firstSO->GetFatherComponent();
-        QString type = aComponent->ComponentDataType().c_str();
-        if ( type == "SMESH" )
-          return true;
-      }
+    for ( int i = 0; i < aRefLength; i++ )
+    {
+      _PTR(SObject) firstSO( aReferences[i] );
+      _PTR(SComponent) aComponent = firstSO->GetFatherComponent();
+      QString type = aComponent->ComponentDataType().c_str();
+      if ( type == "SMESH" )
+        return true;
     }
   }
 
-  // browse through all GEOM data tree
+  // browse through all GEOM data tree to find an object with is not deleted and depends
+  // on a deleted object
   _PTR(ChildIterator) it ( study->NewChildIterator( comp ) );
-  for ( it->InitEx( true ); it->More(); it->Next() ) {
-    _PTR(SObject) child( it->Value() );
-    CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
+  for ( it->InitEx( true ); it->More(); it->Next() )
+  {
+    _PTR(SObject) child   = it->Value();
+    QString       childID = child->GetID().c_str();
+    bool deleted = objects.contains( childID );
+    if ( deleted )
+      continue; // deleted object
+
+    CORBA::Object_var    corbaObj = GeometryGUI::ClientSObjectToObject( child );
     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
-    if( CORBA::is_nil( geomObj ) )
+    if ( CORBA::is_nil( geomObj ) )
       continue;
 
-    GEOM::ListOfGBO_var list = geomObj->GetDependency();
-    if( list->length() == 0 )
-      continue;
+    GEOM::ListOfGBO_var dep = geomObj->GetDependency(); // child depends on dep
+    for( CORBA::ULong i = 0; i < dep->length(); i++ )
+    {
+      CORBA::String_var id = dep[i]->GetStudyEntry();
+      bool depends = objects.contains( id.in() ); // depends on deleted
 
-    for( int i = 0; i < list->length(); i++ ) {
-      bool depends = false;
-      bool deleted = false;
       QMap<QString, GEOM::GEOM_BaseObject_var>::Iterator git;
-      for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git ) {
-        depends = depends || list[i]->_is_equivalent( *git );
-        deleted = deleted || git.key() == child->GetID().c_str() ;//geomObj->_is_equivalent( *git );
+      for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git )
+      {
+        depends = depends || dep[i]->_is_equivalent( *git );
+        deleted = deleted || git.key() == childID ;//geomObj->_is_equivalent( *git )
       }
       if ( depends && !deleted )
         return true;
@@ -150,8 +157,8 @@ static bool inUse( _PTR(Study) study, const QString& component, const QMap<QStri
 // function : getGeomChildrenAndFolders
 // purpose  : Get direct (1-level) GEOM objects under each folder, sub-folder, etc. and these folders itself
 //=======================================================================
-static void getGeomChildrenAndFolders( _PTR(SObject) theSO, 
-                                       QMap<QString,QString>& geomObjList, 
+static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
+                                       QMap<QString,QString>& geomObjList,
                                        QMap<QString,QString>& folderList ) {
   if ( !theSO ) return;
   _PTR(Study) aStudy = theSO->GetStudy();
@@ -182,7 +189,7 @@ static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
 // purpose  : Constructor
 //=======================================================================
 GEOMToolsGUI::GEOMToolsGUI( GeometryGUI* parent )
-: GEOMGUI( parent )
+  : GEOMGUI( parent )
 {
 }
 
@@ -444,6 +451,8 @@ void GEOMToolsGUI::OnEditDelete()
   if ( !dlg.exec() )
     return; // operation is cancelled by user
 
+  SUIT_OverrideCursor wc;
+
   // get currently opened views
   QList<SALOME_View*> views;
   SALOME_View* view;
@@ -457,7 +466,8 @@ void GEOMToolsGUI::OnEditDelete()
   }
 
   _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
-  GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
+  GEOM_Displayer disp( appStudy );
+  disp.SetUpdateColorScale( false ); // IPAL54049
 
   if ( isComponentSelected ) {
     // GEOM component is selected: delete all objects recursively
@@ -469,7 +479,7 @@ void GEOMToolsGUI::OnEditDelete()
     for ( it->InitEx( false ); it->More(); it->Next() ) {
       _PTR(SObject) child( it->Value() );
       // remove object from GEOM engine
-      removeObjectWithChildren( child, aStudy, views, disp );
+      removeObjectWithChildren( child, aStudy, views, &disp );
       // remove object from study
       aStudyBuilder->RemoveObjectWithChildren( child );
       // remove object from use case tree
@@ -491,7 +501,7 @@ void GEOMToolsGUI::OnEditDelete()
     for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
       _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
       // remove object from GEOM engine
-      removeObjectWithChildren( obj, aStudy, views, disp );
+      removeObjectWithChildren( obj, aStudy, views, &disp );
       // remove objects from study
       aStudyBuilder->RemoveObjectWithChildren( obj );
       // remove object from use case tree
@@ -501,7 +511,7 @@ void GEOMToolsGUI::OnEditDelete()
     for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) {
       _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
       // remove object from GEOM engine
-      removeObjectWithChildren( obj, aStudy, views, disp );
+      removeObjectWithChildren( obj, aStudy, views, &disp );
       // remove objects from study
       aStudyBuilder->RemoveObjectWithChildren( obj );
       // remove object from use case tree
index 5b4273c95d79eb549b4b12a5773092620e5f9a7a..67ed48db00f64a89c735feb6d1e03796e5086f18 100644 (file)
@@ -530,6 +530,8 @@ void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
           return;
         }
 
+        SUIT_OverrideCursor wc;
+        disp->SetUpdateColorScale( false ); // IPAL54049
         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
           Handle(SALOME_InteractiveObject) IObject = It.Value();
 
@@ -538,10 +540,12 @@ void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
           if ( obj ) {
             _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
             aExp->SetExpandable( show );
-            if(!show)
+            if ( !show ) {
               disp->EraseWithChildren(IObject,true);
+            }
           } // if ( obj )
         } // iterator
+        disp->SetUpdateColorScale( true );
       }
     }
     app->updateObjectBrowser( false );
@@ -593,7 +597,8 @@ void GEOMToolsGUI::OnUnpublishObject() {
                                     QObject::tr( "WRN_STUDY_LOCKED" ) );
           return;
         }
-
+        SUIT_OverrideCursor wc;
+        disp->SetUpdateColorScale( false ); // IPAL54049
         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
           Handle(SALOME_InteractiveObject) IObject = It.Value();
 
@@ -612,6 +617,7 @@ void GEOMToolsGUI::OnUnpublishObject() {
             }
           } // if ( obj )
         } // iterator
+        disp->SetUpdateColorScale( true ); // IPAL54049
         aSelMgr->clearSelected();
       }
     }
@@ -857,7 +863,7 @@ void GEOMToolsGUI::OnCreateFolder()
   if ( !aFatherSO ) return;
 
   GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toLatin1().constData(), 
-                                          _CAST(SObject, aFatherSO)->GetSObject() );
+                                           _CAST(SObject, aFatherSO)->GetSObject() );
   app->updateObjectBrowser( false );
 }
 
@@ -891,7 +897,7 @@ void GEOMToolsGUI::OnSortChildren()
 #ifndef DISABLE_GRAPHICSVIEW
 void GEOMToolsGUI::OnShowDependencyTree()
 {
-  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  //SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
 
   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
   if ( !app ) return;
index 3c08a30ba7334c05e2fc78cf6f1cd71076313563..d983d5cc86d178db525b2cc6bd8b3518c5d27d27 100644 (file)
 #include <QGridLayout>
 #include <SUIT_MessageBox.h>
  
-static bool isEntryLess( const QString& e1, const QString& e2 )
+#include <iostream>
+
+namespace
 {
-  QStringList el1 = e1.split(":");
-  QStringList el2 = e2.split(":");
-  int e1c = el1.count(), e2c = el2.count();
-  for ( int i = 0; i < e1c && i < e2c; i++ ) {
-    int id1 = el1[i].toInt();
-    int id2 = el2[i].toInt();
-    if ( id1 < id2 ) return true;
-    else if ( id2 < id1 ) return false;
-  }
-  return el1.count() < el2.count();
+  struct NaturalCompare
+  {
+    bool operator () (const std::string& s1, const std::string& s2) const
+    {
+      // hope the entries are never empty and never equal
+      int diff21 = 0;
+      const char* p1 = s1.c_str();
+      const char* p2 = s2.c_str();
+      for ( ; ; ++p1, ++p2 )
+      {
+        if ( *p1 == *p2 )
+        {
+          if ( diff21 && !*p1 ) // both numbers ends
+            return diff21 > 0;
+          continue;
+        }
+        // different chars
+        bool d1 = isdigit( *p1 );
+        bool d2 = isdigit( *p2 );
+        if ( d1 != d2 ) // one number is shorter then another
+          return d2; // is s1 shorter?
+        if ( !d1 && diff21 ) // both numbers ends
+          return diff21 > 0;
+        if ( !diff21 ) // remember the first difference
+          diff21 = *p2 - *p1;
+      }
+      return diff21 > 0;
+    }
+  };
 }
 
 static QStringList objectsToNames( const QMap<QString, QString>& objects )
 {
-  QStringList entries;
-  for ( QMap<QString, QString>::ConstIterator it = objects.begin(); it != objects.end(); ++it ) {
-    QString entry = it.key();
-    QStringList::Iterator iter;
-    bool added = false;
-    for ( iter = entries.begin(); iter != entries.end() && !added; ++iter ) {
-      if ( isEntryLess( entry, *iter ) ) {
-        entries.insert( iter, entry );
-        added = true;
-      }
-    }
-    if ( !added ) 
-      entries.append( entry );
-  }
+  typedef std::map< std::string, QString, NaturalCompare > TSortMap;
+  TSortMap sortedByEntry;
+  for ( QMap<QString, QString>::ConstIterator it = objects.begin(); it != objects.end(); ++it )
+    sortedByEntry.insert( sortedByEntry.end(), std::make_pair( it.key().toStdString(), it.value() ));
+
   QStringList names;
-  for ( int i = 0; i < entries.count(); i++ ) {
-    int level = entries[i].count(":")-3;
-    names.append( QString( level*2, ' ' ) + objects[ entries[i] ] );
+  for ( TSortMap::iterator it = sortedByEntry.begin(); it != sortedByEntry.end(); ++it )
+  {
+    const std::string& entry = it->first;
+    int level = std::count( entry.begin(), entry.end(), ':' ) - 3;
+    names.append( QString( level * 2, ' ' ) + it->second );
   }
   return names;
 }
index f187e4956096bb460f5787f97d8264406c0efd12..bc62c01c0d4c538964b2864224cc3f45c818c15f 100644 (file)
@@ -778,7 +778,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::SelectionIntoArgument()
   if ( study ) {
     SALOME_ListIO aSelList;
     aSelMgr->selectedObjects(aSelList);
-                int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
-        }
+    /*int nbSel = */GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
+  }
   myLineEditCurArg->setText( aString );
 }
index 0984331aaa94d46c3217217d39485870b38df33a..ec83532bcbae3bd2d4dadc7309d08e8a8fb8bc60 100644 (file)
@@ -141,22 +141,22 @@ GEOMToolsGUI_PublishDlg::~GEOMToolsGUI_PublishDlg()
     if ( appStudy ) {
       _PTR(Study) aStudy = appStudy->studyDS();
       if ( aStudy ) {
-       GEOM_Displayer displayer ( appStudy );
-       QTreeWidgetItemIterator it( myTreeWidget );
-       while ( *it ) {
-         QString entry = myEntryToItem.key( *it );
-         _PTR(SObject) SO ( aStudy->FindObjectID( qPrintable( entry ) ) );
-         if ( SO ) {
-           GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
-           if ( CORBA::is_nil( aGeomObject ) ) continue;
-           if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {
-             Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
-             displayer.Erase( io );
-           }
-         }
-         ++it;
-       }
-       displayer.UpdateViewer();
+        GEOM_Displayer displayer ( appStudy );
+        QTreeWidgetItemIterator it( myTreeWidget );
+        while ( *it ) {
+          QString entry = myEntryToItem.key( *it );
+          _PTR(SObject) SO ( aStudy->FindObjectID( qPrintable( entry ) ) );
+          if ( SO ) {
+            GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( SO ) );
+            if ( CORBA::is_nil( aGeomObject ) ) continue;
+            if ( displayer.IsDisplayed( aGeomObject->GetStudyEntry() ) ) {
+              Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( aGeomObject->GetStudyEntry(), "GEOM", "" );
+              displayer.Erase( io );
+            }
+          }
+          ++it;
+        }
+        displayer.UpdateViewer();
       }
     }
   }
@@ -346,10 +346,10 @@ void GEOMToolsGUI_PublishDlg::clickOnApply() {
       }
       // show references if any
       std::vector< _PTR(SObject) > vso = aStudy->FindDependances(SO);
-      for ( int i = 0; i < vso.size(); i++ ) {
-       _PTR(SObject) refObj = vso[i];
-       aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
-       aDrw->SetDrawable( true );
+      for ( size_t i = 0; i < vso.size(); i++ ) {
+        _PTR(SObject) refObj = vso[i];
+        aDrw = aBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
+        aDrw->SetDrawable( true );
       }
     }
   }
index 2c85a3441300916069e956adf52fc0679300b037..d5b11a3fc18728322e33a51d65caea203d236362 100644 (file)
@@ -165,8 +165,8 @@ void GEOMToolsGUI_ReduceStudyDlg::init( const std::set<std::string>& theObjectEn
   GEOM::string_array_var otherObjects = new GEOM::string_array();
 
   GeometryGUI::GetGeomGen()->GetEntriesToReduceStudy( GeometryGUI::ClientStudyToStudy( myStudy ),
-                                                            keptObjects, parentsObjects,
-                                                            subObjects, otherObjects );
+                                                             keptObjects, parentsObjects,
+                                                             subObjects, otherObjects );
 
   for ( int i = 0; i < keptObjects->length(); i++ )
     myKeptObjects.insert( keptObjects[i].in() );
@@ -349,7 +349,7 @@ void GEOMToolsGUI_ReduceStudyDlg::checkVisibleIcon( QTreeWidget* theWidget )
   QTreeWidgetItemIterator it( theWidget );
   while(*it) {
     GEOMToolsGUI_TreeWidgetItem* item = dynamic_cast<GEOMToolsGUI_TreeWidgetItem*>(*it);
-    const char* entry = item->getStudyEntry();
+    //const char* entry = item->getStudyEntry();
     if( item->flags() & Qt::ItemIsSelectable )
       if( !item->isVisible() )
         isInvisible = true;
@@ -658,11 +658,11 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
   }
   if( myGroupIntermediates->checkedId() == 2 ) { // remove
     if( !myCBSoftRemoval->isChecked() && 
-       SUIT_MessageBox::question( this,
-                                  tr( "GEOM_WRN_WARNING" ),
-                                  tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
-                                  QMessageBox::Yes | QMessageBox::No,
-                                  QMessageBox::Yes ) == QMessageBox::No ) {
+        SUIT_MessageBox::question( this,
+                                   tr( "GEOM_WRN_WARNING" ),
+                                   tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
+                                   QMessageBox::Yes | QMessageBox::No,
+                                   QMessageBox::Yes ) == QMessageBox::No ) {
       return;
     }
     for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
index ab91abb4c3d6dd60ef87ca84eb97064aa1114f1a..3c4fc7f62a63caf212f4b7c4add631edd1a579b9 100644 (file)
@@ -262,7 +262,7 @@ namespace
         levelsListStr.push_back( substr );
     }
     GEOMUtils::LevelsList levelsListData;
-    for( int level = 0; level < levelsListStr.size(); level++ ) {
+    for( size_t level = 0; level < levelsListStr.size(); level++ ) {
       std::vector<std::string> namesListStr;
       std::stringstream ss1( levelsListStr[level] );
       while ( std::getline( ss1, substr, ',' ) ) {
@@ -270,7 +270,7 @@ namespace
           namesListStr.push_back( substr );
       }
       GEOMUtils::LevelInfo levelInfoData;
-      for( int node = 0; node < namesListStr.size(); node++ ) {
+      for( size_t node = 0; node < namesListStr.size(); node++ ) {
         std::vector<std::string> linksListStr;
         std::stringstream ss2( namesListStr[node] );
         while ( std::getline( ss2, substr, '_' ) ) {
@@ -280,7 +280,7 @@ namespace
         std::string nodeItem = linksListStr[0];
         if( !nodeItem.empty() ) {
           GEOMUtils::NodeLinks linksListData;
-          for( int link = 1; link < linksListStr.size(); link++ ) {
+          for( size_t link = 1; link < linksListStr.size(); link++ ) {
             std::string linkItem = linksListStr[link];
             linksListData.push_back( linkItem );
           }// Links
@@ -1083,7 +1083,7 @@ void GEOMUtils::ConvertStringToTree( const std::string& dependencyStr,
     cursor = objectIndex;
 
     std::size_t upwardIndexBegin = dependencyStr.find("{",cursor) + 1;
-    std::size_t upwardIndexFinish = dependencyStr.find("}",upwardIndexBegin);
+    //std::size_t upwardIndexFinish = dependencyStr.find("}",upwardIndexBegin);
     LevelsList upwardList = parseWard( dependencyStr, cursor );
 
     LevelsList downwardList = parseWard( dependencyStr, cursor );
index 7d9f430e75935860543776b56f1e3815cb62896b..797d9da7603431bc1d7dc1d4190361f28a239396 100644 (file)
@@ -35,8 +35,8 @@ namespace GEOMUtils
 // purpose  : gets measures of the given type for list of shapes in the range
 //=================================================================================
   std::map<int,double> ComputeMeasures( std::list<TopoDS_Shape> shapes, 
-                             TopAbs_ShapeEnum entity, 
-                             Range &range)
+                              TopAbs_ShapeEnum entity, 
+                              Range &range)
 {
   bool hasRange = (range.min != -1.0); // -1.0 means that range must not be used
   if ( !hasRange )
@@ -60,23 +60,23 @@ namespace GEOMUtils
       //Get the measure: length, area or volume
       GProp_GProps LProps, SProps, VProps;
       if ( entity == TopAbs_EDGE ) {
-       BRepGProp::LinearProperties( aSubShape, LProps );
-       aMeasure = LProps.Mass();
+        BRepGProp::LinearProperties( aSubShape, LProps );
+        aMeasure = LProps.Mass();
       } else if ( entity == TopAbs_FACE ) {
-       BRepGProp::SurfaceProperties( aSubShape, SProps );
-       aMeasure = SProps.Mass();
+        BRepGProp::SurfaceProperties( aSubShape, SProps );
+        aMeasure = SProps.Mass();
       } else if ( entity == TopAbs_SOLID ) {
-       BRepGProp::VolumeProperties( aSubShape, VProps );
-       aMeasure = VProps.Mass();
+        BRepGProp::VolumeProperties( aSubShape, VProps );
+        aMeasure = VProps.Mass();
       }
       // Don't pass sub-shapes with out of range measure, if range is used
       if ( hasRange ) {
-       if ( aMeasure < range.min || aMeasure > range.max )
-         continue;
+        if ( aMeasure < range.min || aMeasure > range.max )
+          continue;
       } else {
-       // get range min and max
-       if ( aMeasure < range.min ) range.min = aMeasure;
-       if ( aMeasure > range.max ) range.max = aMeasure;
+        // get range min and max
+        if ( aMeasure < range.min ) range.min = aMeasure;
+        if ( aMeasure > range.max ) range.max = aMeasure;
       }
       // get global index of sub-shape
       index = aSubShapesMap.FindIndex( aSubShape );
@@ -93,9 +93,9 @@ namespace GEOMUtils
 // purpose  : gets distribution data for single shape
 //=================================================================================
 Distribution ComputeDistribution( TopoDS_Shape shape, 
-                                 TopAbs_ShapeEnum entity, 
-                                 int intervals, 
-                                 Range range)
+                                  TopAbs_ShapeEnum entity, 
+                                  int intervals, 
+                                  Range range)
 {
   std::list<TopoDS_Shape> aShapes;
   aShapes.push_back( shape );
@@ -107,9 +107,9 @@ Distribution ComputeDistribution( TopoDS_Shape shape,
 // purpose  : gets distribution data for list of shapes
 //=================================================================================
 Distribution ComputeDistribution( std::list<TopoDS_Shape> shapes, 
-                                 TopAbs_ShapeEnum entity, 
-                                 int nbIntervals, 
-                                 Range range)
+                                  TopAbs_ShapeEnum entity, 
+                                  int nbIntervals, 
+                                  Range range)
 {
   // get list of measures and compute range (if it was not specified)
   std::map<int,double> measures = ComputeMeasures( shapes, entity, range );
@@ -129,15 +129,15 @@ Distribution ComputeDistribution( std::list<TopoDS_Shape> shapes,
     std::vector<int> indicesToErase;
     for ( dit = measures.begin(); dit != measures.end(); dit++ ) {
       if ( ( dit->second >= localRange.min && dit->second < localRange.max ) || 
-          ( i == nbIntervals-1 && dit->second == localRange.max ) ) {
-       localRange.count++;
-       localRange.indices.push_back( dit->first );
-       // measure is in interval, so remove it from map of search
-       indicesToErase.push_back( dit->first );
+           ( i == nbIntervals-1 && dit->second == localRange.max ) ) {
+        localRange.count++;
+        localRange.indices.push_back( dit->first );
+        // measure is in interval, so remove it from map of search
+        indicesToErase.push_back( dit->first );
       }
     }
     aDistr.push_back( localRange );
-    for( int j=0; j < indicesToErase.size(); j++ )
+    for( size_t j=0; j < indicesToErase.size(); j++ )
       measures.erase( indicesToErase[j] );
   }
 
index 5671eed6341d009c621ba5964dcf3305a0bbeb32..dee3492cbb604a0620a3f037ba9c0e4cb86ff17d 100644 (file)
@@ -137,6 +137,7 @@ namespace
     return xmlPaths;
   }
 
+#ifdef MYDEBUG
   void dumpinfo(const GEOMUtils::PluginInfo& info)
   {
     printf("DUMPING PLUGIN INFO\n");
@@ -160,6 +161,7 @@ namespace
       printf("-----\n");
     }
   }
+#endif
 }
 
 namespace GEOMUtils
index aac522ccc1e88900bd8dc5f3fdf432ebd210e126..78212462407efdcbea25351051e5b8359daf157f 100644 (file)
@@ -2499,12 +2499,15 @@ GEOM::GEOM_IOperations_ptr GEOM_Gen_i::GetPluginOperations(CORBA::Long theStudyI
 void GEOM_Gen_i::LoadPlugin(const std::string& theLibName)
 {
   std::string aPlatformLibName;
-#ifdef WIN32
-  aPlatformLibName = theLibName;
-  aPlatformLibName += ".dll" ;
-#else
+#if !defined(WIN32)
   aPlatformLibName = "lib";
+#endif
   aPlatformLibName += theLibName;
+#if defined(WIN32)
+  aPlatformLibName += ".dll" ;
+#elif defined(__APPLE__)
+  aPlatformLibName += ".dylib";
+#else
   aPlatformLibName += ".so";
 #endif
 
index 2984de3afce8e2d6ccfef6608c256ca07a4ace5c..1ba00706701b224ca09039e8260511457344e0b0 100644 (file)
@@ -3633,12 +3633,14 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ImportIGES( const char* theFileName,
 CORBA::Boolean GEOM_Superv_i::ExportXAO( GEOM::GEOM_Object_ptr shape,
                                          const GEOM::ListOfGO& groups,
                                          const GEOM::ListOfFields& fields,
-                                         const char* author, const char* fileName )
+                                         const char* author,
+                                         const char* fileName,
+                                         const char* shapeFileName )
 {
   beginService( " GEOM_Superv_i::ExportXAO" );
   MESSAGE("GEOM_Superv_i::ExportXAO");
   getXAOPluginOp();
-  CORBA::Boolean isGood = myXAOOp->ExportXAO( shape, groups, fields, author, fileName );
+  CORBA::Boolean isGood = myXAOOp->ExportXAO( shape, groups, fields, author, fileName, shapeFileName );
   endService( " GEOM_Superv_i::ExportXAO" );
   return isGood;
 }
index 594215cc4d3d4b6221e5313e5fd681cc42bf609b..8d712acdeb27ebf049dbeb8967b60d28b3670c9d 100644 (file)
@@ -744,7 +744,8 @@ public:
                             const GEOM::ListOfGO& groups,
                             const GEOM::ListOfFields& fields,
                             const char* author,
-                            const char* fileName);
+                            const char* fileName,
+                            const char* shapeFileName);
   CORBA::Boolean ImportXAO( const char* fileName,
                             GEOM::GEOM_Object_out shape,
                             GEOM::ListOfGO_out subShapes,
index aeffc075ed7c945552ae0f1cf7ea3b4d51ffac9e..84a0945d65e796e82ed787f78769e78b90874408 100644 (file)
@@ -33,10 +33,11 @@ def GetXAOPluginOperations(self):
 #  @param fields The list of fields to export
 #  @param author The author of the file
 #  @param fileName The name of the file to export
+#  @param shapeFileName The name of the BRep file to export
 #  @return True if operation is successful or False otherwise
 #
 #  @ingroup l2_import_export
-def ExportXAO(self, shape, groups, fields, author, fileName):
+def ExportXAO(self, shape, groups, fields, author, fileName, shapeFileName = ""):
     """
     Export a shape to XAO format
     
@@ -52,7 +53,7 @@ def ExportXAO(self, shape, groups, fields, author, fileName):
     """
     from salome.geom.geomBuilder import RaiseIfFailed
     anOp = GetXAOPluginOperations(self)
-    res = anOp.ExportXAO(shape, groups, fields, author, fileName)
+    res = anOp.ExportXAO(shape, groups, fields, author, fileName, shapeFileName)
     RaiseIfFailed("ExportXAO", anOp)
     return res
 
index 197429e4eb51bb90d7c30bd0290a3f34ed0101ef..5de7403b30c000a3a5761f8dced603a1f75fc53c 100644 (file)
@@ -3919,8 +3919,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
         #         publication is switched on, default value is used for result name.
         #
         #  @return New GEOM.GEOM_Object, containing the created pipe if 
-        #          \a IsGenerateGroups is not set. Otherwise it returns new
-        #          GEOM.ListOfGO. Its first element is the created pipe, the
+        #          \a IsGenerateGroups is not set. Otherwise it returns a
+        #          list of GEOM.GEOM_Object. Its first element is the created pipe, the
         #          remaining ones are created groups.
         #
         #  @ref tui_creation_pipe "Example"
@@ -3959,8 +3959,8 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
 
             Returns:
                 New GEOM.GEOM_Object, containing the created pipe if 
-                IsGenerateGroups is not set. Otherwise it returns new
-                GEOM.ListOfGO. Its first element is the created pipe, the
+                IsGenerateGroups is not set. Otherwise it returns a
+                list of GEOM.GEOM_Object. Its first element is the created pipe, the
                 remaining ones are created groups.
             """
             # Example: see GEOM_TestAll.py
index f775a93b579f6fe5f130cf5b2b56917cb32f3ac4..1e9f9ac6391a3ec109a974561ea58ee9f2606347 100644 (file)
@@ -116,97 +116,97 @@ bool IGESPlugin_GUI::importIGES( SUIT_Desktop* parent )
   if ( igesOp.isNull() ) return false;
 
   QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
-                                                tr( "IGES_FILES" ),
-                                                tr( "IMPORT_TITLE" ),
-                                                parent );
+                                                 tr( "IGES_FILES" ),
+                                                 tr( "IMPORT_TITLE" ),
+                                                 parent );
   if ( fileNames.count() > 0 )
   {
     QStringList entryList;
     QStringList errors;
     SUIT_MessageBox::StandardButton igesAnswer = SUIT_MessageBox::NoButton;
-    
+
     for ( int i = 0; i < fileNames.count(); i++ )
     {
       QString fileName = fileNames.at( i );
       SUIT_OverrideCursor wc;
       GEOM_Operation transaction( app, igesOp.get() );
       bool ignoreUnits = false;
-      
+
       try
       {
-       app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, true ) ) );
-       transaction.start();
-       
-       CORBA::String_var units = igesOp->ReadValue( fileName.toUtf8().constData(), "LEN_UNITS" );
-       QString unitsStr( units.in() );
-       bool unitsOK = unitsStr.isEmpty() || unitsStr == "M" || unitsStr.toLower() == "metre";
-       
-       if ( !unitsOK )
-       {
-         if( igesAnswer == SUIT_MessageBox::NoToAll )
-         {
-           ignoreUnits = true;
-         }
-         else if( igesAnswer != SUIT_MessageBox::YesToAll )
-         {
-           SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel;
-           if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
-           igesAnswer = SUIT_MessageBox::question( parent,
-                                                   tr( "WRN_WARNING" ),
-                                                   tr( "SCALE_DIMENSIONS" ).arg( unitsStr ),
-                                                   btns,
-                                                   SUIT_MessageBox::No );
-           switch ( igesAnswer )
-           {
-           case SUIT_MessageBox::Cancel:
-             return true;             // cancel (break) import operation
-           case SUIT_MessageBox::Yes:
-           case SUIT_MessageBox::YesToAll:
-             break;                   // scaling is confirmed
-           case SUIT_MessageBox::No:
-           case SUIT_MessageBox::NoAll:
-             ignoreUnits = true;      // scaling is rejected
-           default:
-             break;
-           }
-         }
-       }
-       
-       GEOM::ListOfGO_var result = igesOp->ImportIGES( fileName.toUtf8().constData(), ignoreUnits );
-       if ( result->length() > 0 && igesOp->IsDone() )
-       {
-         GEOM::GEOM_Object_var main = result[0];
-         QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
-         SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
-                                                                               SALOMEDS::SObject::_nil(),
-                                                                               main.in(),
-                                                                               publishName.toUtf8().constData() );
-         
-         entryList.append( so->GetID() );
-         transaction.commit();
-         GEOM_Displayer( study ).Display( main.in() );
+        app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( SUIT_Tools::file( fileName, true ) ) );
+        transaction.start();
+
+        CORBA::String_var units = igesOp->ReadValue( fileName.toUtf8().constData(), "LEN_UNITS" );
+        QString unitsStr( units.in() );
+        bool unitsOK = unitsStr.isEmpty() || unitsStr == "M" || unitsStr.toLower() == "metre";
+
+        if ( !unitsOK )
+        {
+          if( igesAnswer == SUIT_MessageBox::NoToAll )
+          {
+            ignoreUnits = true;
+          }
+          else if( igesAnswer != SUIT_MessageBox::YesToAll )
+          {
+            SUIT_MessageBox::StandardButtons btns = SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel;
+            if ( i < fileNames.count()-1 ) btns = btns | SUIT_MessageBox::YesToAll | SUIT_MessageBox::NoToAll;
+            igesAnswer = SUIT_MessageBox::question( parent,
+                                                    tr( "WRN_WARNING" ),
+                                                    tr( "SCALE_DIMENSIONS" ).arg( unitsStr ),
+                                                    btns,
+                                                    SUIT_MessageBox::No );
+            switch ( igesAnswer )
+            {
+            case SUIT_MessageBox::Cancel:
+              return true;             // cancel (break) import operation
+            case SUIT_MessageBox::Yes:
+            case SUIT_MessageBox::YesToAll:
+              break;                   // scaling is confirmed
+            case SUIT_MessageBox::No:
+            case SUIT_MessageBox::NoAll:
+              ignoreUnits = true;      // scaling is rejected
+            default:
+              break;
+            }
+          }
+        }
+
+        GEOM::ListOfGO_var result = igesOp->ImportIGES( fileName.toUtf8().constData(), ignoreUnits );
+        if ( result->length() > 0 && igesOp->IsDone() )
+        {
+          GEOM::GEOM_Object_var main = result[0];
+          QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
+          SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
+                                                                                SALOMEDS::SObject::_nil(),
+                                                                                main.in(),
+                                                                                publishName.toUtf8().constData() );
+
+          entryList.append( so->GetID() );
+          transaction.commit();
+          GEOM_Displayer( study ).Display( main.in() );
           main->UnRegister();
-       }
-       else
-       {
-         transaction.abort();
-         errors.append( QString( "%1 : %2" ).arg( fileName ).arg( igesOp->GetErrorCode() ) );
-       }
+        }
+        else
+        {
+          transaction.abort();
+          errors.append( QString( "%1 : %2" ).arg( fileName ).arg( igesOp->GetErrorCode() ) );
+        }
       }
       catch( const SALOME::SALOME_Exception& e )
       {
-       transaction.abort();
+        transaction.abort();
       }
     }
 
     getGeometryGUI()->updateObjBrowser( true );
     app->browseObjects( entryList );
-          
+
     if ( errors.count() > 0 )
     {
       SUIT_MessageBox::critical( parent,
-                                tr( "GEOM_ERROR" ),
-                                tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+                                 tr( "GEOM_ERROR" ),
+                                 tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
     }
   }
   return fileNames.count() > 0;
@@ -245,10 +245,10 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent )
 
     QString version;
     QString fileName = IGESPlugin_ExportDlg::getFileName( QString( io->getName() ),
-                                                         tr( "IGES_FILES" ),
-                                                         tr( "EXPORT_TITLE" ),
-                                                         parent,
-                                                         version );
+                                                          tr( "IGES_FILES" ),
+                                                          tr( "EXPORT_TITLE" ),
+                                                          parent,
+                                                          version );
     
     if ( fileName.isEmpty() )
       return false;
@@ -266,15 +266,15 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent )
       
       if ( igesOp->IsDone() )
       {
-       transaction.commit();
+        transaction.commit();
       }
       else
       {
-       transaction.abort();
-       SUIT_MessageBox::critical( parent,
-                                  tr( "GEOM_ERROR" ),
-                                  tr( "GEOM_PRP_ABORT" ) + "\n" + tr( igesOp->GetErrorCode() ) );
-       return false;
+        transaction.abort();
+        SUIT_MessageBox::critical( parent,
+                                   tr( "GEOM_ERROR" ),
+                                   tr( "GEOM_PRP_ABORT" ) + "\n" + tr( igesOp->GetErrorCode() ) );
+        return false;
       }
     }
     catch ( const SALOME::SALOME_Exception& e )
@@ -288,8 +288,8 @@ bool IGESPlugin_GUI::exportIGES( SUIT_Desktop* parent )
   if ( !ok )
   {
     SUIT_MessageBox::warning( parent,
-                             tr( "WRN_WARNING" ),
-                             tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
+                              tr( "WRN_WARNING" ),
+                              tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
   }
   return ok;
 }
index 5b652b084c9ec1eb2057ffb6715cd679bd95aadb..7bbd751773ab97841ff5ebc1f8e680d16d860068 100755 (executable)
@@ -88,6 +88,8 @@ SET(MeasureGUI_HEADERS
   MeasureGUI_InertiaDlg.h
   MeasureGUI_BndBoxDlg.h
   MeasureGUI_DistanceDlg.h
+  MeasureGUI_AnnotationDlg.h
+  MeasureGUI_AnnotationInteractor.h
   MeasureGUI_AngleDlg.h
   MeasureGUI_MaxToleranceDlg.h
   MeasureGUI_WhatisDlg.h
@@ -116,6 +118,8 @@ SET(_moc_HEADERS
   MeasureGUI_InertiaDlg.h
   MeasureGUI_BndBoxDlg.h
   MeasureGUI_DistanceDlg.h
+  MeasureGUI_AnnotationDlg.h
+  MeasureGUI_AnnotationInteractor.h
   MeasureGUI_AngleDlg.h
   MeasureGUI_MaxToleranceDlg.h
   MeasureGUI_WhatisDlg.h
@@ -154,6 +158,8 @@ SET(MeasureGUI_SOURCES
   MeasureGUI_InertiaDlg.cxx
   MeasureGUI_BndBoxDlg.cxx
   MeasureGUI_DistanceDlg.cxx
+  MeasureGUI_AnnotationDlg.cxx
+  MeasureGUI_AnnotationInteractor.cxx
   MeasureGUI_AngleDlg.cxx
   MeasureGUI_MaxToleranceDlg.cxx
   MeasureGUI_WhatisDlg.cxx
old mode 100644 (file)
new mode 100755 (executable)
index 38a6f3b..d50c62c
 
 #include <GeometryGUI.h>
 #include "GeometryGUI_Operations.h"
+#include <GEOMGUI_TextTreeWdg.h>
 
 #include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_AnnotationAttrs.h>
+#include <GEOMGUI_AnnotationMgr.h>
 
 #include <LightApp_SelectionMgr.h>
 #include <SUIT_OverrideCursor.h>
@@ -44,6 +47,7 @@
 #include "MeasureGUI_BndBoxDlg.h"                 // Method BNDBOX
 #include "MeasureGUI_DistanceDlg.h"               // Method DISTANCE
 #include "MeasureGUI_AngleDlg.h"                  // Method ANGLE
+#include "MeasureGUI_AnnotationDlg.h"             // Method ANNOTATION
 #include "MeasureGUI_MaxToleranceDlg.h"           // Method MAXTOLERANCE
 #include "MeasureGUI_WhatisDlg.h"                 // Method WHATIS
 #include "MeasureGUI_CheckShapeDlg.h"             // Method CHECKSHAPE
@@ -111,6 +115,12 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
   case GEOMOp::OpAngle: 
     dlg = new MeasureGUI_AngleDlg( getGeometryGUI(), parent );
     break; // ANGLE
+  case GEOMOp::OpAnnotation:
+    dlg = new MeasureGUI_AnnotationDlg( getGeometryGUI(), true, parent );
+    break; // ANNOTATION
+  case GEOMOp::OpEditAnnotation:
+    dlg = new MeasureGUI_AnnotationDlg( getGeometryGUI(), false, parent );
+    break; // ANNOTATION
   case GEOMOp::OpTolerance: 
     dlg = new MeasureGUI_MaxToleranceDlg( getGeometryGUI(), parent );
     break; // MAXTOLERANCE
@@ -154,6 +164,15 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
   case GEOMOp::OpHideAllDimensions:
     ChangeDimensionsVisibility( false );
     break; // HIDE ALL DIMENSIONS
+  case GEOMOp::OpShowAllAnnotations:
+    ChangeAnnotationsVisibility( true );
+    break; // SHOW ALL ANNOTATIONS
+  case GEOMOp::OpHideAllAnnotations:
+    ChangeAnnotationsVisibility( false );
+    break; // HIDE ALL ANNOTATIONS
+  case GEOMOp::OpDeleteAnnotation:
+    DeleteAnnotation();
+    break; // DELETE ANNOTATIOn
   default: 
     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); 
     break;
@@ -173,48 +192,161 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
 void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible )
 {
   SalomeApp_Application* anApp = getGeometryGUI()->getApp();
-  if (!anApp)
-  {
+  if ( !anApp )
     return;
-  }
 
   SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
   if ( !anActiveStudy )
-  {
     return;
-  }
 
-  LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr();
-  if ( !aSelMgr )
-  {
+  Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
+  if ( anIObject.IsNull()
+   || !anIObject->hasEntry() )
     return;
+
+  SUIT_OverrideCursor wc;
+
+  GEOMGUI_DimensionProperty aDimensions( anActiveStudy, anIObject->getEntry() );
+
+  for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt ) {
+    aDimensions.SetVisible( anIt, theIsVisible );
   }
 
-  SALOME_ListIO aListIO;
-  aSelMgr->selectedObjects( aListIO );
-  if ( aListIO.Extent() != 1 )
-  {
+  aDimensions.SaveToAttribute( anActiveStudy, anIObject->getEntry() );
+
+  GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true );
+}
+
+//=======================================================================
+// function : ChangeAnnotationsVisibility
+// purpose  : 
+//=======================================================================
+void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
+{
+  SalomeApp_Application* anApp = getGeometryGUI()->getApp();
+  if ( !anApp )
     return;
-  }
 
-  Handle(SALOME_InteractiveObject) anIObject = aListIO.First();
-  if ( !anIObject->hasEntry() )
-  {
+  SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+  if ( !anActiveStudy )
     return;
+
+  QString anEntry;
+  Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
+  if ( !anIObject.IsNull() && anIObject->hasEntry() ) {
+    anEntry = anIObject->getEntry();
+  }
+  if ( anEntry.isEmpty() ) {
+    anEntry = getGeometryGUI()->GetTextTreeWdg()->getSingleSelectedObject();
   }
 
-  SUIT_OverrideCursor wc;
+  if ( !anEntry.isEmpty() ) {
+    _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( anEntry.toStdString() );
 
-  GEOMGUI_DimensionProperty aDimensions( anActiveStudy, anIObject->getEntry() );
+    const Handle(GEOMGUI_AnnotationAttrs)
+      aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
 
-  for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt )
+    if ( aShapeAnnotations.IsNull() ) {
+      return;
+    }
+
+    const int aCount = aShapeAnnotations->GetNbAnnotation();
+
+    if ( aCount > 0 ) {
+
+      SUIT_OverrideCursor wc;
+
+      for ( int anI = 0; anI < aCount; ++anI ) {
+
+        if ( !theIsVisible ) {
+          getGeometryGUI()->GetAnnotationMgr()->Erase( anEntry, anI );
+        }
+        else {
+          getGeometryGUI()->GetAnnotationMgr()->Display( anEntry , anI );
+        }
+      }
+
+      getGeometryGUI()->emitAnnotationsUpdated( anEntry );
+    }
+  }
+  else {
+    if ( theIsVisible ) {
+      getGeometryGUI()->GetAnnotationMgr()->DisplayAllAnnotations();
+    }
+    else {
+      getGeometryGUI()->GetAnnotationMgr()->EraseAllAnnotations();
+    }
+    getGeometryGUI()->GetTextTreeWdg()->updateVisibility();
+  }
+}
+
+//=======================================================================
+// function : DeleteAnnotation
+// purpose  : 
+//=======================================================================
+void MeasureGUI::DeleteAnnotation()
+{
+  SalomeApp_Application* anApp = getGeometryGUI()->getApp();
+  if ( !anApp )
+    return;
+
+  SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+  if ( !anActiveStudy )
+    return;
+
+  Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
+  if ( anIObject.IsNull()
+   || !anIObject->hasEntry() )
+    return;
+
+  const QString aEntry = anIObject->getEntry();
+
+  QString aObjEntry;
+
+  int aIndex = 0;
+
+  if ( getGeometryGUI()->GetAnnotationMgr()->getIndexFromEntry( aEntry, aObjEntry, aIndex ) )
   {
-    aDimensions.SetVisible( anIt, theIsVisible );
+    _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( aObjEntry.toStdString() );
+
+    const Handle(GEOMGUI_AnnotationAttrs)
+      aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+
+    if ( aShapeAnnotations.IsNull() ) {
+      return;
+    }
+
+    aShapeAnnotations->Remove( aIndex );
+
+    getGeometryGUI()->GetAnnotationMgr()->EraseRemovedAnnotation( aObjEntry, aIndex );
+
+    getGeometryGUI()->emitAnnotationsUpdated( aObjEntry );
   }
+}
 
-  aDimensions.SaveToAttribute( anActiveStudy, anIObject->getEntry() );
+//=======================================================================
+// function : getSingleSelectedIO
+// purpose  : returns selected interactive object for single selection.
+//=======================================================================
+Handle(SALOME_InteractiveObject) MeasureGUI::getSingleSelectedIO()
+{
+  SalomeApp_Application* anApp = getGeometryGUI()->getApp();
+  if ( !anApp ) {
+    return Handle(SALOME_InteractiveObject)();
+  }
 
-  GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true );
+  LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr();
+  if ( !aSelMgr ) {
+    return Handle(SALOME_InteractiveObject)();
+  }
+
+  SALOME_ListIO aListIO;
+  aSelMgr->selectedObjects( aListIO );
+  if ( aListIO.Extent() != 1 ) {
+    return Handle(SALOME_InteractiveObject)();
+  }
+
+  return aListIO.First();
 }
 
 //=======================================================================
old mode 100644 (file)
new mode 100755 (executable)
index 3067bbc..524225a
 #ifndef MEASUREGUI_H
 #define MEASUREGUI_H
 
+// GEOM includes
 #include <GEOMGUI.h>
 
+// GUI includes
+#include <SALOME_InteractiveObject.hxx>
+
 class QDialog;
 
 //=================================================================================
@@ -52,6 +56,17 @@ public:
 
   // Show/hide all dimension created for object
   void ChangeDimensionsVisibility( const bool theIsVisible );
+
+  // Show/hide all shape annotations created for GEOM object
+  void ChangeAnnotationsVisibility( const bool theIsVisible );
+
+  // Deletes the selected annotation
+  void DeleteAnnotation();
+
+private:
+  // Returns selected interactive object for single selection
+  Handle(SALOME_InteractiveObject) getSingleSelectedIO();
+
 private:
   QDialog* myManageDimensionDlg;
 private slots:
diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
new file mode 100755 (executable)
index 0000000..d7b0607
--- /dev/null
@@ -0,0 +1,1008 @@
+// Copyright ( C ) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright ( C ) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or ( at your option ) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  File   : MeasureGUI_AnnotationDlg.cxx
+
+#include "MeasureGUI.h"
+#include "MeasureGUI_AnnotationDlg.h"
+#include "MeasureGUI_AnnotationInteractor.h"
+
+#include <DlgRef.h>
+#include <GEOMBase.h>
+#include <GEOMBase_Skeleton.h>
+#include <GEOM_Displayer.h>
+#include <GeometryGUI.h>
+#include <GEOMGUI_AnnotationMgr.h>
+#include <GEOMGUI_TextTreeWdg.h>
+
+#include <SOCC_Prs.h>
+#include <SOCC_ViewModel.h>
+
+#include <SalomeApp_Application.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Tools.h>
+#include <SalomeApp_IntSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
+
+#include <LightApp_SelectionMgr.h>
+
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <SVTK_ViewModel.h>
+#include <SALOME_Prs.h>
+#include <SALOME_ListIO.hxx>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+
+#include <QComboBox>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHeaderView>
+#include <QInputDialog>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QStack>
+#include <QTableWidget>
+#include <QVBoxLayout>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+#include <Bnd_Box.hxx>
+#include <BRepAdaptor_CompCurve.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBndLib.hxx>
+#include <BRep_Tool.hxx>
+
+#include <SelectMgr_ViewerSelector.hxx>
+
+#include <TopoDS.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_DataMapIteratorOfDataMapOfIntegerInteger.hxx>
+
+#include <NCollection_Handle.hxx>
+
+#include <limits>
+
+#include <SALOMEDS_wrap.hxx>
+#include <GEOMImpl_Types.hxx>
+
+#ifdef max
+#undef max
+#endif
+
+//=======================================================================
+//function : MeasureGUI_AnnotationDlg
+//purpose  : 
+//=======================================================================
+
+MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg( GeometryGUI* theGeometryGUI, const bool theIsCreate,
+                                                   QWidget* parent, bool modal, Qt::WindowFlags fl )
+: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
+  myIsCreation( theIsCreate ), myShapeNameModified( false )
+{
+  myEditCurrentArgument = 0;
+
+  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap iconSelect( resMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
+
+  setWindowTitle( myIsCreation ? tr( "CREATE_ANNOTATION_TITLE" ) : tr( "EDIT_ANNOTATION_TITLE" ) );
+
+  // Shape type button group
+  mainFrame()->GroupBoxName->hide();
+  mainFrame()->GroupConstructors->hide();
+
+  // Field properties
+  QGroupBox* propGroup = new QGroupBox( tr( "ANNOTATION_PROPERTIES" ), centralWidget() );
+  QGridLayout* propLayout = new QGridLayout( propGroup );
+  propLayout->setMargin( 9 );
+  propLayout->setSpacing( 6 );
+
+  QLabel* textLabel = new QLabel( tr( "ANNOTATION_TEXT" ), propGroup );
+  myTextEdit = new QLineEdit( propGroup );
+  propLayout->addWidget( textLabel, 0, 0 );
+  propLayout->addWidget( myTextEdit, 0, 1, 1, 2 );
+
+  // shape
+  QLabel* shapeLabel = new QLabel( tr( "ANNOTATION_SHAPE" ), propGroup );
+  myShapeSelBtn = new QPushButton( propGroup );
+  myShapeSelBtn->setIcon( iconSelect );
+  myShapeSelBtn->setEnabled( myIsCreation );
+  myShapeName = new QLineEdit( propGroup );
+  myShapeName->setReadOnly( true );
+  myShapeName->setEnabled( myIsCreation );
+
+  // data type
+  myIsScreenFixed = new QCheckBox( tr( "ANNOTATION_IS_SCREEN_FIXED" ), propGroup );
+  myIsScreenFixed->setChecked( false ); // 3D, not fixed
+
+  propLayout->addWidget( shapeLabel, 1, 0 );
+  propLayout->addWidget( myShapeSelBtn, 1, 1 );
+  propLayout->addWidget( myShapeName, 1, 2 );
+  propLayout->addWidget( myIsScreenFixed, 2, 0, 1, 3 );
+  propLayout->setColumnStretch( 2, 5 );
+
+  QLabel* shapeTypeLabel = new QLabel( tr( "ANNOTATION_SUB_SHAPE" ), propGroup );
+  mySubShapeTypeCombo = new QComboBox( propGroup );
+  mySubShapeTypeCombo->setEnabled( myIsCreation );
+  mySubShapeTypeCombo->addItem( tr( "WHOLE_SHAPE" ), TopAbs_SHAPE );
+  mySubShapeTypeCombo->addItem( tr( "GEOM_VERTEX" ), TopAbs_VERTEX );
+  mySubShapeTypeCombo->addItem( tr( "GEOM_EDGE" ), TopAbs_EDGE );
+  mySubShapeTypeCombo->addItem( tr( "GEOM_FACE" ), TopAbs_FACE );
+  mySubShapeTypeCombo->addItem( tr( "GEOM_SOLID" ), TopAbs_SOLID );
+  mySubShapeTypeCombo->setCurrentIndex( 0 ); // SHAPE
+
+  propLayout->addWidget( shapeTypeLabel, 3, 0 );
+  propLayout->addWidget( mySubShapeTypeCombo, 3, 1, 1, 2 );
+
+  // sub-shape
+  mySubShapeSelBtn = new QPushButton( propGroup );
+  mySubShapeSelBtn->setIcon( iconSelect );
+  mySubShapeSelBtn->setEnabled( myIsCreation );
+  mySubShapeName = new QLineEdit( propGroup );
+  mySubShapeName->setReadOnly( true );
+  mySubShapeName->setEnabled( myIsCreation );
+
+  propLayout->addWidget( mySubShapeSelBtn, 4, 1 );
+  propLayout->addWidget( mySubShapeName, 4, 2 );
+
+  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
+  layout->setMargin( 0 );
+  layout->setSpacing( 6 );
+  layout->addWidget( propGroup );
+
+  setHelpFileName( "annotation_page.html" );
+
+  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+  connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this,
+           SLOT( SelectionIntoArgument() ) );
+  connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+  connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+
+  myInteractor = new MeasureGUI_AnnotationInteractor( theGeometryGUI, parent );
+  myInteractor->Enable();
+
+  connect( myInteractor, SIGNAL( SignalInteractionFinished( Handle_GEOM_Annotation ) ),
+           this, SLOT( onDragged( Handle_GEOM_Annotation ) ) );
+
+  Init();
+}
+
+//=======================================================================
+//function : ~MeasureGUI_AnnotationDlg
+//purpose  : 
+//=======================================================================
+
+MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg() {
+}
+
+//=================================================================================
+// function : Init()
+// purpose  : fills annotation properties with default values( in create mode ) or
+// the values of modified object
+//=================================================================================
+void MeasureGUI_AnnotationDlg::Init()
+{
+  if ( myIsCreation ) {
+
+    // default presentation values
+    myIsPositionDefined = false;
+    myAnnotationProperties.Text = tr( "ANNOTATION_PREFIX" );
+    myAnnotationProperties.IsVisible = false;
+    myAnnotationProperties.IsScreenFixed = false;
+    myAnnotationProperties.Attach = gp_Pnt( 0, 0, 0 );
+    myAnnotationProperties.ShapeIndex = -1;
+    myAnnotationProperties.ShapeType = ( int ) TopAbs_SHAPE;
+
+    // update internal controls and fields following to default values
+    activateSelectionArgument( myShapeSelBtn );
+
+    myTextEdit->setText( myAnnotationProperties.Text );
+    myShapeNameModified = false;
+    myIsScreenFixed->setChecked( myAnnotationProperties.IsScreenFixed );
+
+    int aSubShapeTypeIndex = -1;
+    int aTypesCount = mySubShapeTypeCombo->count();
+    for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
+      int aType = mySubShapeTypeCombo->itemData( i ).toInt();
+      if ( aType == myAnnotationProperties.ShapeType )
+        aSubShapeTypeIndex = i;
+    }
+    mySubShapeTypeCombo->setCurrentIndex( aSubShapeTypeIndex );
+
+    mySelectionMode = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
+    SelectionIntoArgument();
+    updateSubShapeEnableState();
+
+    // connect controls
+    connect( myShapeSelBtn, SIGNAL( clicked() ), this,
+        SLOT( SetEditCurrentArgument() ) );
+    connect( mySubShapeSelBtn, SIGNAL( clicked() ), this,
+        SLOT( SetEditCurrentArgument() ) );
+
+    connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) );
+    connect( myIsScreenFixed, SIGNAL( clicked( bool ) ), this, SLOT( onTypeChange() ) );
+    connect( mySubShapeTypeCombo, SIGNAL( currentIndexChanged( int ) ),
+        this, SLOT( onSubShapeTypeChange() ) );
+
+    //SelectionIntoArgument();
+
+    redisplayPreview();
+  } else { // edition
+    myIsPositionDefined = true;
+    mySelectionMode = TopAbs_SHAPE;
+    // find annotation
+    GEOMGUI_TextTreeWdg* aTextTreeWdg = myGeomGUI->GetTextTreeWdg();
+    // text tree widget should be not empty
+    QMap<QString, QList<int> > anAnnotations;
+    aTextTreeWdg->getSelected( anAnnotations );
+    // there is only one annotation selected when edit is started
+    QMap<QString, QList<int> >::const_iterator anIt = anAnnotations.begin();
+    myEditAnnotationEntry = anIt.key();
+    myEditAnnotationIndex = anIt.value()[0];
+
+    SalomeApp_Study* aStudy = getStudy();
+    _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myEditAnnotationEntry.toStdString() );
+    const Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+    if ( !aShapeAnnotations.IsNull() ) {
+      aShapeAnnotations->GetProperties( myEditAnnotationIndex, myAnnotationProperties );
+
+      myShape = GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject(aSObj) );
+    }
+
+    /// fill dialog controls
+    myTextEdit->setText( myAnnotationProperties.Text );
+    myShapeNameModified = false;
+    myIsScreenFixed->setChecked( myAnnotationProperties.IsScreenFixed );
+
+    int aSubShapeTypeIndex = -1;
+    int aTypesCount = mySubShapeTypeCombo->count();
+    for ( int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++ ) {
+      int aType = mySubShapeTypeCombo->itemData( i ).toInt();
+      if ( aType == myAnnotationProperties.ShapeType )
+        aSubShapeTypeIndex = i;
+    }
+    mySubShapeTypeCombo->setCurrentIndex( aSubShapeTypeIndex );
+
+    QString aShapeName = "";
+    _PTR(GenericAttribute) anAttr;
+    if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") ) {
+      _PTR(AttributeName) aNameAttr( anAttr );
+      aNameAttr->Value();
+      aShapeName = aNameAttr->Value().c_str();
+    }
+    myShapeName->setText( aShapeName );
+
+    QString aSubShapeName = "";
+    TopAbs_ShapeEnum aShapeType = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
+    if ( aShapeType != TopAbs_SHAPE ) {
+      aSubShapeName = QString( "%1:%2_%3" ).arg( aShapeName )
+                                           .arg( GEOMBase::TypeName( aShapeType ) )
+                                           .arg( myAnnotationProperties.ShapeIndex );
+    }
+    mySubShapeName->setText( aSubShapeName );
+
+    mySelectionMode = ( TopAbs_ShapeEnum ) myAnnotationProperties.ShapeType;
+    //SelectionIntoArgument();
+    updateSubShapeEnableState();
+
+    // connect controls
+    connect( myTextEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChange() ) );
+    connect( myIsScreenFixed, SIGNAL( clicked( bool ) ), this, SLOT( onTypeChange() ) );
+
+    myGeomGUI->GetAnnotationMgr()->SetPreviewStyle( myEditAnnotationEntry, myEditAnnotationIndex, true );
+
+    SalomeApp_Application* anApp = myGeomGUI->getApp();
+    if ( anApp )
+    {
+      OCCViewer_ViewManager* aVM = (OCCViewer_ViewManager*)anApp->getViewManager( OCCViewer_Viewer::Type(), false );
+      OCCViewer_Viewer* aViewer = (OCCViewer_Viewer*)aVM->getViewModel();
+      aViewer->unHighlightAll( true, true );
+    }
+
+    redisplayPreview();
+  }
+}
+
+//=================================================================================
+// function : activateSelection
+// purpose  : Activate local selection
+//=================================================================================
+void MeasureGUI_AnnotationDlg::activateSelection()
+{
+  globalSelection( GEOM_ALLOBJECTS );
+  if ( !myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE ) {
+    localSelection( myShape.get(), mySelectionMode );
+  }
+}
+
+//=================================================================================
+// function : getShapeType()
+// purpose  :
+//=================================================================================
+TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const
+{
+  return ( TopAbs_ShapeEnum ) mySubShapeTypeCombo->itemData(
+      mySubShapeTypeCombo->currentIndex() ).toInt();
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose  :
+//=================================================================================
+void MeasureGUI_AnnotationDlg::ClickOnOk()
+{
+  setIsApplyAndClose( true );
+  if ( ClickOnApply() )
+    ClickOnCancel();
+  setIsApplyAndClose( false );
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose  :
+//=================================================================================
+bool MeasureGUI_AnnotationDlg::ClickOnApply()
+{
+  if ( !isApplyAndClose() ) {
+    setIsDisableBrowsing( true );
+    setIsDisplayResult( false );
+  }
+
+  QString msg;
+  if ( !isValid( msg ) ) {
+    showError( msg );
+    return false;
+  }
+
+  SUIT_OverrideCursor wc;
+  SUIT_Session::session()->activeApplication()->putInfo( "" );
+
+  try {
+    if ( openCommand() )
+      if ( !execute( /*isApplyAndClose()*/ ) ) {
+        abortCommand();
+        showError();
+        return false;
+      }
+  } catch ( const SALOME::SALOME_Exception& e ) {
+    SalomeApp_Tools::QtCatchCorbaException( e );
+    abortCommand();
+    return false;
+  }
+  commitCommand();
+
+  if ( !isApplyAndClose() ) {
+    setIsDisableBrowsing( false );
+    setIsDisplayResult( true );
+  }
+
+  if ( !myShape->_is_nil() ) {
+    redisplay( myShape.get() );
+  }
+
+  if ( myIsCreation ) {
+
+   if ( !isApplyAndClose() )
+     Init();
+  }
+
+  return true;
+}
+
+//=================================================================================
+// function : SetEditCurrentArgument()
+// purpose  : process click on shape/sub-shape button. It stores as current edit argument
+// the corresponded line edit, set focus in it and unpress other button if it was pressed
+//=================================================================================
+void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
+{
+  QPushButton* aSelectButton = ( QPushButton* ) sender();
+
+  activateSelectionArgument( aSelectButton );
+
+  SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : activateSelectionArgument()
+// purpose  : it stores as current edit argument the corresponded line edit,
+// sets the focus on it and unpresses other button if it was pressed
+//=================================================================================
+void MeasureGUI_AnnotationDlg::activateSelectionArgument
+(
+  QPushButton* theSelectionButton ) {
+  QPushButton* anOtherButton = 0;
+  if ( theSelectionButton == myShapeSelBtn ) {
+    myEditCurrentArgument = myShapeName;
+    anOtherButton = mySubShapeSelBtn;
+    // throw down current sub-shape selection
+    TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
+
+    mySubShapeTypeCombo->setCurrentIndex( 0 );
+    mySubShapeName->setText( "" );
+
+    myAnnotationProperties.ShapeType = aShapeType;
+    myAnnotationProperties.ShapeIndex = -1;
+
+    mySelectionMode = aShapeType;
+
+    updateSubShapeEnableState();
+  } else if ( theSelectionButton == mySubShapeSelBtn ) {
+    myEditCurrentArgument = mySubShapeName;
+    anOtherButton = myShapeSelBtn;
+  } else
+    myEditCurrentArgument = 0;
+
+  if ( myEditCurrentArgument )
+    myEditCurrentArgument->setFocus();
+
+  theSelectionButton->setDown( true );
+  anOtherButton->setDown( false );
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose  : Called when selection has changed. Sets the current selection in the
+// annotation property and redisplays presentation
+//=================================================================================
+void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
+{
+  if ( myIsCreation && myEditCurrentArgument )
+  {
+    myEditCurrentArgument->setText( "" );
+
+    GEOM::GeomObjPtr anObj = getSelected( mySelectionMode );
+
+    bool hasAttachPoint = false;
+    gp_Pnt anAttachPoint( 0, 0, 0 );
+    int aSubShapeIndex = -1;
+    if ( myEditCurrentArgument == myShapeName ) { // Selection of a shape is active
+      if ( anObj->_is_nil() || mySelectionMode != TopAbs_SHAPE ) {
+        myShape = GEOM::GEOM_Object::_nil();
+      } else {
+        myShape = anObj;
+        QString aName = GEOMBase::GetName( anObj.get() );
+        myEditCurrentArgument->setText( aName );
+        if ( !myShapeNameModified ) {
+          myTextEdit->setText( aName );
+          onTextChange();
+          // modified state should not be changed as modification was performed not manually
+          myShapeNameModified = false;
+        }
+      }
+
+      bool aNullShape = myShape->_is_nil();
+      mySubShapeTypeCombo->setEnabled( !aNullShape );
+      updateSubShapeEnableState();
+
+      activateSelection();
+
+      if ( !aNullShape ) {
+
+        TopoDS_Shape aShape;
+        GEOMBase::GetShape( myShape.get(), aShape );
+
+        hasAttachPoint = getPickedPoint( anAttachPoint, aShape );
+        if ( !hasAttachPoint ) {
+
+          anAttachPoint = getAttachPoint( aShape, hasAttachPoint );
+        }
+      }
+    } else if ( myEditCurrentArgument == mySubShapeName ) {
+      if ( !myShape->_is_nil() ) {
+
+        if ( anObj->_is_nil() ) {
+          myEditCurrentArgument->setText( QString() );
+        }
+        else {
+
+          QString aName = GEOMBase::GetName( anObj.get() );
+          myEditCurrentArgument->setText( aName );
+
+          TopTools_IndexedMapOfShape aMainMap;
+          TopoDS_Shape aMainShape;
+          TopoDS_Shape aSubShape;
+          GEOMBase::GetShape( myShape.get(), aMainShape );
+          GEOMBase::GetShape( anObj.get(), aSubShape );
+          TopExp::MapShapes( aMainShape, getShapeType(), aMainMap );
+
+          if ( aMainMap.Contains( aSubShape ) ) {
+            aSubShapeIndex = aMainMap.FindIndex( aSubShape );
+          }
+
+          if ( !aSubShape.IsNull() ) {
+
+            TopoDS_Shape aShape;
+            GEOMBase::GetShape( myShape.get(), aShape );
+
+            hasAttachPoint = getPickedPoint( anAttachPoint, aSubShape );
+            if ( !hasAttachPoint ) {
+
+              anAttachPoint = getAttachPoint( aSubShape, hasAttachPoint );
+            }
+          }
+        }
+      }
+      myAnnotationProperties.ShapeIndex = aSubShapeIndex;
+    }
+
+    gp_Trsf aToShapeLCS;
+    if ( !myShape->_is_nil() ) {
+
+      TopoDS_Shape aShape;
+      GEOMBase::GetShape( myShape.get(), aShape );
+      gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+      aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS );
+    }
+
+    myAnnotationProperties.Attach = anAttachPoint.Transformed( aToShapeLCS );
+
+    if ( hasAttachPoint && !myIsPositionDefined ) {
+
+      gp_Pnt aPosition = getDefaultPosition( anAttachPoint );
+
+      myAnnotationProperties.Position = ( !myAnnotationProperties.IsScreenFixed ) ?
+        aPosition.Transformed( aToShapeLCS ) : aPosition;
+
+      myIsPositionDefined = true;
+    }
+    else if ( !hasAttachPoint ) {
+
+      myIsPositionDefined = false;
+    }
+  }
+  redisplayPreview();
+}
+
+//=======================================================================
+//function : closeEvent
+//purpose  :
+//=======================================================================
+void MeasureGUI_AnnotationDlg::closeEvent( QCloseEvent* theEv )
+{
+  if ( myInteractor ) {
+    myInteractor->Disable();
+  }
+  GEOMBase_Skeleton::closeEvent( theEv );
+}
+
+//=======================================================================
+//function : onTextChange
+//purpose  : change annotation text
+//=======================================================================
+void MeasureGUI_AnnotationDlg::onTextChange()
+{
+  myAnnotationProperties.Text = myTextEdit->text();
+  if ( !myShapeNameModified )
+    myShapeNameModified = true;
+  redisplayPreview();
+}
+
+//=======================================================================
+//function : onTypeChange
+//purpose  : change annotation type: 2D or 3D
+//=======================================================================
+void MeasureGUI_AnnotationDlg::onTypeChange()
+{
+  const bool isScreenFixedBefore = myAnnotationProperties.IsScreenFixed;
+
+  myAnnotationProperties.IsScreenFixed = myIsScreenFixed->isChecked();
+
+  // convert point position from screen space to 3D space
+  if ( myIsPositionDefined ) {
+
+    SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView();
+    OCCViewer_ViewWindow* anOccView = NULL;
+    if ( anActiveView ) {
+
+      anOccView = qobject_cast<OCCViewer_ViewWindow*>( anActiveView );
+    }
+
+    if ( anOccView ) {
+
+      TopoDS_Shape aShape;
+      GEOMBase::GetShape( myShape.get(), aShape );
+      const gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+
+      gp_Trsf aToShapeLCS, aFrShapeLCS;
+      aFrShapeLCS.SetTransformation( aShapeLCS, gp_Ax3() );
+      aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS );
+
+      const Handle(V3d_View) aView3d = anOccView->getViewPort()->getView();
+      const gp_Pnt aPosition = myAnnotationProperties.Position;
+      const gp_Pnt aAttach3d = myAnnotationProperties.Attach.Transformed( aFrShapeLCS );
+      if ( !isScreenFixedBefore ) {
+
+        gp_Pnt aPosition3d = aPosition.Transformed( aFrShapeLCS );
+        gp_Pnt aPosition2d = GEOM_Annotation::ConvertPosition2d( aPosition3d, aAttach3d, aView3d );
+        myAnnotationProperties.Position = aPosition2d;
+      }
+      else {
+
+        gp_Pnt aPosition3d = GEOM_Annotation::ConvertPosition3d( aPosition, aAttach3d, aView3d );
+        aPosition3d = aPosition3d.Transformed( aToShapeLCS );
+        myAnnotationProperties.Position = aPosition3d;
+      }
+    }
+  }
+
+  redisplayPreview();
+}
+
+//=======================================================================
+//function : onSubShapeTypeChange
+//purpose  :
+//=======================================================================
+void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
+{
+  const TopAbs_ShapeEnum aShapeType = getShapeType();
+  
+  activateSelectionArgument( aShapeType == TopAbs_SHAPE ? myShapeSelBtn : mySubShapeSelBtn );
+
+  myAnnotationProperties.ShapeType = aShapeType;
+
+  if ( aShapeType != mySelectionMode ) {
+    mySubShapeName->setText( "" );
+    myAnnotationProperties.ShapeIndex = -1;
+    mySelectionMode = aShapeType;
+  }
+
+  updateSubShapeEnableState();
+
+  activateSelection();
+  redisplayPreview();
+}
+
+//=================================================================================
+// function : onDragged
+// purpose  :
+//=================================================================================
+void MeasureGUI_AnnotationDlg::onDragged( Handle_GEOM_Annotation theAnnotation )
+{
+  TopoDS_Shape aShape;
+  GEOMBase::GetShape( myShape.get(), aShape );
+  gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+  gp_Trsf aToShapeLCS;
+  aToShapeLCS.SetTransformation( gp_Ax3(), aShapeLCS );
+
+  if ( !myAnnotationProperties.IsScreenFixed ) {
+    myAnnotationProperties.Position = theAnnotation->GetPosition().Transformed( aToShapeLCS );
+
+    if ( !myIsCreation ) {
+      myGeomGUI->GetAnnotationMgr()->storeFixedPosition( myEditAnnotationEntry, 0 );
+    }
+  }
+  else {
+    myAnnotationProperties.Position = theAnnotation->GetPosition();
+  }
+}
+
+#define RETURN_WITH_MSG( a, b ) \
+  if ( ( a ) ) { \
+    theMessage += ( b ); \
+    return false; \
+  }
+
+//=================================================================================
+// function : createOperation
+// purpose  :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr MeasureGUI_AnnotationDlg::createOperation()
+{
+  return getGeomEngine()->GetILocalOperations( getStudyId() );
+}
+
+//=================================================================================
+// function : isValid()
+// purpose  : Verify validity of input data
+//=================================================================================
+bool MeasureGUI_AnnotationDlg::isValid( QString& theMessage )
+{
+  SalomeApp_Study* study = getStudy();
+  RETURN_WITH_MSG( !study, tr( "GEOM_NO_STUDY" ) )
+  RETURN_WITH_MSG( study->studyDS()->GetProperties()->IsLocked(),
+      tr( "GEOM_STUDY_LOCKED" ) )
+
+  if ( myIsCreation ) {
+    RETURN_WITH_MSG( myShape->_is_nil(), tr( "NO_SHAPE" ) )
+  } else {
+    //RETURN_WITH_MSG( CORBA::is_nil( myShape ), tr( "NO_FIELD" ) )
+  }
+
+  if ( getShapeType() != TopAbs_SHAPE ) {
+    if ( myIsCreation ) {
+      RETURN_WITH_MSG( myAnnotationProperties.ShapeIndex < 0, tr( "NO_SUB_SHAPE" ) )
+    } else {
+      //RETURN_WITH_MSG( CORBA::is_nil( myShape ), tr( "NO_FIELD" ) )
+    }
+  }
+
+  if ( myIsCreation ) {
+    RETURN_WITH_MSG( !myIsPositionDefined, tr( "NO_POSITION" ) )
+  }
+
+  return true;
+}
+
+//=================================================================================
+// function : execute
+// purpose  :
+//=================================================================================
+bool MeasureGUI_AnnotationDlg::execute()
+{
+  QString anError;
+  if ( !isValid( anError ) )
+    return false;
+
+  SalomeApp_Study* aStudy = getStudy();
+  _PTR(SObject) aSObj = aStudy->studyDS()->FindObjectID( myShape->GetStudyEntry() );
+
+  Handle(GEOMGUI_AnnotationAttrs) aShapeAnnotations =
+    GEOMGUI_AnnotationAttrs::FindOrCreateAttributes( aSObj, aStudy );
+
+  if ( myIsCreation ) {
+    myAnnotationProperties.IsVisible = true; // initially created annotation is hidden
+
+    aShapeAnnotations->Append( myAnnotationProperties );
+
+    myGeomGUI->emitAnnotationsUpdated( QString( myShape->GetStudyEntry() ) );
+
+    erasePreview( true );
+
+    globalSelection( myGeomGUI->getLocalSelectionMode() , true );
+
+    myGeomGUI->GetAnnotationMgr()->Display( myShape->GetStudyEntry(), aShapeAnnotations->GetNbAnnotation()-1 );
+  }
+  else {
+
+    aShapeAnnotations->SetProperties( myEditAnnotationIndex, myAnnotationProperties );
+    myGeomGUI->emitAnnotationsUpdated( QString( myShape->GetStudyEntry() ) );
+  }
+  return true;
+}
+
+//=================================================================================
+// function : buildPrs
+// purpose  : creates annotation presentation object and corresponded SALOME presentation
+//=================================================================================
+SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
+{
+  QString aEntry = myIsCreation ? 
+    myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myShape->GetStudyEntry(), - 1 ) :
+    myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myEditAnnotationEntry, myEditAnnotationIndex );
+
+  SALOME_Prs* aPrs = myGeomGUI->GetAnnotationMgr()->CreatePresentation(
+    myAnnotationProperties, myShape.get(), 0, aEntry );
+
+  // set preview style for the created presentation
+  AIS_ListOfInteractive aIObjects;
+  ((SOCC_Prs*)aPrs)->GetObjects( aIObjects );
+  AIS_ListOfInteractive::Iterator aIOIt( aIObjects );
+  for ( ; aIOIt.More(); aIOIt.Next() ) {
+  
+    Handle( GEOM_Annotation ) aPresentation = Handle( GEOM_Annotation )::DownCast( aIOIt.Value() );
+    aPresentation->SetTextColor( Quantity_NOC_VIOLET );
+    aPresentation->SetLineColor( Quantity_NOC_VIOLET );
+    aPresentation->SetDepthCulling( Standard_False );
+  }
+
+  return aPrs;
+}
+
+//=================================================================================
+// function : updateSubShapeEnableState
+// purpose  : creates annotation presentation object and corresponded SALOME presentation
+//=================================================================================
+void MeasureGUI_AnnotationDlg::updateSubShapeEnableState()
+{
+  if ( !myIsCreation )
+    return;
+
+  bool isWholeShape = getShapeType() == TopAbs_SHAPE;
+  bool aNullShape = myShape->_is_nil();
+  mySubShapeSelBtn->setEnabled( !aNullShape && !isWholeShape );
+  mySubShapeName->setEnabled( !aNullShape && !isWholeShape );
+}
+
+//=================================================================================
+// function : redisplayPreview
+// purpose  : creates annotation presentation object and corresponded SALOME presentation
+//=================================================================================
+void MeasureGUI_AnnotationDlg::redisplayPreview()
+{
+  if ( myIsCreation ) {
+
+    QString aMess;
+    if ( !isValid( aMess ) ) {
+      erasePreview( true );
+      return;
+    }
+
+    erasePreview( false );
+
+    try {
+      SUIT_OverrideCursor wc;
+      getDisplayer()->SetToActivate( true );
+
+      if ( SALOME_Prs* aPrs = buildPrs() )
+        displayPreview( aPrs );
+      } catch ( const SALOME::SALOME_Exception& e ) {
+        SalomeApp_Tools::QtCatchCorbaException( e );
+      } catch ( ... ) {
+    }
+  }
+  else {
+    myGeomGUI->GetAnnotationMgr()->Redisplay( myEditAnnotationEntry, myEditAnnotationIndex,
+                                              myAnnotationProperties );
+  }
+
+  QString anEntry;
+  if ( myIsCreation && !myShape->_is_nil() ) {
+    anEntry = myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myShape->GetStudyEntry(), -1 );
+  }
+  else if ( !myIsCreation ) {
+    anEntry = myGeomGUI->GetAnnotationMgr()->makeAnnotationEntry( myEditAnnotationEntry, myEditAnnotationIndex );
+  }
+
+  myInteractor->SetEditEntry( anEntry );
+}
+
+//=================================================================================
+// function : getPickedPoint
+// purpose  : finds picked point in active viewer on the selected shape
+//=================================================================================
+bool MeasureGUI_AnnotationDlg::getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape )
+{
+  if ( theShape.ShapeType() == TopAbs_VERTEX )
+  {
+    bool isOk = false;
+    thePnt = getAttachPoint( theShape, isOk );
+    return isOk;
+  }
+
+  const SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView();
+  if ( !anActiveView )
+    return false;
+
+  const OCCViewer_ViewWindow* anOccView = qobject_cast<const OCCViewer_ViewWindow*>( anActiveView );
+  if ( !anOccView || !anOccView->underMouse() )
+    return false;
+
+  OCCViewer_ViewManager* aVM = ( OCCViewer_ViewManager* )anOccView->getViewManager();
+  OCCViewer_Viewer* aViewer = aVM->getOCCViewer();
+
+  Handle(AIS_InteractiveContext) anAISContext = aViewer->getAISContext();
+  Handle(SelectMgr_ViewerSelector) aSelector;
+  if ( anAISContext->HasOpenedContext() )
+    aSelector = anAISContext->LocalSelector();
+  else
+    aSelector = anAISContext->MainSelector();
+
+  if ( aSelector->NbPicked() < 1 )
+    return false;
+
+  thePnt = aSelector->PickedPoint( 1 );
+  return true;
+}
+
+//=================================================================================
+// function : getAttachPoint
+// purpose  : computes default attachment point on the shape
+//=================================================================================
+gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint( const TopoDS_Shape& theShape, bool& theIsOk )
+{
+  gp_Pnt aPnt( 0.0, 0.0, 0.0 );
+  theIsOk = true;
+  if ( theShape.ShapeType() == TopAbs_COMPSOLID
+    || theShape.ShapeType() == TopAbs_SOLID
+    || theShape.ShapeType() == TopAbs_SHELL )
+  {
+    Bnd_Box aBox;
+    BRepBndLib::Add( theShape, aBox );
+    const gp_Pnt aMin = aBox.CornerMin();
+    const gp_Pnt aMax = aBox.CornerMax();
+    aPnt = gp_Pnt( (aMin.X() + aMax.X()) / 2.0,
+                   (aMin.Y() + aMax.Y()) / 2.0,
+                   (aMin.Z() + aMax.Z()) / 2.0 );
+  }
+  else if ( theShape.ShapeType() == TopAbs_FACE )
+  {
+    BRepAdaptor_Surface aFace( TopoDS::Face( theShape ) );
+    const Standard_Real aU1 = aFace.FirstUParameter();
+    const Standard_Real aU2 = aFace.LastUParameter();
+    const Standard_Real aV1 = aFace.FirstVParameter();
+    const Standard_Real aV2 = aFace.LastVParameter();
+    aPnt = aFace.Value( ( aU1 + aU2 ) / 2.0, ( aV1 + aV2 ) / 2.0 );
+  }
+  else if ( theShape.ShapeType() == TopAbs_WIRE )
+  {
+    BRepAdaptor_CompCurve aWire( TopoDS::Wire( theShape ) );
+    const Standard_Real aP1 = aWire.FirstParameter();
+    const Standard_Real aP2 = aWire.LastParameter();
+    aPnt = aWire.Value( ( aP1 + aP2 ) / 2.0 );
+  }
+  else if ( theShape.ShapeType() == TopAbs_EDGE )
+  {
+    BRepAdaptor_Curve aEdge( TopoDS::Edge( theShape ) );
+    const Standard_Real aP1 = aEdge.FirstParameter();
+    const Standard_Real aP2 = aEdge.LastParameter();
+    aPnt = aEdge.Value( ( aP1 + aP2 ) / 2.0 );
+  }
+  else if ( theShape.ShapeType() == TopAbs_VERTEX )
+  {
+    aPnt = BRep_Tool::Pnt( TopoDS::Vertex( theShape ) );
+  }
+  else
+  {
+    theIsOk = false;
+  }
+
+  return aPnt;
+}
+
+//=================================================================================
+// function : getDefaultPosition
+// purpose  : computes default position for the given attachment point
+//=================================================================================
+gp_Pnt MeasureGUI_AnnotationDlg::getDefaultPosition( const gp_Pnt& theAttach )
+{
+  SUIT_ViewWindow* anActiveView = GEOMBase_Helper::getActiveView();
+  if ( !anActiveView ) {
+
+    return myAnnotationProperties.IsScreenFixed ? gp::Origin() : theAttach;
+  }
+
+  OCCViewer_ViewWindow* anOccView = qobject_cast<OCCViewer_ViewWindow*>( anActiveView );
+  if ( !anOccView ) {
+
+    return myAnnotationProperties.IsScreenFixed ? gp::Origin() : theAttach;
+  }
+
+  OCCViewer_ViewPort3d* aViewPort = anOccView->getViewPort();
+
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+  const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
+
+  const Handle(V3d_View) aView3d = aViewPort->getView();
+
+  const Standard_Real aFontHeight =( aFont.pixelSize() != -1 ) ? aFont.pixelSize() : aFont.pointSize();
+
+  return GEOM_Annotation::GetDefaultPosition( myAnnotationProperties.IsScreenFixed,
+    theAttach, aFontHeight * 1.5, aView3d );
+}
diff --git a/src/MeasureGUI/MeasureGUI_AnnotationDlg.h b/src/MeasureGUI/MeasureGUI_AnnotationDlg.h
new file mode 100755 (executable)
index 0000000..75ef0da
--- /dev/null
@@ -0,0 +1,129 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  GEOM GEOMGUI : GUI for Geometry component
+//  File   : MeasureGUI_AnnotationDlg.h
+
+#ifndef MeasureGUI_AnnotationDlg_H
+#define MeasureGUI_AnnotationDlg_H
+
+#include <GEOMBase_Skeleton.h>
+
+#include <GEOM_Annotation.hxx>
+#include <GEOM_Constants.h>
+#include <GEOMGUI_AnnotationAttrs.h>
+
+#include <TopAbs_ShapeEnum.hxx>
+//#include <TColStd_DataMapOfIntegerInteger.hxx>
+//#include <TColStd_IndexedMapOfInteger.hxx>
+//#include <TopTools_IndexedMapOfShape.hxx>
+
+//#include <QMap>
+//#include <QSet>
+//#include <QVector>
+//#include <QTableWidget>
+
+class QGroupBox;
+class QLineEdit;
+class QPushButton;
+class QComboBox;
+class QCheckBox;
+class SalomeApp_IntSpinBox;
+class MeasureGUI_AnnotationInteractor;
+
+//=================================================================================
+// class    : MeasureGUI_AnnotationDlg
+// purpose  :
+//=================================================================================
+class MeasureGUI_AnnotationDlg : public GEOMBase_Skeleton
+{
+  Q_OBJECT
+
+public:
+  MeasureGUI_AnnotationDlg ( GeometryGUI* theGeometryGUI,
+                             const bool theIsCreate,
+                             QWidget* parent=0,
+                             bool modal=false, Qt::WindowFlags fl=0 );
+  ~MeasureGUI_AnnotationDlg();
+
+protected:
+  // redefined from GEOMBase_Helper
+  virtual                             GEOM::GEOM_IOperations_ptr createOperation();
+  virtual bool                        isValid ( QString& );
+  virtual bool                        execute ();
+
+  SALOME_Prs*                         buildPrs();
+  void                                updateSubShapeEnableState();
+  void                                redisplayPreview();
+
+  void                                closeEvent( QCloseEvent* theEv );
+
+private slots:
+  void                                ClickOnOk();
+  bool                                ClickOnApply();
+  void                                SelectionIntoArgument();
+  void                                SetEditCurrentArgument();
+
+  void                                onTextChange();
+  void                                onTypeChange();
+  void                                onSubShapeTypeChange();
+
+  void                                onDragged( Handle_GEOM_Annotation theAnnotation );
+
+private:
+  void                                Init();
+
+  void                                activateSelectionArgument( QPushButton* theSelectionButton );
+  void                                activateSelection();
+  TopAbs_ShapeEnum                    getShapeType() const;
+
+  bool                                getPickedPoint( gp_Pnt& thePnt, const TopoDS_Shape& theShape );
+  gp_Pnt                              getAttachPoint( const TopoDS_Shape& theShape, bool& theIsOk );
+  gp_Pnt                              getDefaultPosition( const gp_Pnt& theAttach );
+
+private:
+  TopAbs_ShapeEnum                    mySelectionMode;
+  QString                             myEditAnnotationEntry;
+  int                                 myEditAnnotationIndex;
+  GEOMGUI_AnnotationAttrs::Properties myAnnotationProperties;
+  bool                                myIsPositionDefined;
+  /// an index of edited annotation in the list shape annotations, -1 in create operation
+  bool                                myIsCreation;
+  GEOM::GeomObjPtr                    myShape;
+
+  QLineEdit*                          myTextEdit;
+
+  QPushButton*                        myShapeSelBtn;
+  // update shape name by shape selection if it has not been manually modified yet
+  bool                                myShapeNameModified;
+  QLineEdit*                          myShapeName;
+  QCheckBox*                          myIsScreenFixed;
+
+  QComboBox*                          mySubShapeTypeCombo;
+
+  QPushButton*                        mySubShapeSelBtn;
+  QLineEdit*                          mySubShapeName;
+
+  MeasureGUI_AnnotationInteractor*    myInteractor;
+};
+
+#endif
diff --git a/src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx b/src/MeasureGUI/MeasureGUI_AnnotationInteractor.cxx
new file mode 100755 (executable)
index 0000000..7070c22
--- /dev/null
@@ -0,0 +1,333 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : MeasureGUI_AnnotationInteractor.cxx
+// Author : Anton POLETAEV, Open CASCADE S.A.S.
+
+#include "MeasureGUI_AnnotationInteractor.h"
+
+// SALOME includes
+#include <GeometryGUI.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <OCCViewer_ViewWindow.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_Desktop.h>
+#include <SalomeApp_Application.h>
+
+// Qt includes
+#include <QMouseEvent>
+
+// OCCT includes
+#include <V3d_View.hxx>
+
+//=================================================================================
+// function : Constructor
+// purpose  : 
+//=================================================================================
+MeasureGUI_AnnotationInteractor::MeasureGUI_AnnotationInteractor( GeometryGUI* theGUI,
+                                                                  QObject* theParent )
+: QObject( theParent ),
+  myGeomGUI( theGUI ),
+  myIsEnabled( false ),
+  myVM( NULL ),
+  myViewer( NULL ),
+  myActiveViewPort( NULL )
+{
+}
+
+//=================================================================================
+// function : Deactivate
+// purpose  : 
+//=================================================================================
+MeasureGUI_AnnotationInteractor::~MeasureGUI_AnnotationInteractor()
+{
+  if ( myActiveViewPort )
+  {
+    myActiveViewPort->releaseMouse();
+    myActiveViewPort = NULL;
+  }
+
+  Disable();
+}
+
+//=================================================================================
+// function : Enable
+// purpose  : Enables event processing and interaction handlers.
+//=================================================================================
+void MeasureGUI_AnnotationInteractor::Enable()
+{
+  if ( myIsEnabled )
+  {
+    return;
+  }
+
+  myIsEnabled = true;
+
+  // install event filtering on viewer windows
+  SalomeApp_Application* anApp = myGeomGUI->getApp();
+  if ( !anApp )
+  {
+    return;
+  }
+
+  myVM     = (OCCViewer_ViewManager*) anApp->getViewManager( OCCViewer_Viewer::Type(), false );
+  myViewer = (OCCViewer_Viewer*) myVM->getViewModel();
+  if ( !myVM || !myViewer )
+  {
+    return;
+  }
+
+  connect( myVM, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), SLOT( OnViewCreated( SUIT_ViewWindow* ) ) );
+  connect( myVM, SIGNAL( deleteView ( SUIT_ViewWindow* ) ), SLOT( OnViewRemoved( SUIT_ViewWindow* ) ) );
+
+  QVector<SUIT_ViewWindow*>           aViews  = myVM->getViews();
+  QVector<SUIT_ViewWindow*>::iterator aViewIt = aViews.begin();
+  for ( ; aViewIt != aViews.end(); ++aViewIt )
+  {
+    ConnectView( *aViewIt );
+  }
+}
+
+//=================================================================================
+// function : Disable
+// purpose  : Disables event processing and interaction handlers.
+//=================================================================================
+void MeasureGUI_AnnotationInteractor::Disable()
+{
+  if ( !myIsEnabled )
+  {
+    return;
+  }
+
+  myIsEnabled = false;
+
+  // remove event filtering from viewer windows
+  QVector<SUIT_ViewWindow*>           aViews  = myVM->getViews();
+  QVector<SUIT_ViewWindow*>::iterator aViewIt = aViews.begin();
+  for ( ; aViewIt != aViews.end(); ++aViewIt )
+  {
+    DisconnectView( *aViewIt );
+  }
+
+  if ( myActiveViewPort )
+  {
+    myActiveViewPort->releaseMouse();
+    myActiveViewPort = NULL;
+  }
+
+  if ( !myActiveIO.IsNull() )
+  {
+    emit SignalInteractionFinished( myActiveIO );
+    myActiveIO.Nullify();
+  }
+}
+
+//=================================================================================
+// function : ConnectView
+// purpose  : Connect interactor's event handler to the view window given.
+//=================================================================================
+void MeasureGUI_AnnotationInteractor::ConnectView( SUIT_ViewWindow* theView )
+{
+  ( (OCCViewer_ViewWindow*) theView )->getViewPort()->installEventFilter( this );
+}
+
+//=================================================================================
+// function : DisconnectView
+// purpose  : Disconnect interactor's event handler from the view window given.
+//=================================================================================
+void MeasureGUI_AnnotationInteractor::DisconnectView( SUIT_ViewWindow* theView )
+{
+  ( (OCCViewer_ViewWindow*) theView )->getViewPort()->removeEventFilter( this );
+}
+
+//=================================================================================
+// function : OnViewCreated
+// purpose  : Handler for signal coming from GUI layer.
+//=================================================================================
+void MeasureGUI_AnnotationInteractor::OnViewCreated( SUIT_ViewWindow* theView )
+{
+  ConnectView( theView );
+}
+
+//=================================================================================
+// function : OnViewRemoved
+// purpose  : Handler for signal coming from GUI layer.
+//=================================================================================
+void MeasureGUI_AnnotationInteractor::OnViewRemoved( SUIT_ViewWindow* theView )
+{
+  DisconnectView( theView );
+}
+
+//=================================================================================
+// function : eventFilter
+// purpose  : Hooks and process events from OCCT viewer prior to their coming into the base viewer class.
+//=================================================================================
+bool MeasureGUI_AnnotationInteractor::eventFilter( QObject* theObject, QEvent* theEvent )
+{
+  OCCViewer_ViewPort3d* aViewPort = (OCCViewer_ViewPort3d*)theObject;
+
+  const Handle(V3d_View) aView3d = aViewPort->getView();
+
+  switch( theEvent->type() )
+  {
+    // ------------------------------------------------------------------------
+    // Start dragging ("grab") event
+    // ------------------------------------------------------------------------
+    case QEvent::MouseButtonPress :
+    {
+      QMouseEvent* aMouseEv = dynamic_cast<QMouseEvent*>( theEvent );
+
+      if ( myEditEntry.isEmpty() )
+      {
+        return false;
+      }
+
+      if ( !( aMouseEv->buttons() & Qt::LeftButton ) )
+      {
+        return false;
+      }
+
+      const Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
+
+      anAISContext->MoveTo( aMouseEv->x(), aMouseEv->y(), aView3d, Standard_True );
+
+      if ( !anAISContext->HasDetected() )
+      {
+        return false;
+      }
+
+      const Handle(SelectMgr_EntityOwner) aDetected = anAISContext->DetectedOwner();
+
+      if( aDetected.IsNull() )
+      {
+        return false;
+      }
+
+      const Handle(GEOM_Annotation) aAnnotation =
+        Handle(GEOM_Annotation)::DownCast( aDetected->Selectable() );
+
+      if ( aAnnotation.IsNull() )
+      {
+        return false;
+      }
+
+      const Handle(SALOME_InteractiveObject) anIO = 
+        Handle(SALOME_InteractiveObject)::DownCast( aAnnotation->GetOwner() );
+
+      if ( anIO.IsNull() || anIO->getEntry() != myEditEntry )
+      {
+        return false;
+      }
+
+      myStartPoint = aMouseEv->pos();
+      mySelection.Clear();
+
+      for ( anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected() )
+      {
+        mySelection.Append( anAISContext->SelectedOwner() );
+      }
+
+      anAISContext->ClearSelected( Standard_False );
+      anAISContext->Unhilight( myActiveIO, Standard_True );
+
+      myActiveViewPort = aViewPort;
+      myActiveViewPort->grabMouse();
+      myActiveIO = aAnnotation;
+      myActiveIO->BeginDrag();
+
+      emit SignalInteractionStarted( myActiveIO );
+
+      return true;
+    }
+
+    // ------------------------------------------------------------------------
+    // Perform dragging operation
+    // ------------------------------------------------------------------------
+    case QEvent::MouseMove :
+    {
+      QMouseEvent* aMouseEv = (QMouseEvent*) theEvent;
+
+      if ( !myActiveIO.IsNull() )
+      {
+        const Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
+
+        if ( anAISContext->IsHilighted( Handle(AIS_InteractiveObject)::DownCast( myActiveIO ) ) )
+        {
+          anAISContext->Unhilight( myActiveIO, Standard_False );
+        }
+
+        const QPoint aDelta = aMouseEv->pos() - myStartPoint;
+        myActiveIO->Drag( aDelta.x(), (-aDelta.y()), aView3d );
+        anAISContext->Update( myActiveIO, Standard_False );
+        anAISContext->UpdateCurrentViewer();
+        return true;
+      }
+
+      return false;
+    }
+
+    // ------------------------------------------------------------------------
+    // Stop dragging operation
+    // ------------------------------------------------------------------------
+    case QEvent::FocusOut :
+    case QEvent::MouseButtonRelease :
+    {
+      QMouseEvent* aMouseEv = (QMouseEvent*) theEvent;
+
+      if ( myActiveViewPort )
+      {
+        myActiveViewPort->releaseMouse();
+        myActiveViewPort = NULL;
+      }
+      if ( !myActiveIO.IsNull() )
+      {
+        myActiveIO->EndDrag();
+
+        const Handle(AIS_InteractiveContext) anAISContext = myViewer->getAISContext();
+
+        anAISContext->ClearSelected( Standard_False );
+        SelectMgr_SequenceOfOwner::Iterator anIt( mySelection );
+        for( ; anIt.More(); anIt.Next() )
+        {
+          anAISContext->AddOrRemoveSelected( anIt.Value(), Standard_False );
+        }
+
+        anAISContext->Update( myActiveIO, Standard_False );
+        anAISContext->UpdateCurrentViewer();
+        anAISContext->MoveTo( aMouseEv->pos().x(), aMouseEv->pos().y(), aView3d, Standard_True );
+
+        emit SignalInteractionFinished( myActiveIO );
+
+        mySelection.Clear();
+        myActiveIO.Nullify();
+        return (theEvent->type() == QEvent::MouseButtonRelease);
+      }
+
+      return false;
+    }
+
+    default: return false;
+  }
+}
diff --git a/src/MeasureGUI/MeasureGUI_AnnotationInteractor.h b/src/MeasureGUI/MeasureGUI_AnnotationInteractor.h
new file mode 100755 (executable)
index 0000000..21875cc
--- /dev/null
@@ -0,0 +1,122 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : MeasureGUI_AnnotationInteractor.h
+// Author : Anton POLETAEV, Open CASCADE S.A.S.
+//
+#ifndef MEASUREGUI_ANNOTATIONINTERACTOR_H
+#define MEASUREGUI_ANNOTATIONINTERACTOR_H
+
+#include <GEOM_Annotation.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_SequenceOfOwner.hxx>
+#include <QObject>
+#include <QPoint>
+
+class GeometryGUI;
+class OCCViewer_Viewer;
+class OCCViewer_ViewManager;
+class OCCViewer_ViewPort3d;
+class SUIT_ViewWindow;
+
+/*!
+ * \class MeasureGUI_AnnotationInteractor
+ * \brief Class implementing logical layer for interactive dragging of annotation
+ *        labels. It includes two components: listener for GUI events occuring
+ *        inside of OCCT 3D viewer and processor for hooked events to perform
+ *        interactive modification of the selected annotation within current
+ *        AIS context.
+ */
+class MeasureGUI_AnnotationInteractor : public QObject
+{
+  Q_OBJECT
+
+public:
+
+  //! Constructor.
+  //! Connects to existing viewer/view windows to process events.
+  //! \param theGUI [in] the geometry module's GUI interface.
+  //! \param theOwner [in] the owner of the instance.
+  MeasureGUI_AnnotationInteractor( GeometryGUI* theGUI, QObject* theOwner );
+
+  //! Destructor.
+  virtual ~MeasureGUI_AnnotationInteractor();
+
+public:
+
+  //! Enables event processing and interaction handlers.
+  void Enable();
+
+  //! Disables event processing and interaction handlers.
+  void Disable();
+
+  //! Set entry of allowed annotation presentations.
+  void SetEditEntry( const QString& theEntry ) { myEditEntry = theEntry; }
+
+protected:
+
+  //! Connect interactor's event handler to the view window given.
+  void ConnectView( SUIT_ViewWindow* theWindow );
+
+  //! Disconnect interactor's event handler from the view window given.
+  void DisconnectView( SUIT_ViewWindow* theWindow );
+
+signals:
+
+  //! Emitted when interactor begins modification of the interactive object.
+  void SignalInteractionStarted( Handle_GEOM_Annotation theIO );
+
+  //! Emitted when interactor finished modification of the interactive object.
+  void SignalInteractionFinished( Handle_GEOM_Annotation theIO );
+
+protected slots:
+
+  //! Handler for signal coming from GUI layer.
+  void OnViewCreated( SUIT_ViewWindow* );
+
+  //! Handler for signal coming from GUI layer.
+  void OnViewRemoved( SUIT_ViewWindow* );
+
+protected:
+
+  //! Hooks and process events from OCCT viewer prior to their coming into the base viewer class.
+  //! It handles the events coming to viewport and identifies whether the events can
+  //! invoke an interaction operation or not. If yes, the operation is performed within the
+  //! interactor class and events are "accepted". Otherwise, the events are passed to
+  //! viewer's subroutines.
+  virtual bool eventFilter( QObject*, QEvent* );
+
+private:
+
+  GeometryGUI*              myGeomGUI;
+  bool                      myIsEnabled;
+  OCCViewer_ViewManager*    myVM;
+  OCCViewer_Viewer*         myViewer;
+  OCCViewer_ViewPort3d*     myActiveViewPort;
+  Handle(GEOM_Annotation)   myActiveIO;
+  SelectMgr_SequenceOfOwner mySelection;
+  QPoint                    myStartPoint;
+  QString                   myEditEntry;
+};
+
+#endif
index bd78dd2fb0a8f58547c67d7ae9280c0d7be397a3..177128f27504bf41230af670d35963c35fafa3d4 100644 (file)
@@ -418,7 +418,7 @@ void MeasureGUI_CheckCompoundOfBlocksDlg::onErrorsListSelectionChanged()
 
   myListBox2->clear();
 
-  if (aCurItem < aErrs.length()) {
+  if (aCurItem < (int)aErrs.length()) {
     GEOM::GEOM_IBlocksOperations::BCError aErr = aErrs[aCurItem];
     GEOM::ListOfLong aObjLst = aErr.incriminated;
     QStringList aSubShapeList;
index 6713729f7ebace8303419cf6e7ee419dac85364c..6032636e07803d00f22dac64b02f7d19ff4584c5 100644 (file)
@@ -440,7 +440,7 @@ void MeasureGUI_CreateDimensionDlg::StartLocalEditing()
   anAISContext->SetZLayer( myDimension, myEditingLayer );
   anAISContext->Activate( myDimension, AIS_DSM_Line );
   anAISContext->Activate( myDimension, AIS_DSM_Text );
-  anAISContext->Redisplay( myDimension );
+  anAISContext->Redisplay( myDimension , Standard_True );
 }
 
 //=================================================================================
@@ -460,7 +460,7 @@ void MeasureGUI_CreateDimensionDlg::StopLocalEditing()
   Handle(V3d_Viewer)             aViewer3d    = myEditingViewer->getViewer3d();
 
   aViewer3d->RemoveZLayer( myEditingLayer );
-  anAISContext->CloseLocalContext();
+  anAISContext->CloseLocalContext( Standard_True );
 
   myEditingViewer = NULL;
 }
index 4d738e0db71b1b7db714598b91ab70716c7b16d9..8a7eaf259a776122ffd3559d7240dc2ae3b6d863 100644 (file)
@@ -373,7 +373,7 @@ void MeasureGUI_DimensionInteractor::MoveFlyoutFree( const Handle(V3d_View)& the
   if ( aNewFlyout <= Precision::Confusion() )
   {
     myInteractedIO->SetFlyout( 0.0 );
-    myViewer->getAISContext()->Redisplay( myInteractedIO );
+    myViewer->getAISContext()->Redisplay( myInteractedIO, Standard_True );
     return;
   }
 
@@ -382,7 +382,7 @@ void MeasureGUI_DimensionInteractor::MoveFlyoutFree( const Handle(V3d_View)& the
   myInteractedIO->SetFlyout( aNewFlyout );
   myInteractedIO->SetCustomPlane( aNewPlane );
 
-  myViewer->getAISContext()->Redisplay( myInteractedIO );
+  myViewer->getAISContext()->Redisplay( myInteractedIO, Standard_True );
 }
 
 //=================================================================================
@@ -496,7 +496,7 @@ void MeasureGUI_DimensionInteractor::MoveFlyoutInPlane( const Handle(V3d_View)&
 
   myInteractedIO->SetFlyout( aFlyout );
 
-  myViewer->getAISContext()->Redisplay( myInteractedIO );
+  myViewer->getAISContext()->Redisplay( myInteractedIO, Standard_True );
 }
 
 //=================================================================================
@@ -668,7 +668,7 @@ void MeasureGUI_DimensionInteractor::MoveText( const Handle(V3d_View)& theView,
   myInteractedIO->DimensionAspect()->SetArrowOrientation( aArrPos );
   myInteractedIO->SetToUpdate();
 
-  myViewer->getAISContext()->Redisplay( myInteractedIO );
+  myViewer->getAISContext()->Redisplay( myInteractedIO, Standard_True );
 }
 
 //=================================================================================
@@ -691,7 +691,7 @@ bool MeasureGUI_DimensionInteractor::eventFilter( QObject* theObject, QEvent* th
       QMouseEvent* aMouseEv = dynamic_cast<QMouseEvent*>( theEvent );
 
       // init detection
-      anAISContext->MoveTo( aMouseEv->x(), aMouseEv->y(), aView3d );
+      anAISContext->MoveTo( aMouseEv->x(), aMouseEv->y(), aView3d, Standard_True );
       if ( !anAISContext->HasDetected() )
       {
         return false;
@@ -738,7 +738,7 @@ bool MeasureGUI_DimensionInteractor::eventFilter( QObject* theObject, QEvent* th
       }
 
       anAISContext->ClearSelected( Standard_False );
-      anAISContext->AddOrRemoveSelected( aDetectedOwner );
+      anAISContext->AddOrRemoveSelected( aDetectedOwner, Standard_True );
 
       emit InteractionStarted( myInteractedIO );
 
index b0e199d3de7ec112deef897f676119888f65676f..fa53c1aa07120a61aedb278bcc5751b5a5e47c6c 100644 (file)
@@ -228,9 +228,9 @@ void MeasureGUI_ManageDimensionsDlg::StartSelection( const Selection theSelectio
     myDimensionInteractor->Enable();
 
     connect( myDimensionInteractor,
-             SIGNAL( InteractionFinished( Handle(AIS_InteractiveObject) ) ),
+             SIGNAL( InteractionFinished( Handle_AIS_InteractiveObject ) ),
              this,
-             SLOT( OnInteractionFinished( Handle(AIS_InteractiveObject) ) ) );
+             SLOT( OnInteractionFinished( Handle_AIS_InteractiveObject ) ) );
 
     anAISContext->UpdateCurrentViewer();
   }
@@ -290,9 +290,9 @@ void MeasureGUI_ManageDimensionsDlg::StopSelection()
     myDimensionInteractor->Disable();
 
     disconnect( myDimensionInteractor,
-                SIGNAL( InteractionFinished( Handle(AIS_InteractiveObject) ) ),
+                SIGNAL( InteractionFinished( Handle_AIS_InteractiveObject ) ),
                 this,
-                SLOT( OnInteractionFinished( Handle(AIS_InteractiveObject) ) ) );
+                SLOT( OnInteractionFinished( Handle_AIS_InteractiveObject ) ) );
   }
 
   myCurrentSelection = Selection_None;
@@ -628,7 +628,7 @@ void MeasureGUI_ManageDimensionsDlg::OnHideAll()
 // function : OnInteractionFinished
 // purpose  :
 //=================================================================================
-void MeasureGUI_ManageDimensionsDlg::OnInteractionFinished( Handle(AIS_InteractiveObject) theIO )
+void MeasureGUI_ManageDimensionsDlg::OnInteractionFinished( Handle_AIS_InteractiveObject theIO )
 {
   // update property data
   SalomeApp_Application* anApp = myGeomGUI->getApp();
index 900552cb6a37b0075960d102ba83ed157ca5415e..4674ac750c62db0cae7ed8b549cd6a5e5b52f74e 100755 (executable)
@@ -48,6 +48,7 @@ SET(_link_LIBRARIES
   OCC2VTK
   SalomeIDLGEOM
   ${CAS_TKBRep}
+  ${CAS_TKOpenGl}
   ${KERNEL_SALOMELocalTrace}
   ${GUI_SalomeObject}
   ${GUI_SVTK}
@@ -76,6 +77,7 @@ SET(OBJECT_HEADERS
   GEOM_DeviceActor.h
   GEOM_Constants.h
   GEOM_AISDimension.hxx
+  GEOM_Annotation.hxx
   )
 # --- sources ---
 
@@ -93,6 +95,7 @@ SET(OBJECT_SOURCES
   GEOM_DeviceActor.cxx
   GEOM_Constants.cxx
   GEOM_AISDimension.cxx
+  GEOM_Annotation.cxx
   )
 
 # --- rules ---
index 4734bf77e11f57d358c04d6bdcb19c1b3ebec113..71212889b4a90e9bd08783653a390180a92519d2 100644 (file)
@@ -88,9 +88,9 @@ GEOM_AISShape::TopLevelDispMode GEOM_AISShape::myTopLevelDm = GEOM_AISShape::Top
 Quantity_Color GEOM_AISShape::myTopLevelColor;
 
 
-static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
+static void getEntityOwners( const Handle(AIS_InteractiveObject)&  theObj,
                              const Handle(AIS_InteractiveContext)& theIC,
-                             SelectMgr_IndexedMapOfOwner& theMap )
+                             SelectMgr_IndexedMapOfOwner&          theMap )
 {
   if ( theObj.IsNull() || theIC.IsNull() )
     return;
@@ -127,9 +127,9 @@ static void getEntityOwners( const Handle(AIS_InteractiveObject)& theObj,
 }
 
 static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap,
-                             const TopoDS_Shape& aMainShape,
-                             const SelectMgr_IndexedMapOfOwner& anAllMap, 
-                             SelectMgr_IndexedMapOfOwner& aToHiliteMap )
+                             const TopoDS_Shape&                aMainShape,
+                             const SelectMgr_IndexedMapOfOwner& anAllMap,
+                             SelectMgr_IndexedMapOfOwner&       aToHiliteMap )
 {
   TopTools_IndexedMapOfShape aMapOfShapes;
   TopExp::MapShapes(aMainShape, aMapOfShapes);
@@ -143,13 +143,13 @@ static void indicesToOwners( const TColStd_IndexedMapOfInteger& aIndexMap,
     Standard_Integer aSubShapeId = aMapOfShapes.FindIndex( aSubShape );
     if ( !aSubShapeId || !aIndexMap.Contains( aSubShapeId ) )
       continue;
-    
+
     if ( !aToHiliteMap.Contains( anOwner ) )
       aToHiliteMap.Add( anOwner );
   }
 }
 
-GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
+GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape&    shape,
                              const Standard_CString aName)
   : SALOME_AISShape(shape),
     myName(aName),
@@ -160,7 +160,7 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
     myFieldStepRangeMin(0),
     myFieldStepRangeMax(0)
 {
-  //rnv: Commented to avoid bug with local selection 
+  //rnv: Commented to avoid bug with local selection
   //SetHilightMode( CustomHighlight ); // override setting the mode to 0 inside AIS_Shape constructor
 
   myShadingColor = Quantity_Color( Quantity_NOC_GOLDENROD );
@@ -171,14 +171,14 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
   myTopLevel = Standard_False;
   Graphic3d_MaterialAspect aMatAspect;
   if ( !HasMaterial() ) {
-        aMatAspect.SetAmbient( 0.5 );
-        aMatAspect.SetDiffuse( 0.5 );
-        aMatAspect.SetEmissive( 0.5 );
-        aMatAspect.SetShininess(0.5 );
-        aMatAspect.SetSpecular( 0.5 );
-        
-        myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
-        myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
+    aMatAspect.SetAmbient( 0.5 );
+    aMatAspect.SetDiffuse( 0.5 );
+    aMatAspect.SetEmissive( 0.5 );
+    aMatAspect.SetShininess(0.5 );
+    aMatAspect.SetSpecular( 0.5 );
+
+    myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
+    myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
   }
 }
 
@@ -186,18 +186,21 @@ GEOM_AISShape::~GEOM_AISShape()
 {
 }
 
-void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
+void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io)
+{
   SetOwner( io );
 }
 
-Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO(){
+Handle(SALOME_InteractiveObject) GEOM_AISShape::getIO()
+{
   Handle(SALOME_InteractiveObject) IO;
   if ( !GetOwner().IsNull() )
     IO = Handle(SALOME_InteractiveObject)::DownCast( GetOwner() );
   return IO;
 }
 
-Standard_Boolean GEOM_AISShape::hasIO(){
+Standard_Boolean GEOM_AISShape::hasIO()
+{
   return !getIO().IsNull();
 }
 
@@ -210,13 +213,14 @@ void GEOM_AISShape::setName(const Standard_CString aName)
     IO->setName(aName);
 }
 
-Standard_CString GEOM_AISShape::getName(){
+Standard_CString GEOM_AISShape::getName()
+{
   return myName.ToCString();
 }
 
 void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
-                            const Handle(Prs3d_Presentation)& aPrs,
-                            const Standard_Integer aMode)
+                            const Handle(Prs3d_Presentation)&           aPrs,
+                            const Standard_Integer                      aMode)
 {  
   if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
 
@@ -351,12 +355,13 @@ void GEOM_AISShape::SetEdgesInShadingColor(const Quantity_Color &aCol)
   myEdgesInShadingColor = aCol;
 }
 
-void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol) {
+void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol)
+{
   myLabelColor = aCol;
 }
 
 void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, 
-                                       const Standard_Boolean aHighlight )
+                                       const Standard_Boolean             aHighlight )
 {
   Handle(AIS_InteractiveObject) anObj = this;
   Handle(AIS_InteractiveContext) anIC = GetContext();
@@ -402,8 +407,8 @@ void GEOM_AISShape::SetDisplayName(bool isDisplayed)
 }
 
 void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
-                                const Handle(Prs3d_Presentation)& aPrs,
-                                const Standard_Integer aMode)
+                                const Handle(Prs3d_Presentation)&           aPrs,
+                                const Standard_Integer                      aMode)
 {
   myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
 
@@ -416,7 +421,7 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
 
   if( isTopLevel() && switchTopLevel() )
     myDrawer->ShadingAspect()->SetColor( topLevelColor() );
-  else { 
+  else {
     if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT ))
       myDrawer->ShadingAspect()->SetColor(myShadingColor);
     else
@@ -440,11 +445,13 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
   }
 }
 
-Standard_Boolean GEOM_AISShape::isTopLevel() {
+Standard_Boolean GEOM_AISShape::isTopLevel()
+{
   return myTopLevel;
 }
 
-void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
+void GEOM_AISShape::setTopLevel(Standard_Boolean f)
+{
   if(f) {
     if(f != myTopLevel)
       myPrevDisplayMode = DisplayMode();
@@ -463,66 +470,74 @@ void GEOM_AISShape::setTopLevel(Standard_Boolean f) {
   myTopLevel = f;
 }
 
-void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode) {
+void GEOM_AISShape::setPrevDisplayMode(const Standard_Integer mode)
+{
   myPrevDisplayMode = mode;
 }
 
-Quantity_Color GEOM_AISShape::topLevelColor() {
+Quantity_Color GEOM_AISShape::topLevelColor()
+{
   return myTopLevelColor;
 }
 
-void GEOM_AISShape::setTopLevelColor(const Quantity_Color c) {
+void GEOM_AISShape::setTopLevelColor(const Quantity_Color c)
+{
   myTopLevelColor = c;
 }
 
-GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode() {
+GEOM_AISShape::TopLevelDispMode GEOM_AISShape::topLevelDisplayMode()
+{
   return myTopLevelDm;
 }
-void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm) {
+
+void GEOM_AISShape::setTopLevelDisplayMode(const GEOM_AISShape::TopLevelDispMode dm)
+{
   myTopLevelDm = dm;
 }
 
-Standard_Boolean GEOM_AISShape::switchTopLevel() {
+Standard_Boolean GEOM_AISShape::switchTopLevel()
+{
   return myTopLevelDm != TopShowAdditionalWActor;
 }
 
-Standard_Boolean GEOM_AISShape::toActivate() {
+Standard_Boolean GEOM_AISShape::toActivate()
+{
   return ( myTopLevel && myTopLevelDm == TopShowAdditionalWActor ) ? false : true;
 }
 
-void GEOM_AISShape::setFieldStepInfo( const GEOM::field_data_type theFieldDataType,
-                                      const int theFieldDimension,
-                                      const QList<QVariant>& theFieldStepData,
+void GEOM_AISShape::setFieldStepInfo( const GEOM::field_data_type    theFieldDataType,
+                                      const int                      theFieldDimension,
+                                      const QList<QVariant>&         theFieldStepData,
                                       const TCollection_AsciiString& theFieldStepName,
-                                      const double theFieldStepRangeMin,
-                                      const double theFieldStepRangeMax )
+                                      const double                   theFieldStepRangeMin,
+                                      const double                   theFieldStepRangeMax )
 {
-  myFieldDataType = theFieldDataType;
-  myFieldDimension = theFieldDimension;
-  myFieldStepData = theFieldStepData;
-  myFieldStepName = theFieldStepName;
+  myFieldDataType     = theFieldDataType;
+  myFieldDimension    = theFieldDimension;
+  myFieldStepData     = theFieldStepData;
+  myFieldStepName     = theFieldStepName;
   myFieldStepRangeMin = theFieldStepRangeMin;
   myFieldStepRangeMax = theFieldStepRangeMax;
 }
 
-void GEOM_AISShape::getFieldStepInfo( GEOM::field_data_type& theFieldDataType,
-                                      int& theFieldDimension,
-                                      QList<QVariant>& theFieldStepData,
+void GEOM_AISShape::getFieldStepInfo( GEOM::field_data_type&   theFieldDataType,
+                                      int&                     theFieldDimension,
+                                      QList<QVariant>&         theFieldStepData,
                                       TCollection_AsciiString& theFieldStepName,
-                                      double& theFieldStepRangeMin,
-                                      double& theFieldStepRangeMax ) const
+                                      double&                  theFieldStepRangeMin,
+                                      double&                  theFieldStepRangeMax ) const
 {
-  theFieldDataType = myFieldDataType;
-  theFieldDimension = myFieldDimension;
-  theFieldStepData = myFieldStepData;
-  theFieldStepName = myFieldStepName;
+  theFieldDataType     = myFieldDataType;
+  theFieldDimension    = myFieldDimension;
+  theFieldStepData     = myFieldStepData;
+  theFieldStepName     = myFieldStepName;
   theFieldStepRangeMin = myFieldStepRangeMin;
   theFieldStepRangeMax = myFieldStepRangeMax;
 }
 
 void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
-                               const bool theIsString,
-                               const bool theIsHighlight )
+                               const bool                        theIsString,
+                               const bool                        theIsHighlight )
 {
   if( myFieldStepData.isEmpty() )
     return;
@@ -532,10 +547,10 @@ void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
   TopAbs_ShapeEnum aShapeType = TopAbs_SHAPE;
   switch( myFieldDimension )
   {
-    case 0: aShapeType = TopAbs_VERTEX; break;
-    case 1: aShapeType = TopAbs_EDGE; break;
-    case 2: aShapeType = TopAbs_FACE; break;
-    case 3: aShapeType = TopAbs_SOLID; break;
+    case 0:  aShapeType = TopAbs_VERTEX; break;
+    case 1:  aShapeType = TopAbs_EDGE; break;
+    case 2:  aShapeType = TopAbs_FACE; break;
+    case 3:  aShapeType = TopAbs_SOLID; break;
     case -1: aShapeType = TopAbs_VERTEX; break;
   }
 
@@ -669,9 +684,41 @@ Standard_Boolean GEOM_AISShape::computeMassCenter( const TopoDS_Shape& theShape,
   }
   else if ( theShape.ShapeType() == TopAbs_FACE )
   {
-    BRepAdaptor_Surface surface( TopoDS::Face( theShape ));
-    theCenter = surface.Value( 0.5 * ( surface.FirstUParameter() + surface.LastUParameter() ),
-                               0.5 * ( surface.FirstVParameter() + surface.LastVParameter() ));
+    const TopoDS_Face& F = TopoDS::Face( theShape );
+    BRepAdaptor_Surface surface( F );
+
+    TopLoc_Location L;
+    Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation( F, L );
+    if ( !triangulation.IsNull() && triangulation->HasUVNodes() )
+    {
+      gp_XY C( 0, 0 );
+      double A = 0;
+      const TColgp_Array1OfPnt2d& uvArray = triangulation->UVNodes();
+      const Poly_Array1OfTriangle&  trias = triangulation->Triangles();
+      Standard_Integer n1,n2,n3;
+      for ( int iT = trias.Lower(); iT <= trias.Upper(); ++iT )
+      {
+        trias( iT ).Get( n1,n2,n3 );
+        const gp_Pnt2d& uv1 = uvArray( n1 );
+        const gp_Pnt2d& uv2 = uvArray( n2 );
+        const gp_Pnt2d& uv3 = uvArray( n3 );
+        double a = 0.5 * sqrt(( uv1.X() - uv3.X() ) * ( uv2.Y() - uv1.Y() ) -
+                              ( uv1.X() - uv2.X() ) * ( uv3.Y() - uv1.Y() ));
+        C += ( uv1.XY() + uv2.XY() + uv3.XY() ) / 3. * a;
+        A += a;
+      }
+      if ( A > std::numeric_limits<double>::min() )
+      {
+        C /= A;
+        theCenter = surface.Value( C.X(), C.Y() );
+        aNbPoints = 1;
+      }
+    }
+    if ( aNbPoints == 0 )
+    {
+      theCenter = surface.Value( 0.5 * ( surface.FirstUParameter() + surface.LastUParameter() ),
+                                 0.5 * ( surface.FirstVParameter() + surface.LastVParameter() ));
+    }
     aNbPoints = 1;
   }
 
diff --git a/src/OBJECT/GEOM_Annotation.cxx b/src/OBJECT/GEOM_Annotation.cxx
new file mode 100755 (executable)
index 0000000..2ab8f8e
--- /dev/null
@@ -0,0 +1,969 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  GEOM OBJECT : interactive object for Geometry entities visualization
+//  File   : GEOM_Annotation.hxx
+//  Module : GEOM
+//
+#include <GEOM_Annotation.hxx>
+
+// OCCT includes
+#include <AIS_InteractiveContext.hxx>
+#include <Font_FTFont.hxx>
+#include <Graphic3d_ArrayOfPoints.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_Camera.hxx>
+#include <Graphic3d_HorizontalTextAlignment.hxx>
+#include <Graphic3d_VerticalTextAlignment.hxx>
+#include <Graphic3d_Vec4.hxx>
+#include <OpenGl_Context.hxx>
+#include <OpenGl_GraphicDriver.hxx>
+#include <OpenGl_Group.hxx>
+#include <OpenGl_PrimitiveArray.hxx>
+#include <OpenGl_Structure.hxx>
+#include <OpenGl_Text.hxx>
+#include <OpenGl_View.hxx>
+#include <OpenGl_Workspace.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <Prs3d_Root.hxx>
+#include <Prs3d_Text.hxx>
+#include <Prs3d_IsoAspect.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <V3d_Viewer.hxx>
+#include <V3d_View.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT( GEOM_Annotation, AIS_InteractiveObject )
+
+// =======================================================================
+// function : Constructor
+// purpose  :
+// =======================================================================
+GEOM_Annotation::GEOM_Annotation() : AIS_InteractiveObject()
+{
+  SetPosition( gp_Pnt( 0.0, 0.0, 0.0 ) );
+  SetIsScreenFixed( Standard_False );
+  SetAttachPoint( gp_Pnt( 0.0, 0.0, 0.0 ) );
+  SetDisplayMode( 0 );
+  SetZLayer( Graphic3d_ZLayerId_Default );
+  SetAutoHide( Standard_True );
+#if OCC_VERSION_LARGE <= 0x07010001
+  SetHilightMode( HighlightAll );
+#endif
+  SetMutable( Standard_True );
+  SetDepthCulling( Standard_True );
+
+  Handle(Prs3d_TextAspect) aTextAspect = new Prs3d_TextAspect();
+  aTextAspect->SetHeight( 20.0 );
+  aTextAspect->SetColor( Quantity_Color( 1.0, 1.0, 1.0, Quantity_TOC_RGB ) );
+  myDrawer->SetTextAspect( aTextAspect );
+
+  Handle(Prs3d_LineAspect) aLineAspect =
+    new Prs3d_LineAspect( Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0 );
+  myDrawer->SetLineAspect( aLineAspect );
+
+  Handle(Prs3d_LineAspect) aHiddenLineAspect =
+    new Prs3d_LineAspect( Quantity_NOC_WHITE, Aspect_TOL_DOT, 1.0 );
+  myDrawer->SetHiddenLineAspect( aHiddenLineAspect );
+
+  Handle(Prs3d_PointAspect) aPointAspect =
+    new Prs3d_PointAspect( Aspect_TOM_POINT, Quantity_NOC_WHITE, 4.0 );
+  myDrawer->SetPointAspect( aPointAspect );
+}
+
+// =======================================================================
+// function : SetText
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetText( const TCollection_ExtendedString& theText )
+{
+  if (myText != theText)
+  {
+    SetToUpdate();
+  }
+
+  myText = theText;
+}
+
+// =======================================================================
+// function : SetPosition
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetPosition( const gp_Pnt& thePosition )
+{
+  SetPosition( thePosition, Standard_True );
+}
+
+// =======================================================================
+// function : SetPosition
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetPosition( const gp_Pnt& thePosition, const Standard_Boolean theUpdateSelection )
+{
+  myPosition = thePosition;
+
+  if ( !myIsScreenFixed )
+  {
+    Handle(Graphic3d_TransformPers) aPersistence =
+      new Graphic3d_TransformPers( Graphic3d_TMF_ZoomRotatePers, thePosition );
+
+    AIS_InteractiveObject::SetTransformPersistence( aPersistence );
+  }
+
+  SetToUpdate();
+
+  if( theUpdateSelection )
+  {
+    UpdateSelection();
+  }
+}
+
+// =======================================================================
+// function : SetIsScreenFixed
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetIsScreenFixed( const Standard_Boolean theIsFixed )
+{
+  myIsScreenFixed = theIsFixed;
+
+  Handle(Graphic3d_TransformPers) aPersistence;
+
+  if (!myIsScreenFixed)
+  {
+    aPersistence = new Graphic3d_TransformPers( Graphic3d_TMF_ZoomRotatePers, myPosition );
+  }
+  else
+  {
+    aPersistence = new Graphic3d_TransformPers( Graphic3d_TMF_2d, Aspect_TOTP_CENTER );
+  }
+
+  AIS_InteractiveObject::SetTransformPersistence( aPersistence );
+
+  SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
+
+  SetToUpdate();
+
+  UpdateSelection();
+}
+
+// =======================================================================
+// function : Set2dPosition
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::Set2dPosition( const Handle(V3d_View)& theView )
+{
+  if ( myIsScreenFixed )
+  {
+    return;
+  }
+
+  gp_Pnt aPosition2d = ConvertPosition2d( myPosition, myAttach, theView );
+
+  SetIsScreenFixed( Standard_True );
+
+  SetPosition( aPosition2d );
+}
+
+// =======================================================================
+// function : Set3dPosition
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::Set3dPosition( const Handle(V3d_View)& theView )
+{
+  if ( !myIsScreenFixed )
+  {
+    return;
+  }
+
+  gp_Pnt aPosition3d = ConvertPosition3d( myPosition, myAttach, theView );
+
+  SetIsScreenFixed( Standard_False );
+
+  SetPosition( aPosition3d );
+}
+
+// =======================================================================
+// function : SetAttachPoint
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetAttachPoint( const gp_Pnt& thePoint )
+{
+  myAttach = thePoint;
+}
+
+// =======================================================================
+// function : SetHilightShape
+// purpose  : Sets shape (annotated shape) that will be used for hilighting.
+// =======================================================================
+void GEOM_Annotation::SetHilightShape( const TopoDS_Shape& theShape )
+{
+  if ( myShape.IsEqual( theShape ) )
+  {
+    return;
+  }
+
+  myShape = theShape;
+  SetToUpdate();
+  UpdateSelection();
+}
+
+// =======================================================================
+// function : SetColor
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetColor( const Quantity_Color& theColor )
+{
+  SetTextColor( theColor );
+  SetLineColor( theColor );
+}
+
+// =======================================================================
+// function : SetTextColor
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetTextColor( const Quantity_Color& theColor )
+{
+  myDrawer->TextAspect()->SetColor( theColor );
+
+  SetToUpdate();
+}
+
+// =======================================================================
+// function : SetLineColor
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetLineColor( const Quantity_Color& theColor )
+{
+  myDrawer->LineAspect()->SetColor( theColor );
+  myDrawer->HiddenLineAspect()->SetColor( theColor );
+  myDrawer->PointAspect()->SetColor( theColor );
+
+  SetToUpdate();
+}
+
+// =======================================================================
+// function : SetLineWidth
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetLineWidth( const Standard_Real theLineWidth )
+{
+  if ( GetLineWidth() != theLineWidth )
+  {
+    myDrawer->LineAspect()->SetWidth( theLineWidth );
+    myDrawer->HiddenLineAspect()->SetWidth( theLineWidth );
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetLineStyle
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetLineStyle( const Aspect_TypeOfLine theStyle )
+{
+  if ( GetLineStyle() != theStyle )
+  {
+    myDrawer->LineAspect()->SetTypeOfLine( theStyle );
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetHiddenLineStyle
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetHiddenLineStyle( const Aspect_TypeOfLine theStyle )
+{
+  if ( GetHiddenLineStyle() != theStyle )
+  {
+    myDrawer->HiddenLineAspect()->SetTypeOfLine( theStyle );
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetTextHeight
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetTextHeight( const Standard_Real theHeight )
+{
+  if ( GetTextHeight() != theHeight )
+  {
+    myDrawer->TextAspect()->SetHeight( theHeight );
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetFontAspect
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetFontAspect( const Font_FontAspect theFontAspect )
+{
+  if ( GetFontAspect() != theFontAspect )
+  {
+    myDrawer->TextAspect()->Aspect()->SetTextFontAspect( theFontAspect );
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetFont
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetFont( const TCollection_AsciiString& theFont )
+{
+  if ( GetFont() != theFont )
+  {
+    myDrawer->TextAspect()->Aspect()->SetFont( theFont );
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetDepthCulling
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetDepthCulling( const Standard_Boolean theToEnable )
+{
+  if ( GetDepthCulling() != theToEnable )
+  {
+    myIsDepthCulling = theToEnable;
+
+    SetToUpdate();
+  }
+}
+
+// =======================================================================
+// function : SetDefaultZLayer
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::SetDefaultZLayer()
+{
+  SetZLayer( myIsScreenFixed ? Graphic3d_ZLayerId_Topmost : Graphic3d_ZLayerId_Default );
+
+  SetToUpdate();
+}
+
+// =======================================================================
+// function : GetDefaultPosition
+// purpose  :
+// =======================================================================
+gp_Pnt GEOM_Annotation::GetDefaultPosition( const Standard_Boolean theIsScreenFixed,
+                                            const gp_Pnt& theAttachPnt,
+                                            const Standard_Real theOffset,
+                                            const Handle(V3d_View)& theView )
+{
+  Standard_Integer aWinWidth = 0;
+  Standard_Integer aWinHeight = 0;
+  theView->Window()->Size( aWinWidth, aWinHeight );
+
+  gp_Pnt aPositionProj = theView->Camera()->Project( theAttachPnt );
+  aPositionProj.SetX( (aPositionProj.X() / 2.) * aWinWidth  + theOffset );
+  aPositionProj.SetY( (aPositionProj.Y() / 2.) * aWinHeight + theOffset );
+  aPositionProj.SetZ( 0.0 );
+
+  if ( theIsScreenFixed )
+  {
+    return aPositionProj;
+  }
+
+  gp_Pnt aAttachProj = theView->Camera()->Project ( theAttachPnt );
+  gp_Pnt aPosition3d = theView->Camera()->UnProject ( gp_Pnt ( aPositionProj.X() / aWinWidth * 2.,
+                                                               aPositionProj.Y() / aWinHeight * 2., 
+                                                               aAttachProj.Z() ));
+
+  return aPosition3d;
+}
+
+// =======================================================================
+// function : ConvertPosition2d
+// purpose  :
+// =======================================================================
+gp_Pnt GEOM_Annotation::ConvertPosition2d( const gp_Pnt& thePosition,
+                                           const gp_Pnt& /*theAttach*/,
+                                           const Handle(V3d_View)& theView )
+{
+  Standard_Integer aWinWidth = 0;
+  Standard_Integer aWinHeight = 0;
+  theView->Window()->Size( aWinWidth, aWinHeight );
+
+  gp_Pnt aPositionProj = theView->Camera()->Project( thePosition );
+  aPositionProj.SetX( (aPositionProj.X() / 2.) * aWinWidth );
+  aPositionProj.SetY( (aPositionProj.Y() / 2.) * aWinHeight );
+  aPositionProj.SetZ( 0.0 );
+  return aPositionProj;
+}
+
+// =======================================================================
+// function : ConvertPosition3d
+// purpose  :
+// =======================================================================
+gp_Pnt GEOM_Annotation::ConvertPosition3d( const gp_Pnt& thePosition,
+                                           const gp_Pnt& theAttach,
+                                           const Handle(V3d_View)& theView )
+{
+  Standard_Integer aWinWidth = 0;
+  Standard_Integer aWinHeight = 0;
+  theView->Window()->Size( aWinWidth, aWinHeight );
+
+  gp_Pnt aAttachProj = theView->Camera()->Project( theAttach );
+  gp_Pnt aPosition3d =  theView->Camera()->UnProject(
+    gp_Pnt ( thePosition.X() / aWinWidth * 2., thePosition.Y() / aWinHeight * 2., aAttachProj.Z() ) );
+
+  return aPosition3d;
+}
+
+// =======================================================================
+// function : Compute
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::Compute( const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/,
+                               const Handle(Prs3d_Presentation)&           thePresentation,
+                               const Standard_Integer                      theMode )
+{
+  thePresentation->Clear();
+
+  if (theMode < 0)
+  {
+    return;
+  }
+
+  Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast( Prs3d_Root::NewGroup( thePresentation ) );
+  if (aGroup.IsNull())
+  {
+    return;
+  }
+
+  Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
+  NCollection_String aUtfText( myText.ToExtString() );
+  OpenGl_Annotation* aAnnotationDraw =
+    new OpenGl_Annotation( this, static_cast<Standard_Integer>( anAsp->Height() ), aGroup->GlStruct()->GlDriver() );
+
+  aAnnotationDraw->SetDepthMode( 0 );
+  aGroup->SetGroupPrimitivesAspect( myDrawer->TextAspect()->Aspect() );
+  aGroup->SetGroupPrimitivesAspect( myDrawer->LineAspect()->Aspect() );
+  aGroup->SetGroupPrimitivesAspect( myDrawer->PointAspect()->Aspect() );
+  aGroup->AddElement( aAnnotationDraw );
+
+  if ( !myIsDepthCulling )
+  {
+    OpenGl_Annotation* aAnnotationDraw =
+      new OpenGl_Annotation( this, static_cast<Standard_Integer>( anAsp->Height() ), aGroup->GlStruct()->GlDriver() );
+
+    aAnnotationDraw->SetDepthMode( GL_GREATER );
+    aGroup->SetPrimitivesAspect( myDrawer->TextAspect()->Aspect() );
+    aGroup->SetPrimitivesAspect( myDrawer->HiddenLineAspect()->Aspect() );
+    aGroup->SetPrimitivesAspect( myDrawer->PointAspect()->Aspect() );
+    aGroup->AddElement( aAnnotationDraw );
+  }
+
+  Bnd_Box aBox = TextBoundingBox();
+  if ( myIsScreenFixed )
+  {
+    gp_Trsf aOffset2d;
+    aOffset2d.SetTranslation( gp_Vec( myPosition.X(), myPosition.Y(), 0.0 ) );
+    aBox = aBox.Transformed( aOffset2d );
+  }
+
+  const gp_Pnt aBoxMin = aBox.CornerMin();
+  const gp_Pnt aBoxMax = aBox.CornerMax();
+  aGroup->ChangeBoundingBox() = Graphic3d_BndBox4f (
+    Graphic3d_Vec4( static_cast<Standard_ShortReal>( aBoxMin.X() ),
+                    static_cast<Standard_ShortReal>( aBoxMin.Y() ),
+                    static_cast<Standard_ShortReal>( aBoxMin.Z() ), 1.0F ),
+    Graphic3d_Vec4( static_cast<Standard_ShortReal>( aBoxMax.X() ),
+                    static_cast<Standard_ShortReal>( aBoxMax.Y() ),
+                    static_cast<Standard_ShortReal>( aBoxMax.Z() ), 1.0F ) );
+}
+
+// =======================================================================
+// function : ComputeSelection
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
+                                        const Standard_Integer             theMode )
+{
+  if (theMode != GlobalSelectionMode())
+  {
+    return;
+  }
+
+  theSelection->Clear();
+
+  Bnd_Box aBox = TextBoundingBox();
+  if ( myIsScreenFixed )
+  {
+    gp_Trsf aOffset2d;
+    aOffset2d.SetTranslation( gp_Vec( myPosition.X(), myPosition.Y(), 0.0 ) );
+    aBox = aBox.Transformed( aOffset2d );
+  }
+
+  const Handle(GEOM_AnnotationOwner) anEntityOwner = new GEOM_AnnotationOwner( myShape, this, 10 );
+  const Handle(GEOM_AnnotationSensEntity) aSensitive =
+    new GEOM_AnnotationSensEntity( anEntityOwner, aBox, myIsDepthCulling );
+
+  theSelection->Add( aSensitive );
+}
+
+// =======================================================================
+// function : TextBoundingBox
+// purpose  :
+// =======================================================================
+Bnd_Box GEOM_Annotation::TextBoundingBox() const
+{
+  Handle(Prs3d_TextAspect) anAsp = myDrawer->TextAspect();
+  Font_FTFont aFont;
+  unsigned int aResolution = GetContext()->CurrentViewer()->DefaultRenderingParams().Resolution;
+  if ( aFont.Init( anAsp->Aspect()->Font().ToCString(),
+                   anAsp->Aspect()->GetTextFontAspect(),
+                  (unsigned int)anAsp->Height(),
+                  aResolution ) )
+  {
+    const NCollection_String aText( (Standard_Utf16Char* )myText.ToExtString() );
+    const Font_Rect aFontRect = aFont.BoundingBox( aText, Graphic3d_HTA_CENTER, Graphic3d_VTA_CENTER );
+    Bnd_Box aBox;
+    aBox.Add( gp_Pnt( aFontRect.Left, aFontRect.Bottom, 0.0 ) );
+    aBox.Add( gp_Pnt( aFontRect.Right, aFontRect.Top, 0.0 ) );
+    return aBox;
+  }
+
+  return Bnd_Box();
+}
+
+// =======================================================================
+// function : BeginDrag
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::BeginDrag()
+{
+  myStartPosition = myPosition;
+}
+
+// =======================================================================
+// function : Drag
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::Drag( const Standard_Integer theDx,
+                            const Standard_Integer theDy,
+                            const Handle(V3d_View)& theView )
+{
+  if (myIsScreenFixed)
+  {
+    SetPosition( myStartPosition.Translated( gp_Vec( theDx, theDy, 0.0 ) ), Standard_False );
+  }
+  else
+  {
+    Standard_Integer aWidth, aHeight;
+    theView->Window()->Size( aWidth, aHeight );
+    gp_Pnt aNormalized = theView->Camera()->Project( myStartPosition );
+    gp_Pnt aNormalizedDrag =
+      aNormalized.Translated( gp_Vec( static_cast<Standard_Real>(theDx) * 2.0 / aWidth,
+                                      static_cast<Standard_Real>(theDy) * 2.0 / aHeight,
+                                      0.0 ) );
+
+    SetPosition( theView->Camera()->UnProject( aNormalizedDrag ), Standard_False );
+  }
+}
+
+// =======================================================================
+// function : EndDrag
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::EndDrag()
+{
+  UpdateSelection();
+}
+
+// =======================================================================
+// function : UndoDrag
+// purpose  :
+// =======================================================================
+void GEOM_Annotation::UndoDrag()
+{
+  SetPosition( myStartPosition, Standard_True );
+}
+
+// =======================================================================
+// subclass : OpenGl_Annotation
+// function : Constructor
+// purpose  : 
+// =======================================================================
+GEOM_Annotation::OpenGl_Annotation::OpenGl_Annotation( GEOM_Annotation* theAnnotation,
+                                                       const Standard_Integer theTextHeight,
+                                                       const OpenGl_GraphicDriver* theDriver )
+: OpenGl_Element(),
+  myAISObject( theAnnotation ),
+  myText( theAnnotation->myText.ToExtString() ),
+  myDepthMode( 0 ),
+  myTextLineY( 0.f ),
+  myTextDPI( 0 )
+{
+  // graphical resources for drawing text and underline
+  myTextParams.Height = theTextHeight;
+  myTextParams.HAlign = Graphic3d_HTA_CENTER;
+  myTextParams.VAlign = Graphic3d_VTA_CENTER;
+  myTextDraw = new OpenGl_Text( myText.ToCString(), OpenGl_Vec3(), myTextParams );
+  myTextLineDraw = new OpenGl_PrimitiveArray( theDriver );
+
+  // graphical resources for drawing extension line and marker
+  Handle(Graphic3d_ArrayOfSegments)
+  aExtVertexArray = new Graphic3d_ArrayOfSegments( 2 );
+  aExtVertexArray->AddVertex( 0.0, 0.0, 0.0 );
+  aExtVertexArray->AddVertex( 0.0, 0.0, 1.0 );
+  myExtLineDraw = new OpenGl_PrimitiveArray( theDriver, Graphic3d_TOPA_SEGMENTS,
+    aExtVertexArray->Indices(), aExtVertexArray->Attributes(), aExtVertexArray->Bounds() );
+
+  Handle(Graphic3d_ArrayOfPoints)
+  aExtMakerArray = new Graphic3d_ArrayOfPoints( 1 );
+  aExtMakerArray->AddVertex( 0.0, 0.0, 1.0 );
+  myExtMarkerDraw = new OpenGl_PrimitiveArray( theDriver, Graphic3d_TOPA_POINTS,
+    aExtMakerArray->Indices(), aExtMakerArray->Attributes(), aExtMakerArray->Bounds() );
+}
+
+// =======================================================================
+// subclass : OpenGl_Annotation
+// function : Destructor
+// purpose  : 
+// =======================================================================
+GEOM_Annotation::OpenGl_Annotation::~OpenGl_Annotation()
+{
+  Release( NULL );
+}
+
+// =======================================================================
+// subclass : OpenGl_Annotation
+// function : Release
+// purpose  : Releases GL resources with the given GL context.
+// =======================================================================
+void GEOM_Annotation::OpenGl_Annotation::Release( OpenGl_Context* theCtx )
+{
+  if (myTextDraw)
+  {
+    myTextDraw->Release( theCtx );
+    myTextLineDraw->Release( theCtx );
+    myExtLineDraw->Release( theCtx );
+    myExtMarkerDraw->Release( theCtx );
+  }
+  myTextDraw      = NULL;
+  myTextLineDraw  = NULL;
+  myExtLineDraw   = NULL;
+  myExtMarkerDraw = NULL;
+}
+
+// =======================================================================
+// subclass : OpenGl_Annotation
+// function : Render
+// purpose  : Renders the annotation graphical elements.
+// =======================================================================
+void GEOM_Annotation::OpenGl_Annotation::Render( const Handle(OpenGl_Workspace)& theWorkspace ) const
+{
+  const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
+
+  // ---------------------------------------------------------------------
+  // initialize text's font and configure some properties when DPI changes
+  // ---------------------------------------------------------------------
+
+  const unsigned int aDPI = theWorkspace->View()->RenderingParams().Resolution;
+  if (myTextDPI != aDPI)
+  {
+    const OpenGl_AspectText* anAspect = theWorkspace->AspectText();
+
+    // getting string size will also initialize font library
+    myTextDraw->StringSize( aContext,
+      myText, *anAspect, myTextParams, aDPI,
+      myTextSize.x, myTextSize.a, myTextSize.d );
+
+    myTextDPI = aDPI;
+    myTextSize.y = myTextSize.a - myTextSize.d;
+    switch (myTextParams.HAlign)
+    {
+      case Graphic3d_HTA_LEFT:   myTextUnderline.x() = 0.f; break;
+      case Graphic3d_HTA_CENTER: myTextUnderline.x() = -myTextSize.x / 2.f; break;
+      case Graphic3d_HTA_RIGHT:  myTextUnderline.x() = -myTextSize.x; break;
+      default:
+        break;
+    }
+    switch (myTextParams.VAlign)
+    {
+      case Graphic3d_VTA_TOPFIRSTLINE:
+      case Graphic3d_VTA_TOP:    myTextUnderline.y() = -myTextSize.y; break;
+      case Graphic3d_VTA_CENTER: myTextUnderline.y() = -myTextSize.y / 2.f; break;
+      case Graphic3d_VTA_BOTTOM: myTextUnderline.y() = myTextSize.d; break;
+      default:
+        break;
+    }
+
+    Handle(Graphic3d_ArrayOfSegments)
+    aVertexArray = new Graphic3d_ArrayOfSegments( 2 );
+    aVertexArray->AddVertex( myTextUnderline.x(), myTextUnderline.y(), 0.0f );
+    aVertexArray->AddVertex( myTextUnderline.x() + myTextSize.x, myTextUnderline.y(), 0.0f );
+    myTextLineDraw->InitBuffers( aContext, Graphic3d_TOPA_SEGMENTS,
+      aVertexArray->Indices(), aVertexArray->Attributes(), aVertexArray->Bounds() );
+  }
+
+  // ---------------------------------------------
+  // perform view culling test by attachment point
+  // ---------------------------------------------
+
+  const OpenGl_Vec4 aAttach( static_cast<float>( myAISObject->myAttach.X() ),
+                             static_cast<float>( myAISObject->myAttach.Y() ),
+                             static_cast<float>( myAISObject->myAttach.Z() ), 1.F );
+
+  const Handle(Graphic3d_Camera) aCamera = theWorkspace->View()->Camera();
+  const OpenGl_Mat4& aCameraProjMat = aCamera->ProjectionMatrixF();
+  const OpenGl_Mat4& aCameraViewMat = aCamera->OrientationMatrixF();
+  const OpenGl_Vec4 aAttachView = aCameraViewMat * aAttach;
+  if (myAISObject->myIsAutoHide)
+  {
+    const OpenGl_Vec4 aAttachClip = aCameraProjMat * aAttachView;
+    if (Abs( aAttachClip.x() ) > aAttachClip.w()
+     || Abs( aAttachClip.y() ) > aAttachClip.w()
+     || Abs( aAttachClip.z() ) > aAttachClip.w())
+    {
+      return;
+    }
+  }
+#if OCC_VERSION_LARGE > 0x07010001
+  const Handle(Graphic3d_PresentationAttributes) aHighlightStyle = theWorkspace->HighlightStyle();
+  if (!aHighlightStyle.IsNull() && myAISObject->myHilightMode == HighlightLabel)
+  {
+    Handle(Graphic3d_PresentationAttributes) empty;
+    theWorkspace->SetHighlightStyle(empty);
+    theWorkspace->ApplyAspectLine();
+  }
+#else    
+  const bool toHighlight = theWorkspace->ToHighlight();
+
+  if (toHighlight && myAISObject->myHilightMode == HighlightLabel)
+  {
+    theWorkspace->SetHighlight( false );
+    theWorkspace->ApplyAspectLine();
+  }
+#endif
+  
+  GLint myOldDepthMode = 0;
+
+  if ( myDepthMode )
+  {
+    aContext->core11fwd->glGetIntegerv( GL_DEPTH_FUNC, &myOldDepthMode );
+    aContext->core11fwd->glDepthFunc( myDepthMode );
+  }
+
+  // -------------------------------------------------------------
+  // render text label in current persistence matrix and underline
+  // -------------------------------------------------------------
+
+  if ( myAISObject->myIsScreenFixed )
+  {
+    // use text position property instead of matrix setup 
+    // to avoid jittering when dragging text
+    myTextDraw->SetPosition( OpenGl_Vec3( static_cast<float>( myAISObject->myPosition.X() ),
+                                          static_cast<float>( myAISObject->myPosition.Y() ),
+                                          static_cast<float>( myAISObject->myPosition.Z() ) ) );
+  }
+
+  myTextDraw->Render( theWorkspace );
+
+  // ------------------------------------------------------------
+  // render annotation text's underline
+  // ------------------------------------------------------------
+
+  if ( myAISObject->myIsScreenFixed )
+  {
+    // setup local transformation (in 2D persistence reference)
+    // to represent position of annotation label on screen
+    const OpenGl_Mat4& aViewMat = aContext->WorldViewState.Current();
+    OpenGl_Mat4 aPositionMat;
+    aPositionMat.SetValue( 0, 3, static_cast<float>( myAISObject->myPosition.X() ) );
+    aPositionMat.SetValue( 1, 3, static_cast<float>( myAISObject->myPosition.Y() ) );
+    aPositionMat.SetValue( 2, 3, static_cast<float>( myAISObject->myPosition.Z() ) );
+    OpenGl_Mat4 aPosViewMat = aViewMat * aPositionMat;
+    aContext->WorldViewState.Push();
+    aContext->WorldViewState.SetCurrent( aPosViewMat );
+    aContext->ApplyModelViewMatrix();
+  }
+
+  myTextLineDraw->Render( theWorkspace );
+
+  // ------------------------------------------------------------
+  // render dynamic extension line using synthetic transformation
+  // ------------------------------------------------------------
+
+  OpenGl_Vec4 aCenter (0.f, 0.f, 0.f, 1.f);
+  switch (myTextParams.HAlign)
+  {
+    case Graphic3d_HTA_LEFT:   aCenter.x() =  myTextSize.x / 2.f; break;
+    case Graphic3d_HTA_CENTER: aCenter.x() = 0.f; break;
+    case Graphic3d_HTA_RIGHT:  aCenter.x() = -myTextSize.x / 2.f; break;
+    default: break;
+  }
+  switch (myTextParams.VAlign)
+  {
+    case Graphic3d_VTA_TOPFIRSTLINE:
+    case Graphic3d_VTA_TOP:    aCenter.y() = -myTextSize.y / 2.f; break;
+    case Graphic3d_VTA_CENTER: aCenter.y() = 0.f; break;
+    case Graphic3d_VTA_BOTTOM: aCenter.y() =  myTextSize.y / 2.f; break;
+    default: break;
+  }
+
+  // compute label's center in view coordinate space
+  const OpenGl_Mat4& aViewMat = aContext->WorldViewState.Current();
+  const OpenGl_Vec4 aCenterView = aViewMat * aCenter;
+
+  // the value below defines whether the extension line should be hanging
+  // on the left side of the label or on the right
+  const bool isLeftHanded = aAttachView.x() < aCenterView.x();
+
+  // compute extension line point at the text label in view coordinate space
+  const OpenGl_Vec4 aHingeView = aViewMat * OpenGl_Vec4(
+    ( isLeftHanded ? myTextUnderline.x() : myTextUnderline.x() + myTextSize.x ), myTextUnderline.y(), 0.0f, 1.0f );
+
+  // prepare matrix to specify geometry of extension line in view space
+  // by multiplication of unit z coordinate vector on given matrix.
+  OpenGl_Mat4 aExtGeometryMat;
+  aExtGeometryMat.SetColumn( 2, aAttachView - aHingeView );
+  aExtGeometryMat.SetColumn( 3, aHingeView );
+
+  // setup and draw
+  aContext->ModelWorldState.Push();
+  aContext->ModelWorldState.SetIdentity();
+  aContext->WorldViewState.Push();
+  aContext->WorldViewState.SetCurrent( aExtGeometryMat );
+  aContext->ApplyModelViewMatrix();
+
+  myExtLineDraw->Render( theWorkspace );
+  myExtMarkerDraw->Render( theWorkspace );
+
+  // ------------------------------------------------------------
+  // restore original state
+  // ------------------------------------------------------------
+
+  aContext->ModelWorldState.Pop();
+  aContext->WorldViewState.Pop();
+
+  if ( myOldDepthMode )
+  {
+    aContext->core11fwd->glDepthFunc( myOldDepthMode );
+  }
+
+  if ( myAISObject->myIsScreenFixed )
+  {
+    aContext->WorldViewState.Pop();
+  }
+
+  aContext->ApplyModelViewMatrix();
+  
+#if OCC_VERSION_LARGE > 0x07010001
+  theWorkspace->SetHighlightStyle(aHighlightStyle);
+#else
+  if ( toHighlight != theWorkspace->ToHighlight() )
+  {
+    theWorkspace->SetHighlight( toHighlight );
+  }
+#endif
+}
+
+// =======================================================================
+// subclass : GEOM_AnnotationOwner
+// function : HilightWithColor
+// purpose  : Perform highlighting of the presentation.
+// =======================================================================
+void GEOM_Annotation::GEOM_AnnotationOwner::HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
+#if OCC_VERSION_LARGE > 0x07010001
+                                                             const Handle(Prs3d_Drawer)& theStyle,
+#else                  
+                                                             const Handle(Graphic3d_HighlightStyle)& theStyle,
+#endif                 
+                                                              const Standard_Integer theMode )
+{
+  if ( myPrsSh.IsNull() )
+  {
+    Handle(Prs3d_Drawer) aDrawer = new Prs3d_Drawer;
+#if OCC_VERSION_LARGE > 0x07010001
+    aDrawer->Link( theStyle );
+#else
+    aDrawer->Link( Selectable()->HilightAttributes() );
+#endif
+    Handle(Prs3d_IsoAspect) aUIsoAspect = new Prs3d_IsoAspect(
+      aDrawer->UIsoAspect()->Aspect()->Color(),
+      aDrawer->UIsoAspect()->Aspect()->Type(),
+      aDrawer->UIsoAspect()->Aspect()->Width(), 0 );
+
+    Handle(Prs3d_IsoAspect) aVIsoAspect = new Prs3d_IsoAspect(
+      aDrawer->UIsoAspect()->Aspect()->Color(),
+      aDrawer->UIsoAspect()->Aspect()->Type(),
+      aDrawer->UIsoAspect()->Aspect()->Width(), 0 );
+
+    aDrawer->SetIsoOnPlane( Standard_False );
+    aDrawer->SetUIsoAspect( aUIsoAspect );
+    aDrawer->SetVIsoAspect( aVIsoAspect );
+    myPrsSh = new StdSelect_Shape( myShape, aDrawer );
+  }
+
+  myPrsSh->SetZLayer ( Selectable()->ZLayer() );
+  
+  thePM->Color( Selectable(), theStyle, theMode, NULL, Graphic3d_ZLayerId_Topmost );
+
+  thePM->Color( myPrsSh, theStyle, theMode, Selectable(), Graphic3d_ZLayerId_Topmost );
+}
+
+// =======================================================================
+// subclass : GEOM_AnnotationOwner
+// function : Unhilight
+// purpose  : Removes highlighting from the type of shape.
+// =======================================================================
+void GEOM_Annotation::GEOM_AnnotationOwner::Unhilight ( const Handle(PrsMgr_PresentationManager)& thePM,
+                                                        const Standard_Integer theMode )
+{
+  SelectMgr_EntityOwner::Unhilight( thePM, theMode );
+  
+#if OCC_VERSION_LARGE > 0x07010001
+  thePM->Unhighlight( myPrsSh );
+#else
+  thePM->Unhighlight( myPrsSh, theMode );
+#endif
+}
+
+// =======================================================================
+// subclass : GEOM_AnnotationOwner
+// function : Clear
+// purpose  : Clears the presentation manager object aPM of all shapes
+// with the given selection mode.
+// =======================================================================
+void GEOM_Annotation::GEOM_AnnotationOwner::Clear ( const Handle(PrsMgr_PresentationManager)& thePM,
+                                                    const Standard_Integer theMode )
+{
+  SelectMgr_EntityOwner::Clear( thePM, theMode );
+
+  if ( !myPrsSh.IsNull() ) {
+    thePM->Clear( myPrsSh, theMode );
+  }
+
+  myPrsSh.Nullify();
+}
diff --git a/src/OBJECT/GEOM_Annotation.hxx b/src/OBJECT/GEOM_Annotation.hxx
new file mode 100755 (executable)
index 0000000..00fc809
--- /dev/null
@@ -0,0 +1,423 @@
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  GEOM OBJECT : interactive object for Geometry entities visualization
+//  File   : GEOM_Annotation.hxx
+//  Module : GEOM
+//
+#ifndef GEOM_Annotation_HeaderFile
+#define GEOM_Annotation_HeaderFile
+
+#include <Basics_OCCTVersion.hxx>
+
+#include <AIS_InteractiveObject.hxx>
+#include <Bnd_Box.hxx>
+#include <Font_FontAspect.hxx>
+#include <gp_Pnt.hxx>
+#include <NCollection_Handle.hxx>
+#include <NCollection_String.hxx>
+#include <OpenGl_Element.hxx>
+#include <OpenGl_TextParam.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_TextAspect.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <SelectMgr_EntityOwner.hxx>
+#include <StdSelect_Shape.hxx>
+#include <TCollection_ExtendedString.hxx>
+
+class OpenGl_GraphicDriver;
+class OpenGl_PrimitiveArray;
+class OpenGl_Text;
+class V3d_View;
+
+/*!
+ * \class GEOM_Annotation
+ * \brief Interactive object, representating annotation entity
+ */
+class GEOM_Annotation : public AIS_InteractiveObject
+{
+public:
+
+  DEFINE_STANDARD_RTTIEXT( GEOM_Annotation, AIS_InteractiveObject )
+
+  //! Enumerates supported highlighting modes.
+  //! - HighlightAll   : all elements of the annotation are highlighted.
+  //! - HighlightLabel : only annotation label is highlighted.
+  enum HighlightMode
+  {
+    HighlightAll   = 0,
+    HighlightLabel = 1
+  };
+
+public:
+
+  //! Constructor.
+  Standard_EXPORT GEOM_Annotation();
+
+  //! Destructor.
+  virtual ~GEOM_Annotation() {}
+
+  //! Sets annotation text string.
+  //! \param theText [in] the string displayed in annotation label.
+  Standard_EXPORT void SetText( const TCollection_ExtendedString& theText );
+
+  //! Returns annotation text string.
+  const TCollection_ExtendedString& GetText() const { return myText; }
+
+  //! Sets position of the annotation text label.
+  //! \param thePosition [in] the cartesian point defining the position of lower left
+  //!        corner of the text label. When displayed in fixed screen position mode
+  //!        (\sa SetScreenFixed) the position is defined as {x,y} pixel coordinate
+  //!        of window space, otherwise 3D point defined in world's coordinate system
+  //!        is used.
+  Standard_EXPORT void SetPosition( const gp_Pnt& thePosition );
+
+  //! Returns position of the annotation text label.
+  const gp_Pnt& GetPosition() const { return myPosition; }
+
+  //! Sets or disables "2D screen fixed" positioning mode. In this mode the annotation
+  //! is fixed at predefined pixel location in the window coordinate space. Other mode
+  //! is "3D screen aligned" positioning, when the label is aligned in plane of the
+  //! screen, while its position is a 3D point defined in world's coordinate system.
+  Standard_EXPORT void SetIsScreenFixed( const Standard_Boolean theIsFixed );
+
+  //! Retuns value of "screen fixed" positioning mode.
+  Standard_Boolean GetIsScreenFixed() const { return myIsScreenFixed; }
+
+  //! Converts annotation position to screen fixed coordinates and
+  //! modifies its "2D screen fixed" flag correspondingly.
+  //! @param theView [in] the view to perform projection of coordinates.
+  Standard_EXPORT void Set2dPosition( const Handle(V3d_View)& theView );
+
+  //! Converts annotation position from screen fixed coordinates
+  //! to 3D position and modifies its "2D screen fixed" flag
+  //! correspondingly.
+  //! @param theView [in] the view to perform projection of coordinates.
+  Standard_EXPORT void Set3dPosition( const Handle(V3d_View)& theView );
+
+  //! Sets attachment point of extension line.
+  //! \param thePoint [in] the 3D cartesian point defined in world's coordinate system
+  //!        (a point on annotated geometry).
+  Standard_EXPORT void SetAttachPoint( const gp_Pnt& thePoint );
+
+  //! Returns attachment point of extension line.
+  const gp_Pnt& GetAttachPoint() const { return myAttach; }
+
+  //! Sets shape (annotated shape) that will be used for hilighting.
+  Standard_EXPORT void SetHilightShape( const TopoDS_Shape& theShape );
+
+  //! Returns the hilighting shape.
+  const TopoDS_Shape HilightShape() const { return myShape; }
+
+public:
+
+  //! Sets color for the presentation.
+  Standard_EXPORT virtual void SetColor( const Quantity_Color& theColor ) Standard_OVERRIDE;
+
+  //! Sets text color.
+  Standard_EXPORT void SetTextColor( const Quantity_Color& theColor );
+
+  //! Returns color for the text's label.
+  Quantity_Color GetTextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
+
+  //! Sets line's color.
+  Standard_EXPORT void SetLineColor( const Quantity_Color& theColor);
+
+   //! Returns color for the connection line.
+  Quantity_Color GetLineColor() const { return myDrawer->LineAspect()->Aspect()->Color(); }
+
+  //! Sets line width to be used for drawing the annotation's extension line and underline.
+  Standard_EXPORT void SetLineWidth( const Standard_Real theLineWidth );
+
+  //! Returns line width for drawing the annotation's extension line and underline.
+  Standard_Real GetLineWidth() const { return myDrawer->LineAspect()->Aspect()->Width(); }
+
+  //! Sets style of connection line.
+  Standard_EXPORT void SetLineStyle( const Aspect_TypeOfLine theStyle );
+
+  //! Retusn style of connection line.
+  Aspect_TypeOfLine GetLineStyle() const { return myDrawer->LineAspect()->Aspect()->Type(); }
+
+  //! Sets style of hidden connection line.
+  Standard_EXPORT void SetHiddenLineStyle( const Aspect_TypeOfLine theStyle );
+
+  //! Retusn style of hidden connection line.
+  Aspect_TypeOfLine GetHiddenLineStyle() const { return myDrawer->HiddenLineAspect()->Aspect()->Type(); }
+
+  //! Sets text height in pixels.
+  Standard_EXPORT void SetTextHeight( const Standard_Real theHeight );
+
+  //! Returns text's height in pixels.
+  Standard_Real GetTextHeight() const { return myDrawer->TextAspect()->Height(); }
+
+  //! Sets font aspect for label.
+  Standard_EXPORT void SetFontAspect( const Font_FontAspect theFontAspect );
+
+  //! Returns label's font aspect.
+  Font_FontAspect GetFontAspect() const { return myDrawer->TextAspect()->Aspect()->GetTextFontAspect(); }
+
+  //! Sets font used for drawing the label.
+  Standard_EXPORT void SetFont( const TCollection_AsciiString& theFont );
+
+  //! Returns font used for drawing the label.
+  TCollection_AsciiString GetFont() const { return myDrawer->TextAspect()->Aspect()->Font(); }
+
+  //! Sets annotation auto-hiding option.
+  //! \param theIsEnable [in] the option flag. If passed true, the annotation 
+  //!        will be automatically hidden in the view if the attachment point
+  //!        goes outside of the view.
+  void SetAutoHide( const Standard_Boolean theIsEnable ) { myIsAutoHide = theIsEnable; }
+
+  //! Returns current state of the auto-hiding option.
+  Standard_Boolean GetAutoHide() const { return myIsAutoHide; }
+
+  //! Sets highlight mode used for display of presentation.
+  //! \param theMode [in] the one of the supported highlight modes.
+  void SetHighlightMode( const HighlightMode theMode ) { myHilightMode = theMode; }
+
+  //! Returns highlight mode
+  HighlightMode GetHilightMode() const { return myHilightMode; }
+
+  //! Sets special flag that allows disabling depth testing when rendering
+  //! the graphical presentation. When disable the hidden parts such as
+  //! lines and text become visible and a rendered with another drawing
+  //! aspect. This mode should be explicitly used with setting top layer
+  //! for the presentation. Otherwise the behavior is undefined.
+  Standard_EXPORT void SetDepthCulling( const Standard_Boolean theToEnable );
+
+  //! Returns depth culling state.
+  Standard_Boolean GetDepthCulling() const { return myIsDepthCulling; }
+
+// Helper tools:
+public:
+
+  //! Restores default z-layer for this presentation.
+  Standard_EXPORT void SetDefaultZLayer();
+
+  //! Returns default position for placing annotation when its attachment point
+  //! has been determined.
+  //! @param theIsScreenFixed [in] the state of annotation's "2D screen fixed" mode.
+  //! @param theAttachPnt [in] the attachment point.
+  //! @param theOffset [in] the offset value for placing the position relative to attachment.s
+  //! @param theView [in] the view for projecting coordinates.
+  Standard_EXPORT static gp_Pnt GetDefaultPosition( const Standard_Boolean theIsScreenFixed,
+                                                    const gp_Pnt& theAttachPnt,
+                                                    const Standard_Real theOffset,
+                                                    const Handle(V3d_View)& theView );
+
+  //! Converts 3d position to 2d on screen point.
+  //! @param thePosition [in] the 3d position.
+  //! @param theAttach [in] the attachment point.
+  //! @param theView [in] the view for projecting coordinates.
+  Standard_EXPORT static gp_Pnt ConvertPosition2d( const gp_Pnt& thePosition,
+                                                   const gp_Pnt& theAttach,
+                                                   const Handle(V3d_View)& theView );
+
+  //! Converts 2d position to 3d point.
+  //! @param thePosition [in] the 2d position.
+  //! @param theAttach [in] the attachment point.
+  //! @param theView [in] the view for projecting coordinates.
+  Standard_EXPORT static gp_Pnt ConvertPosition3d( const gp_Pnt& thePosition,
+                                                   const gp_Pnt& theAttach,
+                                                   const Handle(V3d_View)& theView );
+
+// Interactive dragging:
+public:
+
+  //! Prepares necessary data to perform dragging.
+  Standard_EXPORT void BeginDrag();
+
+  //! Drags annotation presentation in the screen plane using the given pixel delta.
+  //! \param theDx, theDy [in] the drag offset in pixels (from beginning of dragging).
+  //! \param theView [in] the current view for evaluating drag with 3D position mode.
+  Standard_EXPORT void Drag( const Standard_Integer theDx,
+                             const Standard_Integer theDy,
+                             const Handle(V3d_View)& theView );
+
+  //! Perform necessary update when dragging is finished.
+  Standard_EXPORT void EndDrag();
+
+  //! Perform necessary update when dragging need undo.
+  Standard_EXPORT void UndoDrag();
+
+private:
+
+  virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                        const Handle(Prs3d_Presentation)& thePresentation,
+                        const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+  virtual void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
+                                 const Standard_Integer theMode ) Standard_OVERRIDE;
+
+  virtual void setLocalTransformation( const Handle(Geom_Transformation)& /*theTransformation*/ ) Standard_OVERRIDE {}
+
+  virtual void SetTransformPersistence( const Handle(Graphic3d_TransformPers)& /*theTrsfPers*/ ) Standard_OVERRIDE {}
+
+  Bnd_Box TextBoundingBox() const;
+
+  void SetPosition( const gp_Pnt& thePosition, const Standard_Boolean theUpdateSelection );
+
+private:
+
+  gp_Pnt myAttach; //!< Attachment point of extension line.
+  gp_Pnt myPosition; //!< Position of text label.
+  gp_Pnt myStartPosition; //!< Position before starting dragging operation.
+  Standard_Boolean myIsScreenFixed; //!< Flag indicating whether "screen fixed" positioning mode is turned on or off.
+  Standard_Boolean myIsAutoHide; //!< Flag indicating whether "auto-hiding" option is turned on.
+  Standard_Boolean myIsDepthCulling; //!< Flag indiciating whether the "depth culling" is turned on.
+  HighlightMode myHilightMode; //!< Highlight mode for presentation.
+  TCollection_ExtendedString myText; //!< Text string of the label presentation.
+  TopoDS_Shape myShape; //!< Hilighting shape.
+
+private:
+
+  //! Custom element implementing dynamic rendering of 3D annotation
+  //! and invoking dynamic callback in presentation class.
+  class OpenGl_Annotation : public OpenGl_Element
+  {
+  public:
+
+    //! Constructor. Some of the input properties are assigned by reference for dynamic draw
+    //! (it is not likely that GL element will ever outlive the interactive object).
+    //! \param theAnnotation [in] the instance of interactive presentation class.
+    //! \param theTextHeight [in] the height of the text label.
+    //! \param theDriver [in] the instance of graphical driver required for initialization.
+    OpenGl_Annotation( GEOM_Annotation* theAnnotation,
+                       const Standard_Integer theTextHeight,
+                       const OpenGl_GraphicDriver* theDriver );
+
+    //! Destructor. Releases GL resources with NULL context.
+    virtual ~OpenGl_Annotation();
+
+    //! Releases GL resources with the given GL context.
+    virtual void Release( OpenGl_Context* theCtx ) Standard_OVERRIDE;
+
+    //! Renders the annotation graphical elements.
+    virtual void Render( const Handle(OpenGl_Workspace)& theWorkspace ) const Standard_OVERRIDE;
+
+    void SetDepthMode( const int theMode ) { myDepthMode = theMode; }
+
+  private:
+
+    struct TextSize {
+      float x; // width
+      float y; // height
+      float a; // ascent
+      float d; // descent
+    };
+
+    GEOM_Annotation* myAISObject;           //!< Instance of presentation class.
+    NCollection_String myText;              //!< Text string of annotation label.
+    OpenGl_TextParam myTextParams;          //!< Text draw parameters.
+    OpenGl_Text* myTextDraw;                //!< Text draw element.
+    OpenGl_PrimitiveArray* myTextLineDraw;  //!< Text underline draw element.
+    OpenGl_PrimitiveArray* myExtLineDraw;   //!< Extension line draw element.
+    OpenGl_PrimitiveArray* myExtMarkerDraw; //!< Extension marker draw element.
+    int myDepthMode;                        //!< Depth mode for drawing hidden line presentation.
+    mutable float myTextLineY;              //!< Text's underlines relative position.
+    mutable TextSize myTextSize;            //!< Text's size parameters
+    mutable Graphic3d_Vec2 myTextUnderline; //!< Text's underline position.
+    mutable unsigned int myTextDPI;         //!< Text's DPI scale used for last rendering.
+  };
+
+  friend class OpenGl_Annotation; // allow opengl element to get private data and invoke callback methods
+
+public:
+
+  //! Custom entity owner implementing correct highlight for topmost mode.
+  class GEOM_AnnotationOwner : public SelectMgr_EntityOwner
+  {
+  public:
+
+    //! Constructor.
+    GEOM_AnnotationOwner( const TopoDS_Shape& theShape,
+                          const Handle(SelectMgr_SelectableObject)& theSelectable,
+                          const Standard_Integer thePriority )
+      : SelectMgr_EntityOwner( theSelectable, thePriority ),
+        myShape( theShape ) {}
+
+    //! Perform highlighting of the presentation.
+    //! \param thePresentationMgr [in] the presentation manager.
+    //! \param theColor [in] the highlighting color.
+    //! \param theMode [in] the display mode.
+    virtual void
+      HilightWithColor( const Handle(PrsMgr_PresentationManager3d)& thePM,
+#if OCC_VERSION_LARGE > 0x07010001
+                       const Handle(Prs3d_Drawer)& theStyle,
+#else                  
+                       const Handle(Graphic3d_HighlightStyle)& theStyle,
+#endif                 
+                        const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+    //! Removes highlighting from the type of shape.
+    virtual void
+      Unhilight ( const Handle(PrsMgr_PresentationManager)& thePM,
+                  const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+    //! Clears the presentation manager object aPM of all shapes
+    //! with the given selection mode.
+    virtual void
+      Clear ( const Handle(PrsMgr_PresentationManager)& thePM,
+              const Standard_Integer theMode = 0 ) Standard_OVERRIDE;
+
+  private:
+
+    TopoDS_Shape myShape;
+    Handle(StdSelect_Shape) myPrsSh;
+  };
+
+  //! Custom sensitive entity with implementing option to support selection
+  //! with depth culling flag turned off.
+  class GEOM_AnnotationSensEntity : public Select3D_SensitiveBox
+  {
+  public:
+
+    //! Constructor.
+    GEOM_AnnotationSensEntity( const Handle(SelectMgr_EntityOwner)& theOwner,
+                               const Bnd_Box& theBox,
+                               const Standard_Boolean theIsDepthCulling )
+      : Select3D_SensitiveBox( theOwner, theBox ),
+        myIsDepthCulling( theIsDepthCulling ) {}
+
+    //! Checks whether the box overlaps current selecting volume.
+    virtual Standard_Boolean Matches( SelectBasics_SelectingVolumeManager& theMgr,
+                                      SelectBasics_PickResult& thePickResult ) Standard_OVERRIDE
+    {
+      const Standard_Boolean isMatches = Select3D_SensitiveBox::Matches( theMgr, thePickResult );
+      if ( !myIsDepthCulling )
+      {
+        thePickResult = SelectBasics_PickResult( -DBL_MAX, thePickResult.DistToGeomCenter() );
+      }
+      return isMatches;
+    }
+
+  private:
+
+    Standard_Boolean myIsDepthCulling;
+  };
+};
+
+DEFINE_STANDARD_HANDLE( GEOM_Annotation, AIS_InteractiveObject )
+
+#endif
index 17b91bade9c2e7ab2ac51351211118b8f8c8b025..957753d48575ce910242affa9ef3294ed3a33f5e 100644 (file)
@@ -104,7 +104,9 @@ namespace GEOM
       // texture
       "Texture",         // -
       // dimensions
-      "Dimensions"       // -
+      "Dimensions",      // -
+      // shape annotations
+      "ShapeAnnotations" // -
     };
     return ( type >= GEOM::Visibility && type <= GEOM::LastProperty ) ? names[type] : QString();
   }
index 873f6b2a536f57c8cef1a03bf11d99b557ce3fa7..de6c72909d9f9a88bc80017d7696cb5b1962ba85 100644 (file)
@@ -58,7 +58,8 @@ namespace GEOM
     OutlineColor,
     Texture,
     Dimensions,
-    LastProperty = Dimensions,
+    ShapeAnnotations,
+    LastProperty = ShapeAnnotations,
   };
 
   GEOM_OBJECT_EXPORT double minDeflection();
index 516f34abe7b8f96ade0cf39ea5b31dd8da556494..fdb7d5bb89debb04c4fabfe18ac47dddd9c8b208 100644 (file)
@@ -369,7 +369,7 @@ private:
   \brief Constructor
   \internal
 */
-Sketcher_Profile::Functor::Functor() : myError( 0 ), myNumberOfCommand( 0 ), myOk( true )
+Sketcher_Profile::Functor::Functor() : myNumberOfCommand( 0 ), myError( 0 ), myOk( true )
 {
 }
 
index 70f0475b695ecc8687adee9c1f4cd5f50ba6a88e..7d0ced2eb3438db50ea42c179bad0f14e3675c5e 100644 (file)
@@ -114,59 +114,59 @@ bool STLPlugin_GUI::importSTL( SUIT_Desktop* parent )
   GEOM::GEOM_IOperations_var op = GeometryGUI::GetGeomGen()->GetPluginOperations( dsStudy->StudyId(), "STLPluginEngine" );
   STLOpPtr stlOp = GEOM::ISTLOperations::_narrow( op );
   if ( stlOp.isNull() ) return false;
-  
+
   QStringList fileNames = app->getOpenFileNames( SUIT_FileDlg::getLastVisitedPath().isEmpty() ? QDir::currentPath() : QString(""),
-                                                tr( "STL_FILES" ),
-                                                tr( "IMPORT_TITLE" ),
-                                                parent );
+                                                 tr( "STL_FILES" ),
+                                                 tr( "IMPORT_TITLE" ),
+                                                 parent );
   if ( fileNames.count() > 0 )
   {
     QStringList entryList;
     QStringList errors;
-    
+
     foreach( QString fileName, fileNames )
     {
       SUIT_OverrideCursor wc;
       GEOM_Operation transaction( app, stlOp.get() );
-      
+
       try
       {
-       app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) );
-       transaction.start();
-       GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() );
-       if ( result->length() > 0 && stlOp->IsDone() )
-       {
-         GEOM::GEOM_Object_var main = result[0];
-         QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
-         SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
-                                                                               SALOMEDS::SObject::_nil(),
-                                                                               main.in(),
-                                                                               publishName.toUtf8().constData() );
-         
-         entryList.append( so->GetID() );
-         transaction.commit();
-         GEOM_Displayer( study ).Display( main.in() );
+        app->putInfo( tr( "GEOM_PRP_LOADING" ).arg( fileName ) );
+        transaction.start();
+        GEOM::ListOfGO_var result = stlOp->ImportSTL( fileName.toUtf8().constData() );
+        if ( result->length() > 0 && stlOp->IsDone() )
+        {
+          GEOM::GEOM_Object_var main = result[0];
+          QString publishName = GEOMBase::GetDefaultName( SUIT_Tools::file( fileName, true ) );
+          SALOMEDS::SObject_var so = GeometryGUI::GetGeomGen()->PublishInStudy( dsStudy,
+                                                                                SALOMEDS::SObject::_nil(),
+                                                                                main.in(),
+                                                                                publishName.toUtf8().constData() );
+
+          entryList.append( so->GetID() );
+          transaction.commit();
+          GEOM_Displayer( study ).Display( main.in() );
           main->UnRegister();
-       }
-       else
-       {
-         transaction.abort();
-         errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) );
-       }
+        }
+        else
+        {
+          transaction.abort();
+          errors.append( QString( "%1 : %2" ).arg( fileName ).arg( stlOp->GetErrorCode() ) );
+        }
       }
       catch( const SALOME::SALOME_Exception& e )
       {
-       transaction.abort();
+        transaction.abort();
       }
     }
     getGeometryGUI()->updateObjBrowser( true );
     app->browseObjects( entryList );
-    
+
     if ( errors.count() > 0 )
     {
       SUIT_MessageBox::critical( parent,
-                                tr( "GEOM_ERROR" ),
-                                tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
+                                 tr( "GEOM_ERROR" ),
+                                 tr( "GEOM_IMPORT_ERRORS" ) + "\n" + errors.join( "\n" ) );
     }
   }
   return fileNames.count() > 0;
@@ -207,12 +207,12 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent )
     double deflection = 0.;
     bool isRelative = false;
     QString fileName = STLPlugin_ExportDlg::getFileName( io,
-                                                        tr( "STL_FILES" ),
-                                                        tr( "EXPORT_TITLE" ),
-                                                        parent,
-                                                        isASCII,
-                                                        deflection,
-                                                        isRelative );
+                                                         tr( "STL_FILES" ),
+                                                         tr( "EXPORT_TITLE" ),
+                                                         parent,
+                                                         isASCII,
+                                                         deflection,
+                                                         isRelative );
 
     if ( fileName.isEmpty() )
       return false;
@@ -230,15 +230,15 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent )
       
       if ( stlOp->IsDone() )
       {
-       transaction.commit();
+        transaction.commit();
       }
       else
       {
-       transaction.abort();
-       SUIT_MessageBox::critical( parent,
-                                  tr( "GEOM_ERROR" ),
-                                  tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) );
-       return false;
+        transaction.abort();
+        SUIT_MessageBox::critical( parent,
+                                   tr( "GEOM_ERROR" ),
+                                   tr( "GEOM_PRP_ABORT" ) + "\n" + tr( stlOp->GetErrorCode() ) );
+        return false;
       }
     }
     catch ( const SALOME::SALOME_Exception& e )
@@ -252,8 +252,8 @@ bool STLPlugin_GUI::exportSTL( SUIT_Desktop* parent )
   if ( !ok )
   {
     SUIT_MessageBox::warning( parent,
-                             tr( "WRN_WARNING" ),
-                             tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
+                              tr( "WRN_WARNING" ),
+                              tr( "GEOM_WRN_NO_APPROPRIATE_SELECTION" ) );
   }
   return ok;
 }
index d9adfbfabd65f43eab6b25085d0f1b302c3f348b..799aa8f6ef0bd067bcb30b77d67e341f3d335224 100644 (file)
@@ -279,47 +279,47 @@ Handle(Geom_Surface) ShHealOper_FillHoles::buildSurface(const TopoDS_Wire& theWi
 {
   Handle(Geom_BSplineSurface) aSurf;
   try {
-      GeomPlate_BuildPlateSurface aBuilder(myDegree, myNbPtsOnCur, myNbIter,
-                                                 myTol2d, myTol3d, myTolAng, myTolCrv);
-      TopoDS_Iterator aIter;
-      for(aIter.Initialize (theWire); aIter.More(); aIter.Next()) {
-
-        TopoDS_Edge ae = TopoDS::Edge(aIter.Value());
-        BRepAdaptor_Curve adC(ae);
-        Handle(BRepAdaptor_HCurve) aHAD= new BRepAdaptor_HCurve(adC);
-        Handle(BRepFill_CurveConstraint) aConst =
-            new BRepFill_CurveConstraint (Handle(Adaptor3d_HCurve)::DownCast(aHAD), (Standard_Integer) GeomAbs_C0, myNbPtsOnCur, myTol3d);
-        //Handle(GeomPlate_CurveConstraint) aConst =
-         // new GeomPlate_CurveConstraint(aHAD, (Standard_Integer) GeomAbs_C0, myNbPtsOnCur, myTol3d);
-        aBuilder.Add (Handle(GeomPlate_CurveConstraint)::DownCast(aConst));
-      }
-      aBuilder.Perform();
-      if(!aBuilder.IsDone())
-        return aSurf;
-      Handle(GeomPlate_Surface) aPlSurf = aBuilder.Surface();
-
-      //for filling holes without initial specified surface
-      //the initial surface should be build by GeomPlate itself
-      //following code was taken from BRepFill_Filling::Build
-
-      Standard_Real aDist = aBuilder.G0Error();
-      TColgp_SequenceOfXY S2d;
-      TColgp_SequenceOfXYZ S3d;
-      S2d.Clear();
-      S3d.Clear();
-      aBuilder.Disc2dContour(4,S2d);
-      aBuilder.Disc3dContour(4,0,S3d);
-      Standard_Real amaxTol = Max( myTol3d, 10* aDist);
-      GeomPlate_PlateG0Criterion Criterion( S2d, S3d, amaxTol );
-      GeomPlate_MakeApprox Approx( aPlSurf, Criterion, myTol3d, myMaxSeg, myMaxDeg );
-      aSurf = Approx.Surface();
-      if(aSurf.IsNull())
-        return aSurf;
-
-      theCurves2d = aBuilder.Curves2d();
-      theOrders    = aBuilder.Order();
-      theSenses    = aBuilder.Sense();
+    GeomPlate_BuildPlateSurface aBuilder(myDegree, myNbPtsOnCur, myNbIter,
+                                         myTol2d, myTol3d, myTolAng, myTolCrv);
+    TopoDS_Iterator aIter;
+    for(aIter.Initialize (theWire); aIter.More(); aIter.Next()) {
+
+      TopoDS_Edge ae = TopoDS::Edge(aIter.Value());
+      BRepAdaptor_Curve adC(ae);
+      Handle(BRepAdaptor_HCurve) aHAD= new BRepAdaptor_HCurve(adC);
+      // Handle(BRepFill_CurveConstraint) aConst =
+      //     new BRepFill_CurveConstraint (Handle(Adaptor3d_HCurve)::DownCast(aHAD), (Standard_Integer) GeomAbs_C0, myNbPtsOnCur, myTol3d);
+      Handle(GeomPlate_CurveConstraint) aConst =
+        new GeomPlate_CurveConstraint(aHAD, (Standard_Integer) GeomAbs_C0, myNbPtsOnCur, myTol3d);
+      aBuilder.Add (aConst);
     }
+    aBuilder.Perform();
+    if(!aBuilder.IsDone())
+      return aSurf;
+    Handle(GeomPlate_Surface) aPlSurf = aBuilder.Surface();
+
+    //for filling holes without initial specified surface
+    //the initial surface should be build by GeomPlate itself
+    //following code was taken from BRepFill_Filling::Build
+
+    Standard_Real aDist = aBuilder.G0Error();
+    TColgp_SequenceOfXY S2d;
+    TColgp_SequenceOfXYZ S3d;
+    S2d.Clear();
+    S3d.Clear();
+    aBuilder.Disc2dContour(4,S2d);
+    aBuilder.Disc3dContour(4,0,S3d);
+    Standard_Real amaxTol = Max( myTol3d, 10* aDist);
+    GeomPlate_PlateG0Criterion Criterion( S2d, S3d, amaxTol );
+    GeomPlate_MakeApprox Approx( aPlSurf, Criterion, myTol3d, myMaxSeg, myMaxDeg );
+    aSurf = Approx.Surface();
+    if(aSurf.IsNull())
+      return aSurf;
+
+    theCurves2d = aBuilder.Curves2d();
+    theOrders    = aBuilder.Order();
+    theSenses    = aBuilder.Sense();
+  }
 
   catch (Standard_Failure) {
     aSurf.Nullify();
index 5466dcb7511d994de9f6fc0840576cf0a0b880ce..78372f5ac9379dc7d0a5d3d028e8fca96849aed0 100755 (executable)
@@ -34,11 +34,16 @@ ADD_DEFINITIONS(
   #${CAS_DEFINITIONS}
   ${QT_DEFINITIONS}
   )
+IF(NOT SALOME_GUI_BUILD_WITH_QT5)
+  SET(QT_QTCORE_LIB ${QT_QTCORE_LIBRARY})
+ELSE()
+  SET(QT_QTCORE_LIB ${Qt5Core_LIBRARIES})
+ENDIF()
 
 # libraries to link to
 SET(_link_LIBRARIES
   ${OpenCV_LIBS}
-  ${QT_QTCORE_LIBRARY} # ${QT_LIBRARIES}
+  ${QT_QTCORE_LIB}
   ${KERNEL_SALOMELocalTrace}
   )
 
index fb59e2cd54e8e508cd0ac753310f0232cbdc5af1..db3c162b0f1bb44b2a960f6035f557ac0f4e3b09 100644 (file)
@@ -65,6 +65,25 @@ void BrepGeometry::setShapeString(const std::string& shape)
     initIds();
 }
 
+void BrepGeometry::writeShapeFile(const std::string& fileName)
+throw (XAO_Exception)
+{
+    bool res = BRepTools::Write(m_shape, fileName.c_str());
+    if (!res)
+        throw XAO_Exception(MsgBuilder() << "Cannot write BRep file: " << fileName);
+}
+
+void BrepGeometry::readShapeFile(const std::string& fileName)
+throw (XAO_Exception)
+ {
+    BRep_Builder builder;
+    bool res = BRepTools::Read(m_shape, fileName.c_str(), builder);
+    if (!res)
+        throw XAO_Exception(MsgBuilder() << "Cannot read BRep file: " << fileName);
+
+    initIds();
+}
+
 TopoDS_Shape BrepGeometry::getTopoDS_Shape()
 {
     return m_shape;
index 59d19ba5450a94b26e094c9d393acf2d1c3bc710..e5782338495b1da42bc87e177807d1ca8fd4d950 100644 (file)
@@ -75,6 +75,18 @@ namespace XAO
          */
         virtual void setShapeString(const std::string& shape);
 
+        /**
+         * Writes shape to a file
+         * @param fileName the path to the file
+         */
+        virtual void writeShapeFile(const std::string& fileName) throw (XAO_Exception);
+
+        /**
+         * Reads shape from a file
+         * @param fileName the path to the file
+         */
+        virtual void readShapeFile(const std::string& fileName) throw (XAO_Exception);
+
 #ifdef SWIG
         %pythoncode %{
         def setShape(self, shape):
index 3fa7c8c1990d57bb2a9cdf12abf3bc9fdf87f785..0ef35b169edc08f13262ec80dceff3b923e6a741 100644 (file)
@@ -34,18 +34,17 @@ using namespace XAO;
 // -------------------------------------------------------
 
 Field::Field(const XAO::Dimension& dimension,
-        const int& nbElements, const int& nbComponents, const std::string& name)
-    : m_name(name), m_dimension(dimension), m_nbElements(nbElements), m_nbComponents(nbComponents)
+             const int& nbElements, const int& nbComponents, const std::string& name)
+  : m_name(name), m_dimension(dimension),
+    m_nbComponents(nbComponents), m_components(nbComponents, ""),
+    m_nbElements(nbElements)
 {
-    m_components.reserve(nbComponents);
-    for (int i = 0; i < nbComponents; ++i)
-        m_components.push_back("");
 }
 
 Field::~Field()
 {
-    for (unsigned int i = 0; i < m_steps.size(); ++i)
-        delete m_steps[i];
+  for (unsigned int i = 0; i < m_steps.size(); ++i)
+    delete m_steps[i];
 }
 
 Field* Field::createField(const XAO::Type& type, const XAO::Dimension& dimension,
@@ -83,7 +82,7 @@ throw (XAO_Exception)
 {
     for (unsigned int  i = 0; i < names.size(); ++i)
     {
-        if (i < m_nbComponents)
+      if ((int)i < m_nbComponents)
             m_components[i] = names[i];
     }
 }
@@ -130,7 +129,7 @@ throw (XAO_Exception)
 void Field::checkStepIndex(const int& step)
 throw (XAO_Exception)
 {
-    if (step < m_steps.size() && step >= 0)
+  if (step < (int)m_steps.size() && step >= 0)
         return;
 
     throw XAO_Exception(MsgBuilder() << "Step index is out of range [0, "
index d6d9abebd23209ba5b8adaf47139c99219695898..5d2c373dabf5d1e156d47c8ebda82af22ec01afe 100644 (file)
@@ -56,7 +56,6 @@ namespace XAO
               const int& nbElements, const int& nbComponents, const std::string& name);
 
     public:
-        /**
         /**
          * Creates a Field of the given type.
          * @param type the type of the field to create.
index 698843c9e981f7b8740a2be1a23d9767af865ad7..34760ca345bb0496646a8bca72379f22a8d4a0a7 100644 (file)
@@ -94,6 +94,8 @@ namespace XAO
 
         virtual const std::string getShapeString() = 0;
         virtual void setShapeString(const std::string& shape) = 0;
+        virtual void writeShapeFile(const std::string& fileName) = 0;
+        virtual void readShapeFile(const std::string& fileName) = 0;
 
         const int countElements(const XAO::Dimension& dim) const throw (XAO_Exception);
         const int countVertices() const { return m_vertices.getSize(); }
index c2799c55907823a8acd819d30a2f1a7a24dbc950..3ca39684c90763ad92a34c15d346f04184a29158 100644 (file)
@@ -43,7 +43,7 @@ Group::~Group()
 void Group::checkIndex(const int& element)
 throw (XAO_Exception)
 {
-    if (element < m_elements.size() && element >= 0)
+  if (element < (int)m_elements.size() && element >= 0)
         return;
 
     throw XAO_Exception(MsgBuilder() << "Index of element is out of range [0, "
index 4e9652a26990daaf07653230252e66afee041887..1ec749b35829bbca38add6827f87f3f72dd4acba 100644 (file)
@@ -241,9 +241,9 @@ bool Xao::removeField(Field* field)
     return res;
 }
 
-const bool Xao::exportXAO(const std::string& fileName)
+const bool Xao::exportXAO(const std::string& fileName, const std::string& shapeFileName)
 {
-    return XaoExporter::saveToFile(this, fileName);
+    return XaoExporter::saveToFile(this, fileName, shapeFileName);
 }
 
 const std::string Xao::getXML()
index 82c891b82ff32d2ceefe21a1592c932e3a8e2033..c7d839c3f50c819292e4698321b653d8299a93c9 100644 (file)
@@ -215,9 +215,10 @@ namespace XAO
         /**
          * Exports this XAO object to a file.
          * \param fileName the name of the file to create.
+         * \param shapeFileName if not empty, export the shape to this external file.
          * \return true is the export is successful.
          */
-        const bool exportXAO(const std::string& fileName);
+        const bool exportXAO(const std::string& fileName, const std::string& shapeFileName);
         /**
          * Gets the XML corresponding to this XAO.
          * \return the XML as a string.
index f0ca278fe9759567f20220f1d30511c004084c9c..fd13841b85f8625e28c25d2a5b7bdb974fc43570 100644 (file)
 #include "XAO_Step.hxx"
 #include "XAO_XaoUtils.hxx"
 
+#ifdef WIN32
+# define _separator_ '\\'
+#else
+# define _separator_ '/'
+#endif
+
 namespace XAO
 {
     const xmlChar* C_TAG_XAO = (xmlChar*)"XAO";
@@ -39,6 +45,7 @@ namespace XAO
 
     const xmlChar* C_TAG_SHAPE = (xmlChar*)"shape";
     const xmlChar* C_ATTR_SHAPE_FORMAT = (xmlChar*)"format";
+    const xmlChar* C_ATTR_SHAPE_FILE = (xmlChar*)"file";
 
     const xmlChar* C_TAG_TOPOLOGY = (xmlChar*)"topology";
     const xmlChar* C_TAG_VERTICES = (xmlChar*)"vertices";
@@ -83,8 +90,8 @@ namespace XAO
 using namespace XAO;
 
 namespace {
-    xmlDocPtr exportXMLDoc(Xao* xaoObject);
-    void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao);
+    xmlDocPtr exportXMLDoc(Xao* xaoObject, const std::string& shapeFileName);
+    void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao, const std::string& shapeFileName);
     void exportGeometricElements(Geometry* xaoGeometry, xmlNodePtr topology,
                                  XAO::Dimension dim, const xmlChar* colTag, const xmlChar* eltTag);
     void exportGroups(Xao* xaoObject, xmlNodePtr xao);
@@ -109,13 +116,15 @@ namespace {
     void parseStepElementNode(xmlNodePtr eltNode, Step* step);
 
     std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
-                               const bool& required, const std::string& defaultValue, const std::string& exception = std::string(""));
+                               const bool& required, const std::string& defaultValue,
+                               const std::string& exception = std::string(""));
     int readIntegerProp(xmlNodePtr node, const xmlChar* attribute,
-                        const bool& required, const int& defaultValue, const std::string& exception = std::string(""));
+                        const bool& required, const int& defaultValue,
+                        const std::string& exception = std::string(""));
 
-  std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
-                             const bool& required, const std::string& defaultValue,
-                             const std::string& exception /*= std::string() */)
+    std::string readStringProp(xmlNodePtr node, const xmlChar* attribute,
+                               const bool& required, const std::string& defaultValue,
+                               const std::string& exception /*= std::string() */)
   {
     xmlChar* strAttr = xmlGetProp(node, attribute);
     if (strAttr == NULL)
@@ -161,7 +170,7 @@ namespace {
     return res;
   }
 
-  xmlDocPtr exportXMLDoc(Xao* xaoObject)
+  xmlDocPtr exportXMLDoc(Xao* xaoObject, const std::string& shapeFileName)
   {
     // Creating the Xml document
     xmlDocPtr masterDocument = xmlNewDoc(BAD_CAST "1.0");
@@ -173,7 +182,7 @@ namespace {
 
     if (xaoObject->getGeometry() != NULL)
     {
-        exportGeometry(xaoObject->getGeometry(), masterDocument, xao);
+        exportGeometry(xaoObject->getGeometry(), masterDocument, xao, shapeFileName);
     }
 
     exportGroups(xaoObject, xao);
@@ -199,7 +208,8 @@ namespace {
     }
   }
 
-  void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao)
+  void exportGeometry(Geometry* xaoGeometry, xmlDocPtr doc, xmlNodePtr xao,
+                      const std::string& shapeFileName)
   {
     // Geometric part
     xmlNodePtr geometry = xmlNewChild(xao, 0, C_TAG_GEOMETRY, 0);
@@ -207,9 +217,20 @@ namespace {
 
     xmlNodePtr shape = xmlNewChild(geometry, 0, C_TAG_SHAPE, 0);
     xmlNewProp(shape, C_ATTR_SHAPE_FORMAT, BAD_CAST XaoUtils::shapeFormatToString(xaoGeometry->getFormat()).c_str());
-    std::string txtShape = xaoGeometry->getShapeString();
-    xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size());
-    xmlAddChild(shape, cdata);
+
+    if (shapeFileName == "")
+    {
+        // export the shape in the XAO file
+        std::string txtShape = xaoGeometry->getShapeString();
+        xmlNodePtr cdata = xmlNewCDataBlock(doc, BAD_CAST txtShape.c_str(), txtShape.size());
+        xmlAddChild(shape, cdata);
+    }
+    else
+    {
+        // export the shape in an external file
+        xmlNewProp(shape, C_ATTR_SHAPE_FILE, BAD_CAST shapeFileName.c_str());
+        xaoGeometry->writeShapeFile(shapeFileName);
+    }
 
     xmlNodePtr topology = xmlNewChild(geometry, 0, C_TAG_TOPOLOGY, 0);
 
@@ -361,11 +382,20 @@ namespace {
   {
     if (geometry->getFormat() == XAO::BREP)
     {
-        xmlChar* data = xmlNodeGetContent(shapeNode->children);
-        if (data == NULL)
-            throw XAO_Exception("Missing BREP");
-        geometry->setShapeString((char*)data);
-        xmlFree(data);
+        std::string strFile = readStringProp(shapeNode, C_ATTR_SHAPE_FILE, false, "");
+        if (strFile != "")
+        {
+            geometry->readShapeFile(strFile);
+        }
+        else
+        {
+            // read brep from node content
+            xmlChar* data = xmlNodeGetContent(shapeNode->children);
+            if (data == NULL)
+                throw XAO_Exception("Missing BREP");
+            geometry->setShapeString((char*)data);
+            xmlFree(data);
+        }
     }
     else
     {
@@ -608,10 +638,10 @@ namespace {
   }
 }
 
-const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName)
+const bool XaoExporter::saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName)
 throw (XAO_Exception)
 {
-    xmlDocPtr doc = exportXMLDoc(xaoObject);
+    xmlDocPtr doc = exportXMLDoc(xaoObject, shapeFileName);
     xmlSaveFormatFileEnc(fileName.c_str(), doc, "UTF-8", 1); // format = 1 for node indentation
     xmlFreeDoc(doc);
 
@@ -621,7 +651,7 @@ throw (XAO_Exception)
 const std::string XaoExporter::saveToXml(Xao* xaoObject)
 throw (XAO_Exception)
 {
-    xmlDocPtr doc = exportXMLDoc(xaoObject);
+    xmlDocPtr doc = exportXMLDoc(xaoObject, "");
 
     xmlChar *xmlbuff;
     int buffersize;
index 966e76386354db56d34e4b49b88d048090a23180..d633ecb0832e7061d97ed79bb1d5c11a104d334b 100644 (file)
@@ -44,9 +44,10 @@ namespace XAO
          * Saves the XAO object to a file.
          * @param xaoObject the object to export.
          * @param fileName the path of the file to create.
+         * @param shapeFileName if not empty save the shape in an this external file.
          * @return true if the export was successful, false otherwise.
          */
-        static const bool saveToFile(Xao* xaoObject, const std::string& fileName)
+        static const bool saveToFile(Xao* xaoObject, const std::string& fileName, const std::string& shapeFileName)
         throw (XAO_Exception);
 
         /**
index 2c060200edd4669ce9509d9438690aaa8c8040f2..51ef590a2d7a283be50710e8f6b7935a26d2c3f4 100644 (file)
@@ -46,7 +46,7 @@ void ImportExportTest::testExportNoGeometry()
 {
     Xao xao("me", "1.0");
 
-    bool res = xao.exportXAO("empty.xao");
+    bool res = xao.exportXAO("empty.xao", "");
     CPPUNIT_ASSERT(res);
 }
 
@@ -103,7 +103,7 @@ void ImportExportTest::testExportGeometry()
         }
     }
 
-    bool res = xao.exportXAO("mygeom.xao");
+    bool res = xao.exportXAO("mygeom.xao", "");
     CPPUNIT_ASSERT(res);
 
     std::string xml = xao.getXML();
index d3b32ee68e0cf3e82c2ca7e793f3c4be2aaaeee4..c1a5e91da781c25c34c8c9fd9934ddc2d911e816 100644 (file)
@@ -54,6 +54,7 @@
 #include <QRadioButton>
 #include <QGridLayout>
 #include <QPushButton>
+#include <QCheckBox>
 #include <QMap>
 
 //=================================================================================
@@ -101,6 +102,7 @@ XAOPlugin_ExportDlg::XAOPlugin_ExportDlg(GeometryGUI* geometryGUI, QWidget* pare
   ledShape->setMinimumSize(QSize(100, 0));
 
   int line = 0, col = 0;
+  // adWidget(widget, fromRow, fromColumn, rowSpan, columnSpan)
   gridLayoutExport->addWidget(lblShape, line, col++, 1, 1);
   gridLayoutExport->addWidget(btnShapeSelect, line, col++, 1, 1);
   gridLayoutExport->addWidget(ledShape, line, col++, 1, 1);
@@ -121,10 +123,17 @@ XAOPlugin_ExportDlg::XAOPlugin_ExportDlg(GeometryGUI* geometryGUI, QWidget* pare
   ledAuthor = new QLineEdit(gbxExport);
 
   line++; col = 0;
-  gridLayoutExport->addWidget(lblAuthor, line, col++, 2, 1);
+  gridLayoutExport->addWidget(lblAuthor, line, col++, 1, 1);
   col++; // span
   gridLayoutExport->addWidget(ledAuthor, line, col++, 1, 1);
 
+  // Line 3
+  ckxUseSeparateFile = new QCheckBox(tr("XAOPLUGIN_EXPORT_SHAPEFILE"), gbxExport);
+
+  line++; col = 0;
+  gridLayoutExport->addWidget(ckxUseSeparateFile, line, col++, 1, 2);
+
+
   //****************************
   // Filter Group box
   QGroupBox* gbxFilter = new QGroupBox(parent);
@@ -410,6 +419,12 @@ bool XAOPlugin_ExportDlg::execute()
 
   QString author = ledAuthor->text();
   QString fileName = ledFileName->text();
+  QString shapeFileName = QString("");//ledShapeFile->text();
+  if (ckxUseSeparateFile->isChecked())
+  {
+    shapeFileName = fileName;
+    shapeFileName.append(".brep");
+  }
 
   // get selected groups
   QList<QListWidgetItem*> selGroups;
@@ -451,6 +466,7 @@ bool XAOPlugin_ExportDlg::execute()
   GEOM::IXAOOperations_var aXAOOp = GEOM::IXAOOperations::_narrow( getOperation() );
   res = aXAOOp->ExportXAO(m_mainObj, groups, fields,
                           author.toUtf8().constData(),
-                          fileName.toUtf8().constData());
+                          fileName.toUtf8().constData(),
+                          shapeFileName.toStdString().c_str());
   return res;
 }
index daf27e7fab1f35cc5ba1f78e9288eda780443e5b..bade0ff0a65bd13338c542ccb31773bc551adcde 100644 (file)
@@ -27,6 +27,7 @@ class QLineEdit;
 class QButtonGroup;
 class QListWidget;
 class QPushButton;
+class QCheckBox;
 
 //=================================================================================
 // class    : XAOPlugin_ExportDlg
@@ -58,6 +59,7 @@ private:
   QLineEdit* ledShape;
   QLineEdit* ledFileName;
   QLineEdit* ledAuthor;
+  QCheckBox* ckxUseSeparateFile;
   QListWidget* lstGroups;
   QListWidget* lstFields;
   QPushButton* btnShapeSelect;
index 7992926b79deb1749e9f25e3cb26b45ab4b53b88..4e4e6ed11bd6e671ba40713bbbb99704a6227af9 100644 (file)
@@ -48,9 +48,10 @@ XAOPlugin_IECallBack::~XAOPlugin_IECallBack()
 //=============================================================================
 bool
 XAOPlugin_IECallBack::Export( int                            theDocId,
-                             const Handle(GEOM_Object)      theOriginal,
-                             const TCollection_AsciiString& theFileName,
-                             const TCollection_AsciiString& theFormatName )
+                              const Handle(GEOM_Object)      theOriginal,
+                              const TCollection_AsciiString& theFileName,
+                              const TCollection_AsciiString& theFormatName,
+                              const TCollection_AsciiString& theShapeFileName )
 {
   XAOPlugin_IOperations* aPluginOperations = XAOPlugin_OperationsCreator::get( GetEngine(), theDocId );
   GEOMImpl_IShapesOperations* aShapesOperations = GetEngine()->GetIShapesOperations( theDocId );
@@ -63,7 +64,7 @@ XAOPlugin_IECallBack::Export( int                            theDocId,
     lgroups.push_back( Handle(GEOM_Object)::DownCast( groups->Value(i) ) );
   for (int i = 1; i <= fields->Length(); i++)
     lfields.push_back( Handle(GEOM_Field)::DownCast( fields->Value(i) ) );
-  aPluginOperations->ExportXAO( theOriginal, lgroups, lfields, "SIMAN Author", theFileName.ToCString() );
+  aPluginOperations->ExportXAO( theOriginal, lgroups, lfields, "SIMAN Author", theFileName.ToCString(), theShapeFileName.ToCString() );
   return true;
 }
 
index d1f04cec5467cbb757f4191f2fa9117d0596ef0f..8bd1b688b95578b61d27a5dca0b5d781f1723353 100644 (file)
@@ -37,9 +37,10 @@ public:
   ~XAOPlugin_IECallBack();
   
   virtual bool Export( int                            theDocId,
-                      const Handle(GEOM_Object)      theOriginal,
-                      const TCollection_AsciiString& theFileName,
-                      const TCollection_AsciiString& theFormatName );
+                       const Handle(GEOM_Object)      theOriginal,
+                       const TCollection_AsciiString& theFileName,
+                       const TCollection_AsciiString& theFormatName,
+                       const TCollection_AsciiString& theshapeFileName );
 
   virtual
   Handle(TColStd_HSequenceOfTransient) Import( int                            theDocId,
index d33a5deaf69d0675c2e1e164270ffa1d350ecb8d..33e74ae6d0a5d510dbb8afac86b2ebef1e143d25 100644 (file)
@@ -311,7 +311,8 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
                                        std::list<Handle(GEOM_Object)> groupList,
                                        std::list<Handle(GEOM_Field)> fieldList,
                                        const char* author,
-                                       const char* fileName )
+                                       const char* fileName,
+                                       const char* shapeFileName )
 {
   SetErrorCode(KO);
 
@@ -348,7 +349,7 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
   exportFields(fieldList, xaoObject, geometry);
 
   // export the XAO to the file
-  xaoObject->exportXAO(fileName);
+  xaoObject->exportXAO(fileName, shapeFileName);
 
   // make a Python command
   GEOM::TPythonDump pd(exportFunction);
@@ -378,7 +379,7 @@ bool XAOPlugin_IOperations::ExportXAO( Handle(GEOM_Object) shape,
     }
   }
   pd << "], ";
-  pd << "\"" << author << "\", \"" << fileName << "\")";
+  pd << "\"" << author << "\", \"" << fileName << "\", \"" << shapeFileName << "\")";
 
   SetErrorCode(OK);
   delete xaoObject;
index 65e42d42c80fcbc81caf8371b2e04476d2bc1e07..7bf885f7c5769e3dd0e2cd9927d4423836d219eb 100644 (file)
@@ -47,7 +47,8 @@ public:
                   std::list<Handle(GEOM_Object)> groupList,
                   std::list<Handle(GEOM_Field)> fieldList,
                   const char* author,
-                  const char* fileName );
+                  const char* fileName,
+                  const char* shapeFileName );
   
   bool ImportXAO( const char* fileName,
                   Handle(GEOM_Object)& shape,
index fa26fe5f0205fc73bdbe3ba21a018623177c03a9..20581c9b95be4439b166dd7f11a376e0837a2b18 100644 (file)
@@ -55,14 +55,16 @@ XAOPlugin_IOperations_i::~XAOPlugin_IOperations_i()
  *  \param fields The list of fields to export
  *  \param author The author of the export
  *  \param fileName The name of the exported file
+ *  \param shapeFileName If not empty, save to shape to this external file
  *  \return boolean indicating if export was succeful.
  */
 //=============================================================================
 CORBA::Boolean XAOPlugin_IOperations_i::ExportXAO( GEOM::GEOM_Object_ptr shape,
-                                                  const GEOM::ListOfGO& groups,
-                                                  const GEOM::ListOfFields& fields,
-                                                  const char* author,
-                                                  const char* fileName)
+                                                   const GEOM::ListOfGO& groups,
+                                                   const GEOM::ListOfFields& fields,
+                                                   const char* author,
+                                                   const char* fileName,
+                                                   const char* shapeFileName)
 {
   bool isGood = false;
   // Set a not done flag
@@ -94,7 +96,7 @@ CORBA::Boolean XAOPlugin_IOperations_i::ExportXAO( GEOM::GEOM_Object_ptr shape,
   if( !reference.IsNull() )
   {
     // Export XAO
-    isGood = GetOperations()->ExportXAO( reference, groupsObj, fieldsObj, author, fileName );
+    isGood = GetOperations()->ExportXAO( reference, groupsObj, fieldsObj, author, fileName, shapeFileName );
   }
 
   return isGood;
index 3b849c79e4b456ae163f2d959265862f0dd1a0d8..c3dbe49176323b3ba219fd587d7aff78fb4a82c8 100644 (file)
@@ -47,7 +47,8 @@ public:
                             const GEOM::ListOfGO& groups,
                             const GEOM::ListOfFields& fields,
                             const char* author,
-                            const char* fileName );
+                            const char* fileName,
+                            const char* shapeFileName );
 
   CORBA::Boolean ImportXAO( const char* fileName,
                             GEOM::GEOM_Object_out shape,
index a6c2196a71b0a23e539ef132237c9fcc42f9238b..9351d4a66f4262b8912e1dbdbc2a7b280153d430 100644 (file)
@@ -281,17 +281,17 @@ bool XAOPlugin_ImportDlg::execute()
     QStringList anEntryList;
     anEntryList << addInStudy(m_mainShape, m_mainShape->GetName());
     m_mainShape->UnRegister();
-    for (int i = 0; i < subShapes->length(); i++)
+    for (CORBA::ULong i = 0; i < subShapes->length(); i++)
     {
       addInStudy(subShapes[i].in(), subShapes[i]->GetName());
       subShapes[i]->UnRegister();
     }
-    for (int i = 0; i < groups->length(); i++)
+    for (CORBA::ULong i = 0; i < groups->length(); i++)
     {
       addInStudy(groups[i].in(), groups[i]->GetName());
       groups[i]->UnRegister();
     }
-    for (int i = 0; i < fields->length(); i++)
+    for (CORBA::ULong i = 0; i < fields->length(); i++)
     {
       addFieldInStudy(fields[i].in(), m_mainShape);
     }
@@ -329,7 +329,7 @@ QString XAOPlugin_ImportDlg::addFieldInStudy( GEOM::GEOM_Field_ptr theField, GEO
 
   // add steps
   GEOM::ListOfLong_var steps = theField->GetSteps();
-  for (int i = 0; i < steps->length(); ++i)
+  for (CORBA::ULong i = 0; i < steps->length(); ++i)
   {
     GEOM::GEOM_FieldStep_ptr step = theField->GetStep(steps[i]);
     QString stepName = (tr("XAOPLUGIN_STEP") + " %1 %2").arg( step->GetID() ).arg( step->GetStamp() );
index c37ffd620e023dcbd1631659a157f98097bbf118..740b0232cb2d9ebb0920ff2fea4eafc98a9adcf9 100644 (file)
         <source>XAOPLUGIN_EXPORT_AUTHOR</source>
         <translation>Author</translation>
     </message>
+    <message>
+        <source>XAOPLUGIN_EXPORT_SHAPEFILE</source>
+        <translation>Export shape in a separate file</translation>
+    </message>
     <message>
         <source>XAOPLUGIN_EXPORT_LGROUPS</source>
         <translation>Groups</translation>
index 7d3a6deecc54957e91bdc370b5df47b15a5cdb8e..a28228679a751c11d50e465c24186a095058940e 100644 (file)
         <source>XAOPLUGIN_EXPORT_AUTHOR</source>
         <translation>Auteur</translation>
     </message>
+    <message>
+        <source>XAOPLUGIN_EXPORT_SHAPEFILE</source>
+        <translation>Exporter la forme dans un fichier séparé</translation>
+    </message>
     <message>
         <source>XAOPLUGIN_EXPORT_LGROUPS</source>
         <translation>Groupes</translation>