// File : VisuGUI_Module.h
// Author :
// Module : VISU
-// $Header$
#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,
+ SVTK_ViewWindow* theViewWindow)
{
- 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) {
+ 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"));
+ }
+ if (theViewWindow) {
+ theViewWindow->getRenderer()->ResetCameraClippingRange();
+ theViewWindow->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,
+ Handle(SALOME_InteractiveObject)& theIO,
+ VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow = NULL)
+ {
+ 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);
+ }
+ }
//---------------------------------------------------------------
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)
{
- using namespace VISU;
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();
+
+ // 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,
dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
aDlg,
true ); // in creation mode
+ UpdateObjBrowser(theModule,true,theTimeStamp);
QApplication::restoreOverrideCursor();
delete aDlg;
} else {
}
}
}
- PublishInView(theModule,aPrs3d);
+
+ // 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 TDlg, int IsDlgModal>
+ template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
+ inline
void
- CreatePrs3d(SalomeApp_Module* theModule)
+ CreatePrs3d(VisuGUI* theModule)
{
- 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))
return;
-
- if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
+
+ // 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"));
- theModule->updateObjBrowser();
- UpdateObjBrowser(theModule);
-
- if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
- aView->onFitAll();
}
+ template<class TPrs3d_i, class TDlg, int IsDlgModal>
+ inline
+ void
+ CreatePrs3d(VisuGUI* theModule)
+ {
+ if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()) {
+ QString aType = aViewManager->getType();
+ if (aType == VVTK_Viewer::Type())
+ CreatePrs3d<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ else
+ CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ }
+ }
}
#endif