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"
38 //---------------------------------------------------------------
39 template<class TPrs3d_i, class TDlg>
41 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
43 TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
45 TDlg* aDlg = new TDlg (theModule);
46 aDlg->initFromPrsObject(aPrsObject);
48 if (!(aDlg->storeToPrsObject(aPrsObject))) {
52 RecreateActor(theModule, aPrsObject);
53 if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
54 vw->getRenderer()->ResetCameraClippingRange();
57 // Optionally, create table and curves for cut lines
58 QApplication::setOverrideCursor(Qt::waitCursor);
59 CreateCurves( theModule,
60 dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
62 false ); // in edition mode
63 QApplication::restoreOverrideCursor();
70 //---------------------------------------------------------------
71 template<class TPrs3d_i>
73 CreatePrs3d(SalomeApp_Module* theModule,
74 _PTR(SObject) theTimeStamp,
75 const char* theMeshName,
76 VISU::Entity theEntity,
77 const char* theFieldName,
80 VISU::Result_var aResult;
81 if (CheckResult(theModule,theTimeStamp,aResult)){
82 QApplication::setOverrideCursor(Qt::waitCursor);
83 typedef typename TPrs3d_i::TInterface TPrs3d;
84 typename TPrs3d::_var_type aPrs3d =
85 GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
86 (aResult,theMeshName,theEntity,theFieldName,theTimeId);
87 QApplication::restoreOverrideCursor();
88 if (!CORBA::is_nil(aPrs3d.in()))
89 return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
91 SUIT_MessageBox::warn1(GetDesktop(theModule),
92 QObject::tr("WRN_VISU"),
93 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
94 QObject::tr("BUT_OK") );
99 //---------------------------------------------------------------
100 template<class TPrs3d_i, class TDlg, int IsDlgModal>
102 CreatePrs3d(SalomeApp_Module* theModule,
103 _PTR(SObject) theTimeStamp,
104 const Handle(SALOME_InteractiveObject)& theIO)
106 using namespace VISU;
107 Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
109 QString aType = Storable::FindValue(aMap,"myType",&isExist);
110 if(!isExist || aType.toInt() != TTIMESTAMP )
112 QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
113 QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
114 QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
115 QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
116 QApplication::setOverrideCursor(Qt::waitCursor);
119 CreatePrs3d<TPrs3d_i>(theModule,
122 (Entity)anEntity.toInt(),
124 aTimeStampId.toInt());
126 QApplication::restoreOverrideCursor();
128 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
129 int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
131 if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
132 aDlg->initFromPrsObject(aPrs3d);
134 if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
135 // Optionally, create table and curves for cut lines
136 QApplication::setOverrideCursor(Qt::waitCursor);
137 CreateCurves( theModule,
138 dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
140 true ); // in creation mode
141 QApplication::restoreOverrideCursor();
144 DeletePrs3d(theModule,aPrs3d,theIO);
154 PublishInView(theModule,aPrs3d);
161 //---------------------------------------------------------------
162 template<class TPrs3d_i, class TDlg, int IsDlgModal>
164 CreatePrs3d(SalomeApp_Module* theModule)
166 if (CheckLock(GetCStudy(GetAppStudy(theModule))))
169 _PTR(SObject) aTimeStampSObj;
170 Handle(SALOME_InteractiveObject) anIO;
171 if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
174 if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
177 theModule->application()->putInfo(QObject::tr("INF_DONE"));
178 theModule->updateObjBrowser();
179 UpdateObjBrowser(theModule);
181 if (SVTK_ViewWindow* aView = GetViewWindow(theModule))