1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef GEOMGUI_ANNOTATIONMGR_H
21 #define GEOMGUI_ANNOTATIONMGR_H
23 #include "GEOM_GEOMGUI.hxx"
25 #include <SALOMEconfig.h>
26 #include CORBA_SERVER_HEADER(GEOM_Gen)
29 #include <GEOMGUI_AnnotationAttrs.h>
31 #include <SALOME_Prs.h>
32 #include <SALOME_InteractiveObject.hxx>
34 #include <SOCC_ViewModel.h>
36 class SalomeApp_Application;
37 class GEOM_Annotation;
41 * \brief A help class to process visualization of annotation presentations.
42 * It contains a map of presentations shown in each viewer.
43 * and correct 2D position persistent properties of annotations of active viewer.
44 * When the viewer is closed, information about the viewer is removed from the manager
46 class GEOMGUI_EXPORT GEOMGUI_AnnotationMgr : public QObject
51 GEOMGUI_AnnotationMgr( SalomeApp_Application* theApplication );
52 ~GEOMGUI_AnnotationMgr() {}
54 static QString GetEntrySeparator();
56 SALOME_Prs* CreatePresentation( const GEOMGUI_AnnotationAttrs::Properties& theProperty,
57 GEOM::GEOM_Object_ptr theObject,
58 SOCC_Viewer* theView = 0,
59 const QString& theEntry = QString() );
61 bool IsDisplayed( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0 ) const;
62 void Display( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
63 const bool isStoreViewState = true, const bool isUpdateViewer = true );
64 void Erase( const QString& theEntry, const int theIndex, SOCC_Viewer* theView = 0,
65 const bool isUpdateViewer = true );
66 void EraseRemovedAnnotation( const QString& theEntry, const int theIndex );
67 void Redisplay( const QString& theEntry, const int theIndex,
68 const GEOMGUI_AnnotationAttrs::Properties& theProperties);
69 void Redisplay( const QString& theEntry, const int theIndex,
70 const GEOMGUI_AnnotationAttrs::Properties& theProperties, SOCC_Viewer* theView );
72 void DisplayVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
73 const bool isUpdateViewer = true );
74 void EraseVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0,
75 const bool isUpdateViewer = true );
76 void UpdateVisibleAnnotations( const QString& theEntry, SOCC_Viewer* theView = 0 );
78 void DisplayAllAnnotations( SOCC_Viewer* theView = 0 );
79 void EraseAllAnnotations( SOCC_Viewer* theView = 0 );
81 void SetPreviewStyle( const QString& theEntry, const int theIndex, const bool theIsPreview );
83 void RemoveView( SOCC_Viewer* theView );
85 int FindAnnotationIndex( Handle(SALOME_InteractiveObject) theIO,
86 SOCC_Viewer* theView = 0 );
88 Handle(SALOME_InteractiveObject) FindInteractiveObject( const QString& theEntry, const int theIndex,
89 SOCC_Viewer* theView = 0 ) const;
91 QString getDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView ) const;
93 void setDisplayedIndicesInfo( const QString& theEntry, SOCC_Viewer* theView, const QString theIndicesInfo );
95 QString makeAnnotationEntry( const QString& theEntry, const int theIndex );
97 void storeFixedPosition( const QString& theEntry, SOCC_Viewer* theView );
99 bool getIndexFromEntry( const QString& theEntry, QString& theObjEntry, int& theIndex );
101 bool isAnnotationEntry( const QString& theEntry ) { return theEntry.indexOf( GetEntrySeparator() ) != -1; }
105 SalomeApp_Application* getApplication() const { return myApplication; }
107 GEOM_Displayer* getDisplayer() const;
109 SOCC_Viewer* viewOrActiveView( SOCC_Viewer* theView ) const;
111 void getObject( const QString& theEntry, const int theIndex,
112 GEOM::GEOM_Object_ptr& anObject,
113 GEOMGUI_AnnotationAttrs::Properties& aProperty );
115 void storeVisibleState( const QString& theEntry, SOCC_Viewer* theView );
117 std::string getEntry( const GEOM::GEOM_Object_ptr theObject );
119 std::string getName( const GEOM::GEOM_Object_ptr theObject );
121 void setDisplayProperties( const Handle(GEOM_Annotation)& thePrs,
122 SOCC_Viewer* theView = 0,
123 const QString& theEntry = QString() );
125 Handle(GEOM_Annotation) getAISPresentation ( const QString& theEntry,
127 SOCC_Viewer* theView );
130 SalomeApp_Application* myApplication;
132 typedef QMap<int, SALOME_Prs*> AnnotationToPrs;
133 typedef QMap<QString, AnnotationToPrs> EntryToAnnotations;
134 QMap<SOCC_Viewer*, EntryToAnnotations> myVisualized;