#include "VISU_Prs3d_i.hh"
#include "VISU_Result_i.hh"
+#include "VISU_PipeLine.hxx"
+
#include "SalomeApp_SelectionMgr.h"
#include "SVTK_ViewWindow.h"
#include "SUIT_Session.h"
#include "SUIT_Desktop.h"
+#include "SUIT_MessageBox.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_OverrideCursor.h"
onSelectionChanged();
// signals and slots connections :
- connect(ComboBoxPlanes, SIGNAL(activated(int)), this, SLOT(onSelectPlane(int)));
- connect(buttonNew, SIGNAL(clicked()), this, SLOT(ClickOnNew()));
- connect(buttonDelete, SIGNAL(clicked()), this, SLOT(ClickOnDelete()));
- connect(ComboBoxOrientation, SIGNAL(activated(int)), this, SLOT(onSelectOrientation(int)));
- connect(SpinBoxDistance, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
- connect(SpinBoxRot1, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
- connect(SpinBoxRot2, SIGNAL(valueChanged(double)), this, SLOT(SetCurrentPlaneParam()));
- connect(ButtonGroupIJKAxis, SIGNAL(clicked(int)), this, SLOT(onIJKAxisChanged(int)));
- connect(SpinBoxIJKIndex, SIGNAL(valueChanged(int)), this, SLOT(SetCurrentPlaneIJKParam()));
- connect(CheckBoxIJKPlaneReverse, SIGNAL(toggled(bool)), this, SLOT(SetCurrentPlaneIJKParam()));
- connect(TabPane, SIGNAL(currentChanged (QWidget*)), this, SLOT(onTabChanged(QWidget*)));
-
- connect(PreviewCheckBox, SIGNAL(toggled(bool)), this, SLOT(OnPreviewToggle(bool)));
+ connect(ComboBoxPlanes , SIGNAL(activated(int)) , this, SLOT(onSelectPlane(int)));
+ connect(buttonNew , SIGNAL(clicked()) , this, SLOT(ClickOnNew()));
+ connect(buttonDelete , SIGNAL(clicked()) , this, SLOT(ClickOnDelete()));
+ connect(ComboBoxOrientation , SIGNAL(activated(int)) , this, SLOT(onSelectOrientation(int)));
+ connect(SpinBoxDistance , SIGNAL(valueChanged(double)) , this, SLOT(SetCurrentPlaneParam()));
+ connect(SpinBoxRot1 , SIGNAL(valueChanged(double)) , this, SLOT(SetCurrentPlaneParam()));
+ connect(SpinBoxRot2 , SIGNAL(valueChanged(double)) , this, SLOT(SetCurrentPlaneParam()));
+ connect(ButtonGroupIJKAxis , SIGNAL(clicked(int)) , this, SLOT(onIJKAxisChanged(int)));
+ connect(SpinBoxIJKIndex , SIGNAL(valueChanged(int)) , this, SLOT(SetCurrentPlaneIJKParam()));
+ connect(CheckBoxIJKPlaneReverse, SIGNAL(toggled(bool)) , this, SLOT(SetCurrentPlaneIJKParam()));
+ connect(TabPane , SIGNAL(currentChanged (QWidget*)), this, SLOT(onTabChanged(QWidget*)));
+
+ connect(PreviewCheckBox , SIGNAL(toggled(bool)), this, SLOT(OnPreviewToggle(bool)));
connect(AutoApplyCheckBox, SIGNAL(toggled(bool)), this, SLOT(ClickOnApply()));
- connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+
+ connect(buttonOk , SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply , SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
- connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
- connect(myVisuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnOk()));
+
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged()));
- /* to close dialog if study frame change */
- connect(myVisuGUI, SIGNAL(SignalStudyFrameChanged()), this, SLOT(ClickOnCancel()));
this->show();
}
if (SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myVisuGUI)) {
SUIT_OverrideCursor wc;
+ // Save clipping planes, currently applied to the presentation
+ // to enable restoring this state in case of failure.
+ // Refer to bugs IPAL8849, IPAL8850 for more information.
+ typedef vtkSmartPointer<vtkPlane> TPln;
+ typedef std::vector<TPln> TPlns;
+ bool isFailed = false;
+ TPlns anOldPlanes;
+ int iopl = 0, nbOldPlanes = myPrs3d->GetNumberOfClippingPlanes();
+ for (; iopl < nbOldPlanes; iopl++) {
+ anOldPlanes.push_back(myPrs3d->GetClippingPlane(iopl));
+ }
+
+ // Try to apply new clipping
myPrs3d->RemoveAllClippingPlanes();
VISU::TPlanes::iterator anIter = myPlanes.begin();
- for (;anIter != myPlanes.end();anIter++) {
+ for (; anIter != myPlanes.end(); anIter++) {
OrientedPlane* anOrientedPlane = OrientedPlane::New(aViewWindow);
anOrientedPlane->ShallowCopy(anIter->GetPointer());
- myPrs3d->AddClippingPlane(anOrientedPlane);
+ if (!myPrs3d->AddClippingPlane(anOrientedPlane)) {
+ isFailed = true;
+ }
anOrientedPlane->Delete();
}
+ // Check contents of the resulting (clipped) presentation data
+ if (!isFailed) {
+ VISU_PipeLine* aPL = myPrs3d->GetPL();
+ VISU_PipeLine::TMapper* aM = aPL->GetMapper();
+ vtkDataSet* aPrsData = aM->GetInput();
+ aPrsData->Update();
+ if (aPrsData->GetNumberOfCells() < 1) {
+ isFailed = true;
+ }
+ }
+
+ if (isFailed) {
+ // Restore previous clipping state because of failure.
+ myPrs3d->RemoveAllClippingPlanes();
+
+ TPlns::iterator anOldIter = anOldPlanes.begin();
+ for (; anOldIter != anOldPlanes.end(); anOldIter++) {
+ myPrs3d->AddClippingPlane(anOldIter->GetPointer());
+ }
+
+ SUIT_MessageBox::warn1(VISU::GetDesktop(myVisuGUI),
+ tr("WRN_VISU"),
+ tr("WRN_EMPTY_RESULTING_PRS"),
+ tr("BUT_OK") );
+ }
+
VISU::RenderViewWindow(aViewWindow);
}
}