diff --git a/doc/salome/gui/GEOM/images/annotation.png b/doc/salome/gui/GEOM/images/annotation.png
new file mode 100644
index 000000000..584104fc3
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
index 000000000..0cb50206d
Binary files /dev/null and b/doc/salome/gui/GEOM/images/annotation_preview.png differ
diff --git a/doc/salome/gui/GEOM/input/annotation.doc b/doc/salome/gui/GEOM/input/annotation.doc
new file mode 100644
index 000000000..944630a4c
--- /dev/null
+++ b/doc/salome/gui/GEOM/input/annotation.doc
@@ -0,0 +1,57 @@
+/*!
+
+\page annotation_page Shape annotation
+
+ Annotation 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):
+
+ 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.
+ 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).
+
+
+\image html annotation_preview.png
+
+It can be accessed from the main menu via Inspection -> Annotation
+
+\image html annotation.png "Create Annotation dialog"
+
+In this dialog you can:
+
+ Set Text text shown in View 3d and a name of annotation presented in the Text Browser.
+ Select a \b Shape to which the annotation will be assigned.
+ Set Fixed screen position to select alogithm for the annotation position caldulation.
+ Select a Shape Type to which the annotation will be assigned on the shape.
+ It contains "Whole shape", "Vertex", "Edge", "Face" and "Solid" choices.
+ Select a sub shape to assign annotation to. Text control contains information about local selection in the viewer.
+ Move annotation dragging it in 3D view to select an appropriate position.
+ Push \b Apply or Apply and Close button to commit creation of the field.
+
+
+Annotations appear in an Annotations sub-tree in Text Browser.
+The foolowing context menu commands are provided for annotation object in Text Browser:
+
+ Edit allows modifying the annotation text, the positioning algorithm and the annotation position.
+ Delete deletes selected annotation.
+ Show /Hide change visibility of annotation in the active view.
+
+Edit and Delete 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:
+
+ Selection of an annotation will highlight corresponding shape/subshape in 3D view.
+ When the shape is deleted, the annotation will be also deleted.
+
+
+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 File -> Preferences . The Shape annotations group on Geometry Settings pane contains controls for it.
+
+*/
diff --git a/doc/salome/gui/GEOM/input/using_measurement_tools.doc b/doc/salome/gui/GEOM/input/using_measurement_tools.doc
index 515a94ce4..feca9e24f 100644
--- a/doc/salome/gui/GEOM/input/using_measurement_tools.doc
+++ b/doc/salome/gui/GEOM/input/using_measurement_tools.doc
@@ -17,6 +17,7 @@
\subpage angle_page "Angle"
\subpage tolerance_page "Tolerance"
\subpage managing_dimensions_page "Dimensions"
+\subpage annotation_page "Annotations"
\subpage whatis_page "WhatIs"
\subpage inspect_object_operation_page "Inspect Object"
\subpage shape_statistics_operation_page "Shape Statistics"
diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt
index dc98cbf97..74be117a6 100755
--- a/resources/CMakeLists.txt
+++ b/resources/CMakeLists.txt
@@ -39,6 +39,7 @@ SET( _res_files
isoline.png
isoline_v.png
angle.png
+ annotation.png
arc.png
arccenter.png
arcofellipse.png
diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in
old mode 100644
new mode 100755
index 45e41fc70..72d1c700f
--- a/resources/SalomeApp.xml.in
+++ b/resources/SalomeApp.xml.in
@@ -100,6 +100,14 @@
+
+
+
+
+
+
+
+
diff --git a/resources/annotation.png b/resources/annotation.png
new file mode 100644
index 000000000..a02ff683c
Binary files /dev/null and b/resources/annotation.png differ
diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h
index 64d46f202..a62b2f129 100755
--- a/src/GEOMBase/GEOMBase_Helper.h
+++ b/src/GEOMBase/GEOMBase_Helper.h
@@ -65,6 +65,8 @@ public:
static SUIT_ViewWindow* getActiveView();
protected:
+ typedef std::list 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 );
void localSelection( const ObjectList&, const int );
void localSelection( GEOM::GEOM_Object_ptr, const std::list );
@@ -210,7 +214,6 @@ private:
void clearShapeBuffer( GEOM::GEOM_Object_ptr );
private:
- typedef std::list PrsList;
PrsList myPreview;
GEOM_Displayer* myDisplayer;
diff --git a/src/GEOMGUI/CMakeLists.txt b/src/GEOMGUI/CMakeLists.txt
index dba48f806..9dd7a50d8 100755
--- a/src/GEOMGUI/CMakeLists.txt
+++ b/src/GEOMGUI/CMakeLists.txt
@@ -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
index 000000000..1a09b5024
--- /dev/null
+++ b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.cxx
@@ -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
+#include
+#include
+
+// STL includes
+#include
+#include
+#include
+
+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(3, 0.0) );
+ myParameterMap->SetRealArray( PARAMETER_ATTACH( anI ), std::vector(3, 0.0) );
+ myParameterMap->SetIntArray( PARAMETER_SHAPE( anI ), std::vector(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 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 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 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 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 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 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 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( 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
index 000000000..9d93347aa
--- /dev/null
+++ b/src/GEOMGUI/GEOMGUI_AnnotationAttrs.h
@@ -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
+#include
+
+// OCCT includes
+#include
+#include
+#include
+
+// Qt, STL includes
+#include
+
+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
index 000000000..f46d527d3
--- /dev/null
+++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.cxx
@@ -0,0 +1,899 @@
+// 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
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+
+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( 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( ( 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 wnds = desk->windows();
+ SUIT_ViewWindow* wnd;
+ QListIterator 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(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( 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 );
+ }
+ }
+}
+
+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( 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 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( 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::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 (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() ) {
+
+ gp_Ax3 aShapeLCS = gp_Ax3().Transformed( aShape.Location().Transformation() );
+ 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( aProperty.ShapeType ), aSubShapeMap );
+ if ( aProperty.ShapeIndex <= aSubShapeMap.Extent() ) {
+ aPresentation->SetHilightShape( aSubShapeMap( aProperty.ShapeIndex ) );
+ }
+ }
+ }
+
+ setDisplayProperties( aPresentation, aView, theEntry );
+
+ aView->getAISContext()->Redisplay( aPresentation );
+ }
+ }
+ getDisplayer()->UpdateViewer();
+}
+
+void GEOMGUI_AnnotationMgr::DisplayAllAnnotations( SOCC_Viewer* theView )
+{
+ SOCC_Viewer* aView = viewOrActiveView( theView );
+ if ( !myVisualized.contains( aView ) )
+ return;
+
+ GeometryGUI* aModule = dynamic_cast( getApplication()->activeModule() );
+ GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
+ QList anEntries = aTextWidget->getAllEntries( GEOMGUI_TextTreeWdg::AnnotationShape );
+
+ SalomeApp_Study* aStudy = dynamic_cast( 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( getApplication()->activeModule() );
+ GEOMGUI_TextTreeWdg* aTextWidget = aModule->GetTextTreeWdg();
+ QList 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::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( 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 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( 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( 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( getApplication()->activeModule() );
+ return dynamic_cast( 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( 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( 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( 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 (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( 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( 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( 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( 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( 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
index 000000000..52d3b1260
--- /dev/null
+++ b/src/GEOMGUI/GEOMGUI_AnnotationMgr.h
@@ -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
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+
+#include
+#include
+
+#include
+#include
+
+#include
+
+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 AnnotationToPrs;
+ typedef QMap EntryToAnnotations;
+ QMap myVisualized;
+};
+#endif
diff --git a/src/GEOMGUI/GEOMGUI_DimensionProperty.h b/src/GEOMGUI/GEOMGUI_DimensionProperty.h
index 3ff770055..a2397968c 100644
--- a/src/GEOMGUI/GEOMGUI_DimensionProperty.h
+++ b/src/GEOMGUI/GEOMGUI_DimensionProperty.h
@@ -42,6 +42,9 @@
class SalomeApp_Study;
+class GEOMGUI_DimensionProperty;
+typedef QSharedPointer DimensionPropertyPtr;
+
/*!
* \brief Utility class to unpack/pack dimension presentations as object property of study.
*
diff --git a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx
index b79ea3d35..4ab85d38a 100644
--- a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx
+++ b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx
@@ -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
@@ -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 ) )
diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx
index 51fd17889..87026424e 100644
--- a/src/GEOMGUI/GEOMGUI_Selection.cxx
+++ b/src/GEOMGUI/GEOMGUI_Selection.cxx
@@ -25,6 +25,8 @@
#include "GEOMGUI_Selection.h"
#include
+#include
+#include
#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("_");
}
@@ -853,3 +864,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( 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() );
+
+ const Handle(GEOMGUI_AnnotationAttrs)
+ aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+
+ if ( aShapeAnnotations.IsNull() )
+ return false;
+
+ 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;
+}
diff --git a/src/GEOMGUI/GEOMGUI_Selection.h b/src/GEOMGUI/GEOMGUI_Selection.h
index c5d229aa8..76dda787c 100644
--- a/src/GEOMGUI/GEOMGUI_Selection.h
+++ b/src/GEOMGUI/GEOMGUI_Selection.h
@@ -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
index 000000000..8d77a3d34
--- /dev/null
+++ b/src/GEOMGUI/GEOMGUI_TextTreeSelector.cxx
@@ -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
+#include
+
+/*!
+ \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 > aSelectedAnnotations;
+ myTextTree->getSelected(aSelectedAnnotations);
+
+ QMap >::const_iterator anIt = aSelectedAnnotations.begin(),
+ aLast = aSelectedAnnotations.end();
+ for ( ; anIt != aLast; anIt++ ) {
+ QString anEntry = anIt.key();
+ QList anIndices = anIt.value();
+ QList::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 > aSelectedAnnotations;
+ DataObjectList objList;
+ for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin();
+ it != theList.end(); ++it ) {
+ const LightApp_DataOwner* anOwner = dynamic_cast( (*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 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
index 000000000..7ae88764c
--- /dev/null
+++ b/src/GEOMGUI/GEOMGUI_TextTreeSelector.h
@@ -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
+#include
+
+#include
+
+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
diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
old mode 100644
new mode 100755
index 2e3218b1e..d69e7bba2
--- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
+++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.cxx
@@ -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
@@ -49,6 +51,110 @@
#include
#include
+// ----------------------------------------------------------------------------
+// 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(myStudy->application());
+ GeometryGUI* aModule = dynamic_cast(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( 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 ) ) );
+ GeometryGUI* aGeomGUI = dynamic_cast( app->module( "Geometry" ) );
+ 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"<NewChildIterator( SC ) );
anIter->InitEx( true );
- QList objEntries = myObjects.keys();
+ QList aDimensionObjEntries = getObjects( DimensionShape ).keys();
+ QList 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::updateBranch( const QString& theEntry )
+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::updateObjectName( const QString& theEntry )
+{
+ QTreeWidgetItem* anObjectItem;
+
+ QHash 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( SUIT_Session::session()->activeApplication()->activeStudy() );
if ( myStudy ) {
_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();
+ _PTR(SObject) anObject( aStudyDS->FindObjectID( theEntry.toStdString() ) );
+ if ( anObject.get() )
+ anObjectItem->setText( 0, anObject->GetName().c_str() );
+ }
+ }
+}
- QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
+//=================================================================================
+// function : fillBranch
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
+{
+ myStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() );
+
+ if ( myStudy && !theEntry.isEmpty() ) {
+ QSharedPointer aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
+ if ( !aProp ) {
+ return;
+ }
+
+ _PTR(Study) aStudyDS = myStudy->studyDS();
+ if ( aStudyDS ) {
+ _PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
+ const QString aName = obj->GetName().c_str();
+ const int nbProps = aProp->GetNumber();
+
+ 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 );
+ itemName << aName << "";
+ if ( !objectItem ) {
+ QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
- 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 );
- }
+ 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::getVisualProperty( const BranchType& theBranchType,
+ SalomeApp_Study* theStudy,
+ const std::string& theEntry )
+{
+ switch ( theBranchType )
+ {
+ case DimensionShape : return QSharedPointer( new DimensionsProperty( theStudy, theEntry ) );
+ case AnnotationShape : return QSharedPointer( new AnnotationsProperty( theStudy, theEntry ) );
+ default: break;
+ }
+ return QSharedPointer();
+}
+
//=================================================================================
// 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 aProp = getVisualProperty( aBranchType, myStudy, anEntry );
+
+ CAM_Application* anApp = dynamic_cast(myStudy->application());
+ GeometryGUI* aModule = dynamic_cast(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 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(myStudy->application());
+ GeometryGUI* aModule = dynamic_cast(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
+ 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 anObjects = getObjects( AnnotationShape );
+ QHash::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
+ 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
+ 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 aDimensionObjEntries = getObjects( DimensionShape ).keys();
+ BranchType aBranchType = AnnotationShape;
+
+ QList 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 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 >& 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 anIndices;
+ anIndices.append( aDimIndex );
+ theAnnotations[anEntry] = anIndices;
+ }
+ }
+}
+
+//=================================================================================
+// function : setSelected
+// purpose :
+//=================================================================================
+void GEOMGUI_TextTreeWdg::setSelected( const QMap >& theAnnotations )
+{
+ QItemSelectionModel* aSelectionModel = selectionModel();
+ aSelectionModel->clearSelection();
+
+ QMap >::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 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 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 anObjects = getObjects( AnnotationShape );
+ QHash::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& 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& 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;
+}
diff --git a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h
index 4f6677c88..abce0083f 100644
--- a/src/GEOMGUI/GEOMGUI_TextTreeWdg.h
+++ b/src/GEOMGUI/GEOMGUI_TextTreeWdg.h
@@ -23,8 +23,11 @@
#include "GEOM_GEOMGUI.hxx"
#include "GEOM_Displayer.h"
-#include
#include
+#include
+#include
+#include
+#include
#include
@@ -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 >& theAnnotations );
+ void setSelected( const QMap >& theAnnotations );
+
+ QList 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:
+public:
- int myWindowID;
+ /*!
+ * \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;
+ };
- QIcon myVisibleIcon;
- QIcon myInvisibleIcon;
- QHash myObjects;
- SalomeApp_Study* myStudy;
- QTreeWidgetItem* myDimensionsItem;
- GEOM_Displayer myDisplayer;
+private:
+ bool setShapeItemVisibility( QSharedPointer& theProps,
+ QTreeWidgetItem* theWidgetItem,
+ const bool theVisibility );
+ QSharedPointer 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& getObjects( const BranchType& theBranchType );
+ BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
- QMap myActions; //!< menu actions list
+private:
+ int myWindowID;
+ QIcon myVisibleIcon;
+ QIcon myInvisibleIcon;
+ QHash myDimensionObjects;
+ QHash myAnnotationObjects;
+ SalomeApp_Study* myStudy;
+ QTreeWidgetItem* myDimensionsItem;
+ QTreeWidgetItem* myAnnotationsItem;
+ GEOM_Displayer myDisplayer;
+ QMap myActions; //!< menu actions list
};
+
#endif
diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx
old mode 100644
new mode 100755
index ac4879416..c03b93777
--- a/src/GEOMGUI/GEOM_Displayer.cxx
+++ b/src/GEOMGUI/GEOM_Displayer.cxx
@@ -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
@@ -39,12 +38,17 @@
#include
#include
+#include
#include
#include
#include
#include
#include
+#include
+#include
+#include
+
#include
#include
@@ -460,6 +464,7 @@ static std::string getName( GEOM::GEOM_BaseObject_ptr object )
*/
//=================================================================
GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
+: myIsRedisplayed( false )
{
if( st )
myApp = dynamic_cast( st->application() );
@@ -510,7 +515,8 @@ GEOM_Displayer::GEOM_Displayer( SalomeApp_Study* st )
#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 ( == 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( session->activeApplication() );
+ GeometryGUI* aModule = dynamic_cast( anApp->activeModule() );
+ if ( aModule ) {
+ if ( !theViewFrame->isVisible( theIO ) ) {
+ aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast( theViewFrame ));
+ }
+ else {
+ aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(theIO->getEntry()), dynamic_cast( theViewFrame ));
+ }
+ }
}
//=================================================================
@@ -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( session->activeApplication() );
+ GeometryGUI* aModule = dynamic_cast( anApp->activeModule() );
+ if ( aModule ) {
+ if ( !myIsRedisplayed ) {
+ aModule->GetAnnotationMgr()->DisplayVisibleAnnotations(QString(p->GetEntry()), dynamic_cast( v ));
+ } else {
+ aModule->GetAnnotationMgr()->UpdateVisibleAnnotations(QString(p->GetEntry()), dynamic_cast( 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( session->activeApplication() );
+ GeometryGUI* aModule = dynamic_cast( anApp->activeModule() );
+ if ( aModule )
+ aModule->GetAnnotationMgr()->EraseVisibleAnnotations(QString(p->GetEntry()), dynamic_cast( v ));
+ }
}
//=================================================================
diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h
old mode 100644
new mode 100755
index cf5a9df55..390466f58
--- a/src/GEOMGUI/GEOM_Displayer.h
+++ b/src/GEOMGUI/GEOM_Displayer.h
@@ -263,6 +263,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();
@@ -317,6 +318,7 @@ protected:
Aspect_TypeOfMarker myTypeOfMarker;
double myScaleOfMarker;
double myTransparency;
+ bool myIsRedisplayed;
private:
SalomeApp_Application* myApp;
diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts
index aeaedb609..4b1c19571 100644
--- a/src/GEOMGUI/GEOM_images.ts
+++ b/src/GEOMGUI/GEOM_images.ts
@@ -1215,6 +1215,10 @@
ICO_MANAGE_DIMENSIONS
managedimensions.png
+
+ ICO_ANNOTATION
+ annotation.png
+
ICO_POINT
point2.png
diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts
old mode 100644
new mode 100755
index 7591ab083..22fc71ae4
--- a/src/GEOMGUI/GEOM_msg_en.ts
+++ b/src/GEOMGUI/GEOM_msg_en.ts
@@ -575,6 +575,10 @@ Please, select face, shell or solid and try again
GEOM_DIMENSIONS
Dimensions
+
+ GEOM_ANNOTATIONS
+ Annotations
+
GEOM_SKETCHER_DIST
Distance
@@ -3500,6 +3504,50 @@ Please, select face, shell or solid and try again
PREF_DIMENSIONS_USE_TEXT3D
Use 3D text
+
+ PREF_SHAPE_ANNOTATIONS
+ Shape annotations
+
+
+ PREF_SHAPE_ANNOTATIONS_FONT
+ Font
+
+
+ PREF_SHAPE_ANNOTATIONS_FONT_COLOR
+ Font color
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_COLOR
+ Line color
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_WIDTH
+ Line width
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_STYLE
+ Line style
+
+
+ PREF_SHAPE_ANNOTATIONS_AUTOHIDE
+ Hide when attachment is invisible
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID
+ Solid
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH
+ Dashed
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT
+ Dotted
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH
+ Mixed
+
PREF_HIDE_INPUT_OBJECT
Hide input objects from the viewer
@@ -4956,6 +5004,42 @@ Please, select face, shell or solid and try again
STB_MANAGE_DIMENSIONS
Manage measurement dimensions of an object
+
+ TOP_ANNOTATION
+ Annotation
+
+
+ MEN_ANNOTATION
+ Annotation
+
+
+ STB_ANNOTATION
+ Annotation
+
+
+ TOP_EDIT_ANNOTATION
+ Edit Annotation
+
+
+ MEN_EDIT_ANNOTATION
+ Edit
+
+
+ STB_EDIT_ANNOTATION
+ Edit Annotation
+
+
+ TOP_DELETE_ANNOTATION
+ Delete Annotation
+
+
+ MEN_DELETE_ANNOTATION
+ Delete
+
+
+ STB_DELETE_ANNOTATION
+ Delete Annotation
+
MEN_POP_SHOW_DEPENDENCY_TREE
Show dependency tree
@@ -4996,6 +5080,30 @@ Please, select face, shell or solid and try again
TOP_POP_HIDE_ALL_DIMENSIONS
Show all visible measures (dimension) created for the object
+
+ MEN_POP_SHOW_ALL_ANNOTATIONS
+ Show all annotations
+
+
+ STB_POP_SHOW_ALL_ANNOTATIONS
+ Show all shape annotations for the object
+
+
+ TOP_POP_SHOW_ALL_ANNOTATIONS
+ Show all shape annotations for the object
+
+
+ MEN_POP_HIDE_ALL_ANNOTATIONS
+ Hide all annotations
+
+
+ STB_POP_HIDE_ALL_ANNOTATIONS
+ Hide all shape annotations for the object
+
+
+ TOP_POP_HIDE_ALL_ANNOTATIONS
+ Hide all shape annotations for the object
+
TOP_POP_AUTO_COLOR
Auto color
@@ -6675,6 +6783,61 @@ Do you want to continue?
Please specify suitable arguments.
+
+ MeasureGUI_AnnotationDlg
+
+ CREATE_ANNOTATION_TITLE
+ Create annotation
+
+
+ EDIT_ANNOTATION_TITLE
+ Edit annotation
+
+
+ ANNOTATION_PREFIX
+ Annotation
+
+
+ ANNOTATION_NAME
+ Annotation name
+
+
+ ANNOTATION_PROPERTIES
+ Properties
+
+
+ ANNOTATION_TEXT
+ Text
+
+
+ ANNOTATION_SHAPE
+ Shape
+
+
+ ANNOTATION_TYPE
+ Type
+
+
+ ANNOTATION_SUB_SHAPE
+ Sub-shape type
+
+
+ ANNOTATION_IS_SCREEN_FIXED
+ Fixed screen position
+
+
+ WHOLE_SHAPE
+ Whole shape
+
+
+ ANNOTATION_STYLE
+ Style
+
+
+ ANNOTATION_FONT
+ Font
+
+
MeasureGUI_CheckShapeDlg
diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts
old mode 100644
new mode 100755
index 8c16f25af..75e6aab0c
--- a/src/GEOMGUI/GEOM_msg_fr.ts
+++ b/src/GEOMGUI/GEOM_msg_fr.ts
@@ -3492,6 +3492,50 @@ Choisissez une face, une coque ou un solide et essayez de nouveau
PREF_DIMENSIONS_USE_TEXT3D
Utiliser du texte 3D
+
+ PREF_SHAPE_ANNOTATIONS
+ Shape annotations
+
+
+ PREF_SHAPE_ANNOTATIONS_FONT
+ Font
+
+
+ PREF_SHAPE_ANNOTATIONS_FONT_COLOR
+ Font color
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_COLOR
+ Line color
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_WIDTH
+ Line width
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_STYLE
+ Line style
+
+
+ PREF_SHAPE_ANNOTATIONS_AUTOHIDE
+ Hide when attachment is invisible
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID
+ Solid
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH
+ Dashed
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT
+ Dotted
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH
+ Mixed
+
PREF_HIDE_INPUT_OBJECT
Cacher dans la vue les objets en entrée
@@ -4988,6 +5032,30 @@ Choisissez une face, une coque ou un solide et essayez de nouveau
TOP_POP_HIDE_ALL_DIMENSIONS
Afficher toutes les cotations visibles créées sur l'objet
+
+ MEN_POP_SHOW_ALL_ANNOTATIONS
+ Show all annotations
+
+
+ STB_POP_SHOW_ALL_ANNOTATIONS
+ Show all shape annotations for the object
+
+
+ TOP_POP_SHOW_ALL_ANNOTATIONS
+ Show all shape annotations for the object
+
+
+ MEN_POP_HIDE_ALL_ANNOTATIONS
+ Hide all annotations
+
+
+ STB_POP_HIDE_ALL_ANNOTATIONS
+ Hide all shape annotations for the object
+
+
+ TOP_POP_HIDE_ALL_ANNOTATIONS
+ Hide all shape annotations for the object
+
TOP_POP_AUTO_COLOR
Couleur automatique
diff --git a/src/GEOMGUI/GEOM_msg_ja.ts b/src/GEOMGUI/GEOM_msg_ja.ts
old mode 100644
new mode 100755
index c0c9cdd24..3ed5307c8
--- a/src/GEOMGUI/GEOM_msg_ja.ts
+++ b/src/GEOMGUI/GEOM_msg_ja.ts
@@ -3495,6 +3495,50 @@
PREF_DIMENSIONS_USE_TEXT3D
3Dテキストの使用
+
+ PREF_SHAPE_ANNOTATIONS
+ Shape annotations
+
+
+ PREF_SHAPE_ANNOTATIONS_FONT
+ Font
+
+
+ PREF_SHAPE_ANNOTATIONS_FONT_COLOR
+ Font color
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_COLOR
+ Line color
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_WIDTH
+ Line width
+
+
+ PREF_SHAPE_ANNOTATIONS_LINE_STYLE
+ Line style
+
+
+ PREF_SHAPE_ANNOTATIONS_AUTOHIDE
+ Hide when attachment is invisible
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_SOLID
+ Solid
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DASH
+ Dashed
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOT
+ Dotted
+
+
+ PREF_SHAPE_ANNOTATIONS_LINESTYLE_DOTDASH
+ Mixed
+
PREF_HIDE_INPUT_OBJECT
ビューワから入力したオブジェクトの非表示
@@ -4991,6 +5035,30 @@
TOP_POP_HIDE_ALL_DIMENSIONS
オブジェクトのために作成されたすべての見える基準寸法を表示
+
+ MEN_POP_SHOW_ALL_ANNOTATIONS
+ Show all annotations
+
+
+ STB_POP_SHOW_ALL_ANNOTATIONS
+ Show all shape annotations for the object
+
+
+ TOP_POP_SHOW_ALL_ANNOTATIONS
+ Show all shape annotations for the object
+
+
+ MEN_POP_HIDE_ALL_ANNOTATIONS
+ Hide all annotations
+
+
+ STB_POP_HIDE_ALL_ANNOTATIONS
+ Hide all shape annotations for the object
+
+
+ TOP_POP_HIDE_ALL_ANNOTATIONS
+ Hide all shape annotations for the object
+
TOP_POP_AUTO_COLOR
自動色
diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx
old mode 100644
new mode 100755
index 153d10f01..305d6e47d
--- a/src/GEOMGUI/GeometryGUI.cxx
+++ b/src/GEOMGUI/GeometryGUI.cxx
@@ -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() ) );
@@ -386,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
@@ -674,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
@@ -1059,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" );
@@ -1132,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,
@@ -1327,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 );
@@ -1483,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 );
@@ -1603,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 + ")",
@@ -1657,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
@@ -1838,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 );
@@ -2045,6 +2094,10 @@ void GeometryGUI::onViewManagerRemoved( SUIT_ViewManager* vm )
break;
}
}
+ SOCC_Viewer* aSOCCView = dynamic_cast(viewer);
+ if ( aSOCCView ) {
+ GetAnnotationMgr()->RemoveView( aSOCCView );
+ }
}
//================================================================================
@@ -2372,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 );
@@ -2455,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 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,
@@ -2720,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();
@@ -2757,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" ) ) {
@@ -2813,6 +2938,7 @@ void GeometryGUI::storeVisualParameters (int savePoint)
SalomeApp_Study* appStudy = dynamic_cast(application()->activeStudy());
if ( !appStudy || !appStudy->studyDS() )
return;
+
_PTR(Study) studyDS = appStudy->studyDS();
// componentName is used for encoding of entries when storing them in IParameters
@@ -2830,12 +2956,17 @@ void GeometryGUI::storeVisualParameters (int savePoint)
QList lst;
QList::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(vmodel);
+
int aMgrId = vman->getGlobalId();
// saving VTK actors properties
QVector views = vman->getViews();
@@ -2957,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(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::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() );
+ }
}
}
@@ -3061,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;
}
@@ -3116,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 lst = getApp()->viewManagers();
@@ -3128,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(vmodel));
+ SALOME_View* aView = dynamic_cast(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( aView );
+ GetAnnotationMgr()->setDisplayedIndicesInfo( entry, aSOCCView, aProps["ShapeAnnotationVisibleItems"].toString() );
+ }
+ }
}
}
} // for entries iterator
@@ -3152,6 +3315,10 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
occVMod->Repaint();
}
}
+
+ if ( myTextTreeWdg ) {
+ myTextTreeWdg->updateTree();
+ }
}
// Compute current name mode of the viewer
@@ -3384,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;
}
@@ -3551,3 +3719,8 @@ void GeometryGUI::emitDimensionsUpdated( QString entry )
{
emit DimensionsUpdated( entry );
}
+
+void GeometryGUI::emitAnnotationsUpdated( QString entry )
+{
+ emit SignalAnnotationsUpdated( entry );
+}
diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h
index f92d92ab7..78a067a67 100644
--- a/src/GEOMGUI/GeometryGUI.h
+++ b/src/GEOMGUI/GeometryGUI.h
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#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;
diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h
old mode 100644
new mode 100755
index cc44ca9a9..da8ae797e
--- a/src/GEOMGUI/GeometryGUI_Operations.h
+++ b/src/GEOMGUI/GeometryGUI_Operations.h
@@ -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
diff --git a/src/MeasureGUI/CMakeLists.txt b/src/MeasureGUI/CMakeLists.txt
index 5b652b084..7bbd75177 100755
--- a/src/MeasureGUI/CMakeLists.txt
+++ b/src/MeasureGUI/CMakeLists.txt
@@ -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
diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx
old mode 100644
new mode 100755
index 38a6f3be7..d50c62cf1
--- a/src/MeasureGUI/MeasureGUI.cxx
+++ b/src/MeasureGUI/MeasureGUI.cxx
@@ -28,8 +28,11 @@
#include
#include "GeometryGUI_Operations.h"
+#include
#include
+#include
+#include
#include
#include
@@ -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,42 +192,23 @@ 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( anApp->activeStudy() );
if ( !anActiveStudy )
- {
return;
- }
- LightApp_SelectionMgr* aSelMgr = anApp->selectionMgr();
- if ( !aSelMgr )
- {
+ Handle(SALOME_InteractiveObject) anIObject = getSingleSelectedIO();
+ if ( anIObject.IsNull()
+ || !anIObject->hasEntry() )
return;
- }
-
- SALOME_ListIO aListIO;
- aSelMgr->selectedObjects( aListIO );
- if ( aListIO.Extent() != 1 )
- {
- return;
- }
-
- Handle(SALOME_InteractiveObject) anIObject = aListIO.First();
- if ( !anIObject->hasEntry() )
- {
- return;
- }
SUIT_OverrideCursor wc;
GEOMGUI_DimensionProperty aDimensions( anActiveStudy, anIObject->getEntry() );
- for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt )
- {
+ for ( int anIt = 0; anIt < aDimensions.GetNumber(); ++anIt ) {
aDimensions.SetVisible( anIt, theIsVisible );
}
@@ -217,6 +217,138 @@ void MeasureGUI::ChangeDimensionsVisibility( const bool theIsVisible )
GEOM_Displayer( anActiveStudy ).Redisplay( anIObject, true );
}
+//=======================================================================
+// function : ChangeAnnotationsVisibility
+// purpose :
+//=======================================================================
+void MeasureGUI::ChangeAnnotationsVisibility( const bool theIsVisible )
+{
+ SalomeApp_Application* anApp = getGeometryGUI()->getApp();
+ if ( !anApp )
+ return;
+
+ SalomeApp_Study* anActiveStudy = dynamic_cast( 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();
+ }
+
+ if ( !anEntry.isEmpty() ) {
+ _PTR(SObject) aSObj = anActiveStudy->studyDS()->FindObjectID( anEntry.toStdString() );
+
+ const Handle(GEOMGUI_AnnotationAttrs)
+ aShapeAnnotations = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
+
+ 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( 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 ) )
+ {
+ _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 );
+ }
+}
+
+//=======================================================================
+// 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)();
+ }
+
+ 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();
+}
+
//=======================================================================
// function : onFinished
// purpose : called then "Manage Dimension" dialog is closed.
diff --git a/src/MeasureGUI/MeasureGUI.h b/src/MeasureGUI/MeasureGUI.h
old mode 100644
new mode 100755
index 3067bbcc2..524225a39
--- a/src/MeasureGUI/MeasureGUI.h
+++ b/src/MeasureGUI/MeasureGUI.h
@@ -27,8 +27,12 @@
#ifndef MEASUREGUI_H
#define MEASUREGUI_H
+// GEOM includes
#include
+// GUI includes
+#include
+
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
index 000000000..99ee4d658
--- /dev/null
+++ b/src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
@@ -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
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include