#ifndef VisuGUI_Prs3dTools_HeaderFile
#define VisuGUI_Prs3dTools_HeaderFile
-#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
namespace VISU
{
//---------------------------------------------------------------
- template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
bool
CreatePrs3d(SalomeApp_Module* theModule,
_PTR(SObject) theTimeStamp,
const Handle(SALOME_InteractiveObject)& theIO)
{
- using namespace VISU;
Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
+
bool isExist;
QString aType = Storable::FindValue(aMap,"myType",&isExist);
if(!isExist || aType.toInt() != TTIMESTAMP )
return false;
+
QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
aDlg->initFromPrsObject(aPrs3d);
if(IsDlgModal)
- if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
+ if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))){
// Optionally, create table and curves for cut lines
QApplication::setOverrideCursor(Qt::waitCursor);
CreateCurves( theModule,
}
}
}
- PublishInView(theModule,aPrs3d);
+ PublishInView<TViewer>(theModule,aPrs3d);
+
return true;
}
+
return false;
}
//---------------------------------------------------------------
- template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
void
CreatePrs3d(SalomeApp_Module* theModule)
{
_PTR(SObject) aTimeStampSObj;
Handle(SALOME_InteractiveObject) anIO;
- if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
+ if(!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
return;
- if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
+ if(!CreatePrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
return;
theModule->application()->putInfo(QObject::tr("INF_DONE"));
- theModule->updateObjBrowser();
UpdateObjBrowser(theModule);
- if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
+ typedef typename TViewer::TViewWindow TView;
+ if(TView* aView = GetViewWindow<TViewer>(theModule))
aView->onFitAll();
}
+ template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ void
+ CreatePrs3d(SalomeApp_Module* theModule)
+ {
+ CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ }
}
#endif
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VisuGUI_Tools.h
+// Author : Sergey Anikin
+// Module : VISU
+
+#ifndef VisuGUI_ViewTools_HeaderFile
+#define VisuGUI_ViewTools_HeaderFile
+
+#include "SUIT_MessageBox.h"
+#include "SUIT_ViewManager.h"
+#include "SUIT_ViewWindow.h"
+
+#include "SalomeApp_Module.h"
+#include "SalomeApp_Application.h"
+
+#include "VISU_Prs3d_i.hh"
+
+namespace VISU
+{
+ //---------------------------------------------------------------
+ template<class TViewer>
+ typename TViewer::TViewWindow*
+ GetViewWindow(const SalomeApp_Module* theModule,
+ const bool theCreate = false)
+ {
+ typedef typename TViewer::TViewWindow TView;
+ if(SalomeApp_Application* anApp = theModule->getApp()){
+ if(SUIT_ViewManager* aViewManager = anApp->getViewManager( TViewer::Type(), theCreate )){
+ if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
+ return dynamic_cast<TView*>(aViewWindow);
+ }
+ }
+ }
+ return NULL;
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TViewer>
+ VISU_Actor*
+ PublishInView(const SalomeApp_Module* theModule,
+ Prs3d_i* thePrs)
+ {
+ VISU_Actor* aActor = NULL;
+
+ if(!thePrs)
+ return aActor;
+
+ typedef typename TViewer::TViewWindow TView;
+ if(TView* aView = GetViewWindow<TViewer>(theModule)){
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ try{
+ if(aActor = thePrs->CreateActor())
+ aView->AddActor(aActor);
+ }catch(std::exception& exc){
+ SUIT_MessageBox::warn1(GetDesktop(theModule),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_CREATE_ACTOR"),
+ QObject::tr("BUT_OK"));
+ }
+ QApplication::restoreOverrideCursor();
+ }
+ return aActor;
+ }
+}
+
+#endif