1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_Module.h
29 #ifndef VisuGUI_Prs3dTools_HeaderFile
30 #define VisuGUI_Prs3dTools_HeaderFile
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_DialogRunner.h"
35 int runAndWait( QDialog* dlg, const bool modal )
37 VisuGUI_DialogRunner r( dlg );
38 return r.run( modal );
45 //---------------------------------------------------------------
46 template<class TPrs3d_i, class TDlg, int IsDlgModal >
48 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
50 TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
52 TDlg* aDlg = new TDlg (theModule);
53 aDlg->initFromPrsObject(aPrsObject);
54 if (runAndWait(aDlg,IsDlgModal)) {
55 if (!(aDlg->storeToPrsObject(aPrsObject))) {
59 RecreateActor(theModule, aPrsObject);
60 if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
61 vw->getRenderer()->ResetCameraClippingRange();
64 // Optionally, create table and curves for cut lines
65 QApplication::setOverrideCursor(Qt::waitCursor);
66 CreateCurves( theModule,
67 dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
69 false ); // in edition mode
70 QApplication::restoreOverrideCursor();
77 //---------------------------------------------------------------
78 template<class TPrs3d_i>
80 CreatePrs3d(SalomeApp_Module* theModule,
81 _PTR(SObject) theTimeStamp,
82 const char* theMeshName,
83 VISU::Entity theEntity,
84 const char* theFieldName,
87 VISU::Result_var aResult;
88 if (CheckResult(theModule,theTimeStamp,aResult)){
89 QApplication::setOverrideCursor(Qt::waitCursor);
90 typedef typename TPrs3d_i::TInterface TPrs3d;
91 typename TPrs3d::_var_type aPrs3d =
92 GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
93 (aResult,theMeshName,theEntity,theFieldName,theTimeId);
94 QApplication::restoreOverrideCursor();
95 if (!CORBA::is_nil(aPrs3d.in()))
96 return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
98 SUIT_MessageBox::warn1(GetDesktop(theModule),
99 QObject::tr("WRN_VISU"),
100 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
101 QObject::tr("BUT_OK") );
106 //---------------------------------------------------------------
107 template<class TPrs3d_i, class TDlg, int IsDlgModal>
109 CreatePrs3d(SalomeApp_Module* theModule,
110 _PTR(SObject) theTimeStamp,
111 const Handle(SALOME_InteractiveObject)& theIO)
113 using namespace VISU;
114 Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
116 QString aType = Storable::FindValue(aMap,"myType",&isExist);
117 if(!isExist || aType.toInt() != TTIMESTAMP )
119 QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
120 QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
121 QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
122 QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
123 QApplication::setOverrideCursor(Qt::waitCursor);
126 CreatePrs3d<TPrs3d_i>(theModule,
129 (Entity)anEntity.toInt(),
131 aTimeStampId.toInt());
133 QApplication::restoreOverrideCursor();
135 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
136 int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
138 if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
139 aDlg->initFromPrsObject(aPrs3d);
141 if(runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) {
142 // Optionally, create table and curves for cut lines
143 QApplication::setOverrideCursor(Qt::waitCursor);
144 CreateCurves( theModule,
145 dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
147 true ); // in creation mode
148 QApplication::restoreOverrideCursor();
151 DeletePrs3d(theModule,aPrs3d,theIO);
157 PublishInView(theModule,aPrs3d);
164 //---------------------------------------------------------------
165 template<class TPrs3d_i, class TDlg, int IsDlgModal>
167 CreatePrs3d(SalomeApp_Module* theModule)
169 if (CheckLock(GetCStudy(GetAppStudy(theModule))))
172 _PTR(SObject) aTimeStampSObj;
173 Handle(SALOME_InteractiveObject) anIO;
174 if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
177 if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
180 theModule->application()->putInfo(QObject::tr("INF_DONE"));
181 theModule->updateObjBrowser();
182 UpdateObjBrowser(theModule);
184 if (SVTK_ViewWindow* aView = GetViewWindow(theModule))