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"
34 int runAndWait( QDialog* dlg, const bool modal )
50 //---------------------------------------------------------------
51 template<class TPrs3d_i, class TDlg, int IsDlgModal >
53 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
55 TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
57 TDlg* aDlg = new TDlg (theModule);
58 aDlg->initFromPrsObject(aPrsObject);
59 if (runAndWait(aDlg,IsDlgModal)) {
60 if (!(aDlg->storeToPrsObject(aPrsObject))) {
64 RecreateActor(theModule, aPrsObject);
65 if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
66 vw->getRenderer()->ResetCameraClippingRange();
69 // Optionally, create table and curves for cut lines
70 QApplication::setOverrideCursor(Qt::waitCursor);
71 CreateCurves( theModule,
72 dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
74 false ); // in edition mode
75 QApplication::restoreOverrideCursor();
82 //---------------------------------------------------------------
83 template<class TPrs3d_i>
85 CreatePrs3d(SalomeApp_Module* theModule,
86 _PTR(SObject) theTimeStamp,
87 const char* theMeshName,
88 VISU::Entity theEntity,
89 const char* theFieldName,
92 VISU::Result_var aResult;
93 if (CheckResult(theModule,theTimeStamp,aResult)){
94 QApplication::setOverrideCursor(Qt::waitCursor);
95 typedef typename TPrs3d_i::TInterface TPrs3d;
96 typename TPrs3d::_var_type aPrs3d =
97 GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
98 (aResult,theMeshName,theEntity,theFieldName,theTimeId);
99 QApplication::restoreOverrideCursor();
100 if (!CORBA::is_nil(aPrs3d.in()))
101 return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
103 SUIT_MessageBox::warn1(GetDesktop(theModule),
104 QObject::tr("WRN_VISU"),
105 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
106 QObject::tr("BUT_OK") );
111 //---------------------------------------------------------------
112 template<class TPrs3d_i, class TDlg, int IsDlgModal>
114 CreatePrs3d(SalomeApp_Module* theModule,
115 _PTR(SObject) theTimeStamp,
116 const Handle(SALOME_InteractiveObject)& theIO)
118 using namespace VISU;
119 Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
121 QString aType = Storable::FindValue(aMap,"myType",&isExist);
122 if(!isExist || aType.toInt() != TTIMESTAMP )
124 QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
125 QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
126 QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
127 QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
128 QApplication::setOverrideCursor(Qt::waitCursor);
131 CreatePrs3d<TPrs3d_i>(theModule,
134 (Entity)anEntity.toInt(),
136 aTimeStampId.toInt());
138 QApplication::restoreOverrideCursor();
140 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
141 int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
143 if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
144 aDlg->initFromPrsObject(aPrs3d);
146 if(runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) {
147 // Optionally, create table and curves for cut lines
148 QApplication::setOverrideCursor(Qt::waitCursor);
149 CreateCurves( theModule,
150 dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
152 true ); // in creation mode
153 QApplication::restoreOverrideCursor();
156 DeletePrs3d(theModule,aPrs3d,theIO);
162 PublishInView(theModule,aPrs3d);
169 //---------------------------------------------------------------
170 template<class TPrs3d_i, class TDlg, int IsDlgModal>
172 CreatePrs3d(SalomeApp_Module* theModule)
174 if (CheckLock(GetCStudy(GetAppStudy(theModule))))
177 _PTR(SObject) aTimeStampSObj;
178 Handle(SALOME_InteractiveObject) anIO;
179 if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
182 if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
185 theModule->application()->putInfo(QObject::tr("INF_DONE"));
186 theModule->updateObjBrowser();
187 UpdateObjBrowser(theModule);
189 if (SVTK_ViewWindow* aView = GetViewWindow(theModule))