#ifndef VisuGUI_Prs3dTools_HeaderFile
#define VisuGUI_Prs3dTools_HeaderFile
-#include "VisuGUI_Tools.h"
+#include "VISU_Gen_i.hh"
+#include "VisuGUI_ViewTools.h"
#include "VisuGUI_DialogRunner.h"
-int runAndWait( QDialog* dlg, const bool modal )
-{
- VisuGUI_DialogRunner r( dlg );
- return r.run( modal );
-}
+#include <vtkRenderer.h>
namespace VISU
{
class CutLines_i;
//---------------------------------------------------------------
- template<class TPrs3d_i, class TDlg, int IsDlgModal >
+ inline
+ int
+ runAndWait( QDialog* dlg, const bool modal )
+ {
+ VisuGUI_DialogRunner r( dlg );
+ return r.run( modal );
+ }
+
+ //---------------------------------------------------------------
+ template<class TPrs3d_i, class TViewer, class TDlg, int TIsDlgModal>
void
- EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
+ EditPrs3d(VisuGUI* theModule,
+ VISU::Prs3d_i* thePrs3d)
{
- TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
- if (aPrsObject) {
+ if(TPrs3d_i* aPrs3d = dynamic_cast<TPrs3d_i*>(thePrs3d)){
TDlg* aDlg = new TDlg (theModule);
- aDlg->initFromPrsObject(aPrsObject);
- if (runAndWait(aDlg,IsDlgModal)) {
- if (!(aDlg->storeToPrsObject(aPrsObject))) {
+ aDlg->initFromPrsObject(aPrs3d);
+ if (runAndWait(aDlg,TIsDlgModal)) {
+ if (!(aDlg->storeToPrsObject(aPrs3d))) {
delete aDlg;
return;
}
- RecreateActor(theModule, aPrsObject);
- if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
- vw->getRenderer()->ResetCameraClippingRange();
- vw->Repaint();
+ try {
+ aPrs3d->UpdateActors();
+ } catch (std::runtime_error& exc) {
+ INFOS(exc.what());
+ SUIT_MessageBox::warn1
+ (GetDesktop(theModule), QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()),
+ QObject::tr("BUT_OK"));
+
+ aPrs3d->RemoveActors();
+ }
+ typedef typename TViewer::TViewWindow TViewWindow;
+ if(TViewWindow* aViewWindow = GetViewWindow<TViewer>(theModule)){
+ aViewWindow->getRenderer()->ResetCameraClippingRange();
+ aViewWindow->Repaint();
}
// Optionally, create table and curves for cut lines
QApplication::setOverrideCursor(Qt::waitCursor);
CreateCurves( theModule,
- dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
+ dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
aDlg,
false ); // in edition mode
QApplication::restoreOverrideCursor();
}
}
+ template<class TPrs3d_i, class TDlg, int TIsDlgModal>
+ inline
+ void
+ EditPrs3d(VisuGUI* theModule,
+ VISU::Prs3d_i* thePrs3d)
+ {
+ EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg,TIsDlgModal>(theModule,thePrs3d);
+ }
//---------------------------------------------------------------
template<class TPrs3d_i>
+ inline
TPrs3d_i*
- CreatePrs3d(SalomeApp_Module* theModule,
+ CreatePrs3d(VisuGUI* theModule,
_PTR(SObject) theTimeStamp,
const char* theMeshName,
VISU::Entity theEntity,
VISU::Result_var aResult;
if (CheckResult(theModule,theTimeStamp,aResult)){
QApplication::setOverrideCursor(Qt::waitCursor);
- typedef typename TPrs3d_i::TInterface TPrs3d;
- typename TPrs3d::_var_type aPrs3d =
- GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
+ TPrs3d_i* aPrs3d =
+ GetVisuGen(theModule)->template CreatePrs3d<TPrs3d_i>
(aResult,theMeshName,theEntity,theFieldName,theTimeId);
QApplication::restoreOverrideCursor();
- if (!CORBA::is_nil(aPrs3d.in()))
- return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
+ if(aPrs3d)
+ return aPrs3d;
}
SUIT_MessageBox::warn1(GetDesktop(theModule),
QObject::tr("WRN_VISU"),
//---------------------------------------------------------------
- template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
+ inline
bool
- CreatePrs3d(SalomeApp_Module* theModule,
+ CreatePrs3d(VisuGUI* theModule,
_PTR(SObject) theTimeStamp,
- const Handle(SALOME_InteractiveObject)& theIO)
+ const Handle(SALOME_InteractiveObject)& theIO,
+ const bool theIsCreateView = false)
{
- 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();
QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
//
- SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
- VisuGUI* aMod = dynamic_cast<VisuGUI*>(theModule);
- int aPos = 1;
- if (aMod) aPos = GetFreePositionOfDefaultScalarBar(aMod);
- aResourceMgr->setValue("VISU","scalar_bar_position_num",aPos);
+ int aPos = GetFreePositionOfDefaultScalarBar(theModule);
+ GetResourceMgr()->setValue("VISU","scalar_bar_position_num",aPos);
//
QApplication::setOverrideCursor(Qt::waitCursor);
dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
aDlg,
true ); // in creation mode
+ UpdateObjBrowser(theModule,true,theTimeStamp);
QApplication::restoreOverrideCursor();
delete aDlg;
} else {
}
}
}
- PublishInView(theModule,aPrs3d);
- Prs3d_i* aPrs_i = dynamic_cast<Prs3d_i*>(aPrs3d);
- if (aPrs_i != NULL && aMod != NULL)
- AddScalarBarPosition(aMod,aPrs_i,aPos);
+ PublishInView<TViewer>(theModule,aPrs3d,true,theIsCreateView);
+
+ AddScalarBarPosition(theModule,aPrs3d,aPos);
+
return true;
}
+
return false;
}
-
+
//---------------------------------------------------------------
- template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
+ inline
void
- CreatePrs3d(SalomeApp_Module* theModule)
+ CreatePrs3d(VisuGUI* theModule,
+ const bool theIsCreateView = true)
{
- if (CheckLock(GetCStudy(GetAppStudy(theModule))))
+ if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
return;
_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,theIsCreateView))
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,theIsCreateView))
aView->onFitAll();
}
+ template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ inline
+ void
+ CreatePrs3d(VisuGUI* theModule,
+ const bool theIsCreateView = true)
+ {
+ if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
+ QString aType = aViewManager->getType();
+ if(aType == SVTK_Viewer::Type())
+ CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule,theIsCreateView);
+ else if(aType == VVTK_Viewer::Type())
+ CreatePrs3d<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>(theModule,theIsCreateView);
+ }
+ }
+
}
#endif