// File : VisuGUI_Module.h
// Author :
// Module : VISU
-// $Header$
#ifndef VisuGUI_Prs3dTools_HeaderFile
#define VisuGUI_Prs3dTools_HeaderFile
template<class TPrs3d_i, class TViewer, class TDlg, int TIsDlgModal>
void
EditPrs3d(VisuGUI* theModule,
- VISU::Prs3d_i* thePrs3d)
+ VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow)
{
- if(TPrs3d_i* aPrs3d = dynamic_cast<TPrs3d_i*>(thePrs3d)){
+ if (TPrs3d_i* aPrs3d = dynamic_cast<TPrs3d_i*>(thePrs3d)) {
TDlg* aDlg = new TDlg (theModule);
aDlg->initFromPrsObject(aPrs3d);
if (runAndWait(aDlg,TIsDlgModal)) {
try {
aPrs3d->UpdateActors();
} catch (std::runtime_error& exc) {
+ aPrs3d->RemoveActors();
+
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();
+ if (theViewWindow) {
+ theViewWindow->getRenderer()->ResetCameraClippingRange();
+ theViewWindow->Repaint();
}
// Optionally, create table and curves for cut lines
QApplication::setOverrideCursor(Qt::waitCursor);
template<class TPrs3d_i, class TDlg, int TIsDlgModal>
inline
void
- EditPrs3d(VisuGUI* theModule,
- VISU::Prs3d_i* thePrs3d)
+ EditPrs3d(VisuGUI* theModule,
+ Handle(SALOME_InteractiveObject)& theIO,
+ VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow = NULL)
{
- EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg,TIsDlgModal>(theModule,thePrs3d);
+ SVTK_ViewWindow* aViewWindow = theViewWindow;
+ if (!aViewWindow)
+ // Create SVTK_ViewWindow, if it does not exist
+ aViewWindow = GetViewWindow<SVTK_Viewer>(theModule);
+ if (aViewWindow) {
+ EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg,TIsDlgModal>(theModule, thePrs3d, aViewWindow);
+ aViewWindow->highlight(theIO, 1);
+ }
}
//---------------------------------------------------------------
bool
CreatePrs3d(VisuGUI* theModule,
_PTR(SObject) theTimeStamp,
- const Handle(SALOME_InteractiveObject)& theIO,
- const bool theIsCreateView = false)
+ const Handle(SALOME_InteractiveObject)& theIO)
{
Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
bool isExist;
QString aType = Storable::FindValue(aMap,"myType",&isExist);
- if(!isExist || aType.toInt() != TTIMESTAMP )
+ 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();
- //
- int aPos = GetFreePositionOfDefaultScalarBar(theModule);
- GetResourceMgr()->setValue("VISU","scalar_bar_position_num",aPos);
- //
+
+ // Create new TViewWindow instance, if it does not exist.
+ typedef typename TViewer::TViewWindow TViewWindow;
+ TViewWindow* aViewWindow = GetViewWindow<TViewer>(theModule);
+
+ // Define free position for scalar bar.
+ int aPos = GetFreePositionOfDefaultScalarBar(theModule, aViewWindow);
+ GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos);
+
QApplication::setOverrideCursor(Qt::waitCursor);
-
+
TPrs3d_i* aPrs3d =
CreatePrs3d<TPrs3d_i>(theModule,
theTimeStamp,
(Entity)anEntity.toInt(),
aFieldName.latin1(),
aTimeStampId.toInt());
-
+
QApplication::restoreOverrideCursor();
- if(aPrs3d){
+ if (aPrs3d) {
SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
- if(!aValue){
- if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
+ if (!aValue) {
+ if (TDlg* aDlg = new TDlg(theModule)) { // dialog box in creation mode
aDlg->initFromPrsObject(aPrs3d);
- if(runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) {
+ if (runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) {
// Optionally, create table and curves for cut lines
QApplication::setOverrideCursor(Qt::waitCursor);
CreateCurves( theModule,
}
}
}
- PublishInView<TViewer>(theModule,aPrs3d,true,theIsCreateView);
- AddScalarBarPosition(theModule,aPrs3d,aPos);
+ // Display created presentation.
+ if (aViewWindow) {
+ PublishInView(theModule, aPrs3d, aViewWindow, /*highlight = */true);
+ aViewWindow->onFitAll();
+
+ AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos);
+ }
return true;
}
return false;
}
-
+
//---------------------------------------------------------------
template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
inline
void
- CreatePrs3d(VisuGUI* theModule,
- const bool theIsCreateView = true)
+ CreatePrs3d(VisuGUI* 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,TViewer,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO,theIsCreateView))
+
+ // Create new TViewWindow instance, if it does not exist.
+ typedef typename TViewer::TViewWindow TViewWindow;
+ if (!GetViewWindow<TViewer>(theModule))
return;
-
+
+ if (!CreatePrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
+ return;
+
theModule->application()->putInfo(QObject::tr("INF_DONE"));
-
- 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)
+ CreatePrs3d(VisuGUI* theModule)
{
- if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
+ 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);
+ if (aType == VVTK_Viewer::Type())
+ CreatePrs3d<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ else
+ CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule);
}
}
-
}
#endif