Version: 9.16.0
GEOMBase_Helper.h
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
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.
10//
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.
15//
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
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// GEOM GEOMGUI : GUI for Geometry component
24// File : GEOMBase_Helper.h
25// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
26
27#ifndef GEOMBASE_HELPER_H
28#define GEOMBASE_HELPER_H
29
30#include "GEOM_GEOMBase.hxx"
31#include "GEOM_GenericObjPtr.h"
32
33#include <GEOM_Displayer.h>
34#include <SALOME_ListIO.hxx>
35#include <SALOMEconfig.h>
36#include CORBA_CLIENT_HEADER(GEOM_Gen)
37
38#include <TColStd_MapOfInteger.hxx>
39
40#include <QString>
41#include <QMap>
42
43#include <list>
44#include <string>
45
46typedef std::list<GEOM::GEOM_Object_ptr> ObjectList;
47
48class SalomeApp_Study;
49class SUIT_Desktop;
50class SUIT_ViewWindow;
51class SALOME_Prs;
52class GEOM_Operation;
53
54//================================================================
55// Class : GEOMBase_Helper
56// Description : Helper class for dialog box development, can be used as
57// the second base class for dialog boxes. Contains convenient methods
58// performing common operations (display/erase, selection activation,
59// publication in a study, transaction management)
60//================================================================
62{
63public:
64 GEOMBase_Helper( SUIT_Desktop*, SUIT_ViewWindow* aVW = 0);
65 virtual ~GEOMBase_Helper();
66 static SUIT_ViewWindow* getActiveView();
67
68protected:
69 typedef std::list<SALOME_Prs*> PrsList;
70
71 static GEOM::GEOM_Gen_ptr getGeomEngine();
72
73 void display ( const ObjectList&, const bool = true );
74 void display ( GEOM::GEOM_Object_ptr, const bool = true );
75 void erase ( const ObjectList&, const bool = true );
76 void erase ( GEOM::GEOM_Object_ptr, const bool = true );
77 void redisplay ( const ObjectList&, const bool = true, const bool = true );
78 void redisplay ( GEOM::GEOM_Object_ptr, const bool = true, const bool = true );
79
80 virtual void displayPreview ( const bool display,
81 const bool activate = false,
82 const bool update = true,
83 const bool toRemoveFromEngine = true,
84 const double lineWidth = -1,
85 const int displayMode = -1,
86 const int color = -1,
87 const bool append = false );
88 // This is the easiest way to show preview. It is based on execute() method.
89 // It removes temporary GEOM::GEOM_Objects automatically.
90
91 virtual void displayPreview ( GEOM::GEOM_Object_ptr obj,
92 const bool append = false,
93 const bool activate = false,
94 const bool update = true,
95 const double lineWidth = -1,
96 const int displayMode = -1,
97 const int color = -1 );
98 void displayPreview ( const SALOME_Prs* prs,
99 const bool append = false,
100 const bool = true );
101 void erasePreview ( const bool = true );
102
103 const PrsList& getPreview() const { return myPreview; }
104
105 void localSelection( const ObjectList&, const std::list<int> );
106 void localSelection( const ObjectList&, const int );
107 void localSelection( GEOM::GEOM_Object_ptr, const std::list<int> );
108 void localSelection( GEOM::GEOM_Object_ptr, const int );
109 void localSelection( const std::string&, const std::string&, const std::list<int> );
110 void localSelection( const std::list<int> );
111 void localSelection( const int );
112 void activate( const int );
113 void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false );
114 void globalSelection( const TColStd_MapOfInteger&, const bool = false );
115 void globalSelection( const TColStd_MapOfInteger&, const QList<int>& ,const bool = false );
116 void updateViewer ();
117
118 void prepareSelection( const ObjectList&, const int );
119 void prepareSelection( GEOM::GEOM_Object_ptr, const int );
120
121 QString addInStudy ( GEOM::GEOM_Object_ptr, const char* theName );
122
123 bool openCommand ();
124 bool abortCommand ();
125 bool commitCommand ( const char* = 0 );
126 bool hasCommand () const;
127
128 void updateObjBrowser() const;
129 SalomeApp_Study* getStudy () const;
130 bool checkViewWindow ();
131
132 bool onAccept( const bool publish = true, const bool useTransaction = true, bool erasePreviewFlag = true);
133 // This method should be called from "OK" button handler.
134 // <publish> == true means that objects returned by execute()
135 // should be published in a study.
136
137 void showError();
138 // Shows a message box with information about an error taken from getOperation()->GetErrorCode()
139 void showError( const QString& msg );
140 // Shows a error message followed by <msg>
141
142 GEOM::GEOM_IOperations_ptr getOperation();
143 // If <myOperation> is nil --> calls createOperation() and put the result
144 // into <myOperation> and returns it;
145 // otherwise, simply returns <myOperation>
146
147 inline void setPrefix( const QString& prefix ) { myPrefix = prefix; }
148 QString getPrefix( GEOM::GEOM_Object_ptr = GEOM::GEOM_Object::_nil() ) const;
149
150 bool selectObjects( ObjectList& objects );
151 // Selects list of objects
152
154 // Virtual methods, to be redefined in dialog classes
156
157 virtual GEOM::GEOM_IOperations_ptr createOperation();
158 // This method should be redefined in dialog boxes so as to return
159 // proper GEOM_IOperation interface.
160 // Returns nil reference by default
161
162 virtual bool isValid( QString& msg );
163 // Called by onAccept(). Redefine this method to check validity of user input in dialog boxes.
164
165 virtual bool execute( ObjectList& objects );
166 // This method is called by onAccept().
167 // It should perform the required operation and put all new or modified objects into
168 // <objects> argument.Should return <false> if some error occurs during its execution.
169
170 virtual void restoreSubShapes( SALOMEDS::SObject_ptr theSObject );
171 // This method is called by addInStudy().
172
173 virtual GEOM::GEOM_Object_ptr getFather( GEOM::GEOM_Object_ptr theObj );
174 // This method is called by addInStudy(). It should return a father object
175 // for <theObj> or a nil reference if <theObj> should be published
176 // as a top-level object.
177
178 virtual QString getNewObjectName (int CurrObj = -1) const;
179 virtual QString getObjectName(GEOM::GEOM_Object_ptr object) const;
180 virtual bool extractPrefix() const;
181 virtual void addSubshapesToStudy();
182 virtual QList<GEOM::GeomObjPtr> getSourceObjects();
183
184 GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, const QString& theName );
185 GEOM::GEOM_Object_ptr findObjectInFather( GEOM::GEOM_Object_ptr theFather, int theIndex );
186 // These methods are used to find published sub-object (sub-shape) in the parent object (main shape)
187
188 GEOM::GeomObjPtr getSelected( TopAbs_ShapeEnum type );
189 GEOM::GeomObjPtr getSelected( const QList<TopAbs_ShapeEnum>& types );
190 QList<GEOM::GeomObjPtr> getSelected( TopAbs_ShapeEnum type, int count, bool strict = true );
191 QList<GEOM::GeomObjPtr> getSelected( const QList<TopAbs_ShapeEnum>& types, int count, bool strict = true );
192
193 void hideSourceObjects( QList<GEOM::GeomObjPtr> theObjectList );
194 void SetIsPreview(const bool thePreview) {isPreview = thePreview;}
195 bool IsPreview() {return isPreview;}
196
197 GEOM_Displayer* getDisplayer();
198 SUIT_Desktop* getDesktop() const;
199
200 virtual void setIsApplyAndClose( const bool theFlag );
201 virtual bool isApplyAndClose() const;
202
203 virtual void setIsOptimizedBrowsing( const bool theFlag );
204 virtual bool isOptimizedBrowsing() const;
205
206 virtual void setIsWaitCursorEnabled( const bool theFlag ) {myIsWaitCursorEnabled = theFlag;}
207 virtual bool isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;}
208 virtual void setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; }
209 virtual bool isDisableBrowsing() const { return myIsDisableBrowsing; }
210 virtual void setIsDisplayResult( const bool theFlag ) {myIsDisplayResult = theFlag; }
211 virtual bool isDisplayResult() const { return myIsDisplayResult; }
212
213private:
214 QString getEntry( GEOM::GEOM_Object_ptr ) const;
215 void clearShapeBuffer( GEOM::GEOM_Object_ptr );
216
217private:
218
222 GEOM::GEOM_IOperations_var myOperation;
223 SUIT_ViewWindow* myViewWindow;
224 QString myPrefix;
226 SALOME_ListIO mySelected;
227 SUIT_Desktop* myDesktop;
231 bool myIsDisableBrowsing; //This flag enable/disable selection
232 //in the Object Browser newly created objects.
233 bool myIsDisplayResult; //This flag display/hide newly created objects.
234};
235
236#endif // GEOMBASE_HELPER_H
std::list< GEOM::GEOM_Object_ptr > ObjectList
Definition: GEOMBase_Helper.h:46
static std::string getEntry(GEOM::GEOM_BaseObject_ptr object)
Definition: GEOM_Displayer.cxx:435
#define GEOM_ALLOBJECTS
Definition: GEOM_Displayer.h:58
#define GEOMBASE_EXPORT
Definition: GEOM_GEOMBase.hxx:36
Definition: GEOMBase_Helper.h:62
bool myIsDisplayResult
Definition: GEOMBase_Helper.h:233
bool IsPreview()
Definition: GEOMBase_Helper.h:195
bool myIsOptimizedBrowsing
Definition: GEOMBase_Helper.h:229
GEOM_Operation * myCommand
Definition: GEOMBase_Helper.h:221
QString myPrefix
Definition: GEOMBase_Helper.h:224
virtual bool isDisableBrowsing() const
Definition: GEOMBase_Helper.h:209
std::list< SALOME_Prs * > PrsList
Definition: GEOMBase_Helper.h:69
virtual void setIsWaitCursorEnabled(const bool theFlag)
Definition: GEOMBase_Helper.h:206
virtual void setIsDisplayResult(const bool theFlag)
Definition: GEOMBase_Helper.h:210
PrsList myPreview
Definition: GEOMBase_Helper.h:219
void SetIsPreview(const bool thePreview)
Definition: GEOMBase_Helper.h:194
SUIT_Desktop * myDesktop
Definition: GEOMBase_Helper.h:227
virtual bool isDisplayResult() const
Definition: GEOMBase_Helper.h:211
bool myIsApplyAndClose
Definition: GEOMBase_Helper.h:228
SUIT_ViewWindow * myViewWindow
Definition: GEOMBase_Helper.h:223
void setPrefix(const QString &prefix)
Definition: GEOMBase_Helper.h:147
const PrsList & getPreview() const
Definition: GEOMBase_Helper.h:103
SALOME_ListIO mySelected
Definition: GEOMBase_Helper.h:226
bool myIsWaitCursorEnabled
Definition: GEOMBase_Helper.h:230
bool myIsDisableBrowsing
Definition: GEOMBase_Helper.h:231
GEOM_Displayer * myDisplayer
Definition: GEOMBase_Helper.h:220
virtual void setIsDisableBrowsing(const bool theFlag)
Definition: GEOMBase_Helper.h:208
virtual bool isWaitCursorEnabled() const
Definition: GEOMBase_Helper.h:207
GEOM::GEOM_IOperations_var myOperation
Definition: GEOMBase_Helper.h:222
bool isPreview
Definition: GEOMBase_Helper.h:225
void prepareSelection(GEOM::GEOM_Object_ptr, const int)
void prepareSelection(const ObjectList &, const int)
Definition: GEOM_Displayer.h:72
Definition: GEOM_Operation.h:37
GenericObjPtr< GEOM::GEOM_Object > GeomObjPtr
Definition: GEOM_GenericObjPtr.h:218