1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : GEOMGUI_AnnotationAttrs.h
24 // Author : Anton POLETAEV, Open CASCADE S.A.S.
27 #ifndef GEOMGUI_ANNOTATIONATTRS_H
28 #define GEOMGUI_ANNOTATIONATTRS_H
30 // SALOME GUI includes
32 #include <SalomeApp_Study.h>
37 #include <Standard_Transient.hxx>
42 class GEOM_Annotation;
46 * \brief Attribute-style helper tool to manage shape annotation data of an object.
48 class GEOMGUI_AnnotationAttrs : public Standard_Transient
52 DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
54 //! Find annotation data defined for an object.
55 GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject );
57 //! Find or create annotation data fields for an object.
58 GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject,
59 SalomeApp_Study* theStudy );
61 //! Remove annotation data fields for an object.
62 GEOMGUI_EXPORT static void Remove( const _PTR(SObject)& theObject );
67 //! Exports annotation records as a property string.
68 GEOMGUI_EXPORT QString ExportAsPropertyString() const;
70 //! Imports annotation records from a property string.
71 GEOMGUI_EXPORT void ImportFromPropertyString( const QString& theString );
76 * \ brief Structure representing visual properties of the shape annotation.
80 QString Text; //!< Displayed annotation text.
81 bool IsVisible; //!< Application visibility flag of annotation.
82 bool IsScreenFixed; //!< Fixed screen mode flag.
83 gp_Pnt Position; //!< Position of the annotation.
84 gp_Pnt Attach; //!< Attachment point of the annotation.
85 int ShapeIndex; //!< Index of the annotated subshape.
86 int ShapeType; //!< Type of the annotated subshape.
89 //! Setup parameters of the annotation presentation with the properties given.
90 //! @param thePresentation [in] the presentation to setup.
91 //! @param theProps [in] the set of properties.
92 //! @param theShapeLCS [in] the local coordinate system of the shape.
93 GEOMGUI_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
94 const Properties& theProps,
95 const gp_Ax3& theShapeLCS );
97 //! Setup parameters of the annotation presentation with the properties of a definition.
98 //! @param thePresentation [in] the presentation to setup.
99 //! @param theIndex [in] the index of the annotation definition.
100 //! @param theShapeLCS [in] the local coordinate system of the shape.
101 GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
103 const gp_Ax3& theShapeLCS );
107 //! Changes count of annotation definitions stored on the object.
108 //! If the count is decreased the extra annotation definitions are
109 //! cleared out from the attribute.
110 //! @param theNumber [in] the new number of annotation definitions.
111 GEOMGUI_EXPORT void SetNbAnnotation( const int theCount ) const;
113 //! Returns number of annotation definitions stored on the object.
114 GEOMGUI_EXPORT int GetNbAnnotation() const;
116 //! Sets application visibility state of an annotation definition.
117 //! @param theIndex [in] the index of the annotation definition.
118 //! @param theIsVisible [in] the visibility state.
119 GEOMGUI_EXPORT void SetIsVisible( const int theIndex, const bool theIsVisible );
121 //! Returns applicationb visibility state of an annotaion definition.
122 GEOMGUI_EXPORT bool GetIsVisible( const int theIndex ) const;
124 //! Sets annotation label's text.
125 //! @param theIndex [in] the index of the annotation definition.
126 //! @param theText [in] the text string.
127 GEOMGUI_EXPORT void SetText( const int theIndex, const QString& theText );
129 //! Returns annotation label's text.
130 GEOMGUI_EXPORT QString GetText( const int theIndex ) const;
132 //! Sets screen fixed flag of the annotation definition.
133 //! @param theIndex [in] the index of the annotation definition.
134 //! @param theIsScreenFixed [in] the presentation flag.
135 GEOMGUI_EXPORT void SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed );
137 //! Returns screen fixed flag of the annotation definition.
138 GEOMGUI_EXPORT bool GetIsScreenFixed( const int theIndex ) const;
140 //! Sets position of the annotation definition.
141 //! @param theIndex [in] the index of the annotation definition.
142 //! @param thePosition [in] the position of the annotation label.
143 GEOMGUI_EXPORT void SetPosition( const int theIndex, const gp_Pnt& thePosition );
145 //! Returns position of the annotation definition.
146 GEOMGUI_EXPORT gp_Pnt GetPosition( const int theIndex ) const;
148 //! Sets attach point of the annotation definition.
149 //! @param theIndex [in] the index of the annotation definition.
150 //! @param theAttach [in] the attach point of the annotation.
151 GEOMGUI_EXPORT void SetAttach( const int theIndex, const gp_Pnt& theAttach );
153 //! Returns attach point of the annotation definition.
154 GEOMGUI_EXPORT gp_Pnt GetAttach( const int theIndex ) const;
156 //! Sets shape selection arguments.
157 //! @param theIndex [in] the index of the annotation definition.
158 //! @param theShapeType, theSubIdx [in] the type of the selected shape and the sub-shape index.
159 GEOMGUI_EXPORT void SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx );
161 //! Returns shape selection arguments.
162 //! @param theIndex [in] the index of the annotation definition.
163 //! @param theShapeType, theSubIdx [out] the type of the selected shape and the sub-shape index.
164 GEOMGUI_EXPORT void GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const;
168 //! Appends new annotation definition with the given properties.
169 GEOMGUI_EXPORT void Append( const Properties& theProps );
171 //! Appends new annotation definition with the given properties and converts
172 //! position and attachment points to the given shape's local frame of reference.
173 //! @param theShapeLCS [in] the position of shape's local frame of reference with respect
174 //! to the world frame of reference.
175 GEOMGUI_EXPORT void Append( const Properties& theProps, const gp_Ax3& theShapeLCS );
177 //! Removes annotation definition by the given index.
178 //! This methods performs iterative reindexing of elements starting
179 //! from the given index, so sequential removal should be performed
180 //! from the last element, or avoided at all.
181 GEOMGUI_EXPORT void Remove( const Standard_Integer theIndex );
183 //! Sets complete properties of an annotation definition.
184 //! @param theIndex [in] the index of the annotation definition.
185 //! @param theProps [in] the structure containing the properties.
186 GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps );
188 //! Sets complete properties of an annotation definition with converting
189 //! position and attachment points to the given shape's local frame
191 //! @param theIndex [in] the index of the annotation definition.
192 //! @param theProps [in] the structure containing the properties.
193 //! @param theShapeLCS [in] the position of shape's local frame of reference with respect
194 //! to the world frame of reference.
195 GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps, const gp_Ax3& theShapeLCS );
197 //! Returns complete properties of an annotation definition.
198 //! @param theIndex [in] the index of the annotation definition.
199 //! @param theProps [out] the structure containing the properties.
200 GEOMGUI_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const;
204 GEOMGUI_AnnotationAttrs( const _PTR(SObject)& theObject, const _PTR(AttributeParameter)& theParameter )
205 : myObj( theObject ),
206 myParameterMap( theParameter ) {}
208 GEOMGUI_AnnotationAttrs( const GEOMGUI_AnnotationAttrs& theOther ) {}
210 void operator=( const GEOMGUI_AnnotationAttrs& theOther ) {}
215 _PTR(AttributeParameter) myParameterMap;
218 DEFINE_STANDARD_HANDLE( GEOMGUI_AnnotationAttrs, Standard_Transient )