From: vsv Date: Fri, 11 Jul 2008 14:35:44 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: TG_VISU2008_14_07_08~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3c37c9d193c86834c3fec65f41ae05560284c847;p=modules%2Fvisu.git *** empty log message *** --- diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 50a9a6bb..3d629cb5 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -81,7 +81,9 @@ dist_libVISU_la_SOURCES= \ VisuGUI_FieldFilter.cxx \ VisuGUI_ViewExtender.cxx \ VisuGUI_ClippingPlaneMgr.cxx \ - VisuGUI_SegmentationMgr.cxx + VisuGUI_SegmentationMgr.cxx \ + VisuGUI_ClippingPanel.cxx \ + VisuGUI_ClippingPlaneDlg.cxx MOC_FILES= \ VisuGUI_moc.cxx \ @@ -121,7 +123,10 @@ MOC_FILES= \ VisuGUI_InputPane_moc.cxx \ VisuGUI_ViewExtender_moc.cxx \ VisuGUI_ClippingPlaneMgr_moc.cxx \ - VisuGUI_SegmentationMgr_moc.cxx + VisuGUI_SegmentationMgr_moc.cxx \ + VisuGUI_ClippingPanel_moc.cxx \ + VisuGUI_ClippingPlaneDlg_moc.cxx + nodist_libVISU_la_SOURCES=$(MOC_FILES) diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 3f3c64a2..c09967b7 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -3560,4 +3560,98 @@ Please, refer to the documentation. Activate/Deactivate clipping planes + + VisuGUI_ClippingPanel + + TITLE + Clipping Planes + + + PRESENTATIONS_LBL + Presentations: + + + PLANES_LBL + Associated planes: + + + NEW_BTN + New... + + + EDIT_BTN + Edit... + + + DELETE_BTN + Delete + + + TIT_DELETE_PLANE + Delete clipping plane + + + MSG_DELETE_PLANE + Clipping plane %1 will be deleted. Continue? + + + CHK_SHOW_PLANES + Show planes preview + + + CHK_ACTIVATE_PLANES + Deactivate planes + + + CHK_AUTO_APPLY + Auto apply + + + + VisuGUI_ClippingPlaneDlg + + TITLE + Clipping plane edit + + + LBL_NAME + Name of the plane + + + BYVECTOR_TITLE + Normal vector + + + BYPLANE_TITLE + Main plane + + + CHK_AUTOAPPLY + Auto apply + + + CHK_SHOW_PREVIEW + Show preview + + + ORIGIN_TITLE + Origin + + + DIRECTION_TITLE + Direction + + + LBL_ORIENTATION + Orientation + + + LBL_DISTANCE + Distance + + + LBL_ROTATION + Rotation around %1 + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 6757875b..03adac48 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -113,6 +113,7 @@ #include "VisuGUI_Displayer.h" #include "VisuGUI_BuildProgressDlg.h" #include "VisuGUI_TransparencyDlg.h" +#include "VisuGUI_ClippingPanel.h" #include "VISU_ScalarMap_i.hh" #include "VisuGUI_ScalarBarDlg.h" @@ -629,7 +630,8 @@ VisuGUI SVTK_ViewWindow* aViewWindow = GetViewWindow(this); // create mesh presentation and display it in aViewWindow - CreateMesh(this, anIO, aViewWindow); + VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow); + emit presentationCreated(aPrs); } void @@ -654,7 +656,8 @@ VisuGUI return; // create mesh presentation and display it in aViewWindow - CreateMesh(this, anIO, aViewWindow); + VISU::Mesh_i* aPrs = CreateMesh(this, anIO, aViewWindow); + emit presentationCreated(aPrs); } } @@ -662,7 +665,8 @@ void VisuGUI ::OnCreateScalarMap() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } @@ -671,56 +675,64 @@ VisuGUI ::OnCreateDeformedShape() { // CreatePrs3d(this); - VisuGUI_DeformedShapeDlg::CreatePrs3d(this); + Prs3d_i* aPrs = VisuGUI_DeformedShapeDlg::CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreateScalarMapOnDeformedShape() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreateVectors() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreateIsoSurfaces() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreateCutPlanes() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreateCutLines() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreateStreamLines() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void VisuGUI ::OnCreatePlot3D() { - CreatePrs3d(this); + Prs3d_i* aPrs = CreatePrs3d(this); + emit presentationCreated(aPrs); } void @@ -1606,6 +1618,8 @@ VisuGUI break; } default: { + if(VISU::Prs3d_i* aPrs = dynamic_cast(aBase)) + aPrs->SetName((const char*)Name.toLatin1(), true); }} } } @@ -2759,6 +2773,7 @@ void VisuGUI::createPanels() { myPanels.insert( SelectionPanelId, new VisuGUI_SelectionPanel( this ) ); myPanels.insert( FeatureEdgesPanelId, new VisuGUI_FeatureEdgesPanel( this ) ); + myPanels.insert( ClippingPlanesPanelId, new VisuGUI_ClippingPanel( this ) ); QMap< PanelId, VisuGUI_Panel* >::iterator it = myPanels.begin(), itEnd = myPanels.end(); for( ; it != itEnd; ++it ) @@ -3665,6 +3680,7 @@ void VisuGUI::OnPlot3dFromCutPlane() AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos); } + emit presentationCreated(aPrs3d); } } application()->putInfo(QObject::tr("INF_DONE")); diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 1ce6b8d1..b7ba9a78 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -57,7 +57,8 @@ class VisuGUI: public SalomeApp_Module public: enum PanelId { SelectionPanelId = 0, - FeatureEdgesPanelId }; + FeatureEdgesPanelId, + ClippingPlanesPanelId }; public: VisuGUI(); @@ -88,6 +89,7 @@ public: signals: void moduleDeactivated(); void moduleActivated(); + void presentationCreated(VISU::Prs3d_i* thePrs); public slots: virtual bool deactivateModule( SUIT_Study* ); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 72c49e65..8c310db8 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -135,5 +135,6 @@ #define VISU_SLIDER_PANEL 4200 #define VISU_SWEEP_PANEL 4300 +#define VISU_GLOBALCLIPPING 4301 #endif diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.cxx b/src/VISUGUI/VisuGUI_ClippingPanel.cxx new file mode 100644 index 00000000..b08f4567 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingPanel.cxx @@ -0,0 +1,477 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + + +#include "VisuGUI_ClippingPanel.h" +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" +#include "VisuGUI_ClippingPlaneDlg.h" +#include "VisuGUI_ViewTools.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule) + : VisuGUI_Panel(tr("TITLE"), theModule, VISU::GetDesktop(theModule), ApplyBtn | HelpBtn ), + myModule(theModule), + myPlaneDlg(0), + myViewWindow(0) +{ + QVBoxLayout* aMainLayout = new QVBoxLayout(mainFrame()); + + // List of presentations + aMainLayout->addWidget(new QLabel(tr("PRESENTATIONS_LBL"), mainFrame())); + myPrsList = new QListWidget(mainFrame()); + myPrsList->setSelectionMode(QAbstractItemView::SingleSelection); + aMainLayout->addWidget(myPrsList); + + // List of planes + aMainLayout->addWidget(new QLabel(tr("PLANES_LBL"), mainFrame())); + myPlanesList = new QListWidget(mainFrame()); + myPlanesList->setSelectionMode(QAbstractItemView::SingleSelection); + aMainLayout->addWidget(myPlanesList); + + // Management buttons + QWidget* aButtonsWgt = new QWidget(mainFrame()); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtonsWgt); + aMainLayout->addWidget(aButtonsWgt); + + QToolButton* aNewBtn = new QToolButton(aButtonsWgt); + aNewBtn->setToolButtonStyle(Qt::ToolButtonTextOnly); + aNewBtn->setText(tr("NEW_BTN")); + connect(aNewBtn, SIGNAL(clicked(bool)), this, SLOT(onNew())); + aBtnLayout->addWidget(aNewBtn); + + QToolButton* aEditBtn = new QToolButton(aButtonsWgt); + aEditBtn->setToolButtonStyle(Qt::ToolButtonTextOnly); + aEditBtn->setText(tr("EDIT_BTN")); + connect(aEditBtn, SIGNAL(clicked(bool)), this, SLOT(onEdit())); + aBtnLayout->addWidget(aEditBtn); + + QToolButton* aDeleteBtn = new QToolButton(aButtonsWgt); + aDeleteBtn->setToolButtonStyle(Qt::ToolButtonTextOnly); + aDeleteBtn->setText(tr("DELETE_BTN")); + connect(aDeleteBtn, SIGNAL(clicked(bool)), this, SLOT(onPlaneDelete())); + aBtnLayout->addWidget(aDeleteBtn); + + myShowPlanes = new QCheckBox(tr("CHK_SHOW_PLANES"), mainFrame()); + connect(myShowPlanes, SIGNAL( toggled(bool) ), this, SLOT( setPlanesVisible(bool) )); + aMainLayout->addWidget(myShowPlanes); + + myNonActivePlanes = new QCheckBox(tr("CHK_ACTIVATE_PLANES"), mainFrame()); + connect(myNonActivePlanes, SIGNAL(toggled(bool)), this, SLOT(setPlanesNonActive(bool))); + aMainLayout->addWidget(myNonActivePlanes); + + myAutoApply = new QCheckBox(tr("CHK_AUTO_APPLY"), mainFrame()); + aMainLayout->addWidget(myAutoApply); + + + fillPrsList(); + fillPlanesList(); + + connect(myModule, SIGNAL(presentationCreated(VISU::Prs3d_i*)), + this, SLOT(onPresentationCreate(VISU::Prs3d_i*))); + + SUIT_Desktop* aDesktop = VISU::GetDesktop(myModule); + connect(aDesktop, SIGNAL(windowActivated(SUIT_ViewWindow*)), this, SLOT(onWindowActivated(SUIT_ViewWindow*))); +} + + +//************************************************************************* +VisuGUI_ClippingPanel::~VisuGUI_ClippingPanel() +{ +} + + +//************************************************************************* +void VisuGUI_ClippingPanel::fillPrsList() +{ + myPrsList->clear(); + _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule)); + _PTR(SComponent) aVisuSO = aStudy->FindComponent("VISU"); + if (!aVisuSO) { + return; + } + myPresentations = getPrsList(aStudy, aVisuSO); + QStringList aNames; + for (int i = 0; i < myPresentations.size(); i++) { + aNames.append(myPresentations.at(i)->GetName().c_str()); + } + myPrsList->addItems(aNames); +} + +//************************************************************************* +QList VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy, + _PTR(SObject) theObject) +{ + QList aList; + _PTR(ChildIterator) aIter = theStudy->NewChildIterator(theObject); + for (aIter->InitEx(true); aIter->More(); aIter->Next()) { + _PTR(SObject) aSObject = aIter->Value(); + std::vector aSTLList = VISU::GetPrs3dList(myModule, aSObject); + for (int i = 0; i < aSTLList.size(); i++) { + VISU::Prs3d_i* aPrs = aSTLList[i]; + if (!aList.contains(aPrs)) + aList.append(aPrs); + } + if (aList.size() == 0) { + QList aSubList = getPrsList(theStudy, aSObject); + for (int i = 0; i < aSubList.size(); i++) { + VISU::Prs3d_i* aPrs = aSubList[i]; + if (!aList.contains(aPrs)) + aList.append(aSubList[i]); + } + } + } + return aList; +} + +//************************************************************************* +void VisuGUI_ClippingPanel::fillPlanesList() +{ + myPlanesList->clear(); + myPlanes.clear(); + _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule)); + _PTR(SObject) aFolder; + if (VISU::getClippingPlanesFolder(aStudy, aFolder)) { + _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aFolder); + int i; + for (aIter->InitEx(true), i = 0; aIter->More(); aIter->Next(), i++) { + _PTR(SObject) aSObject = aIter->Value(); + PlaneDef aNewPlane = createEmptyPlane(); + updatePlane(aSObject, aNewPlane); + + QListWidgetItem* aItem = new QListWidgetItem(aNewPlane.name, myPlanesList); + + if (aNewPlane.isAuto) { + aItem->setFlags(0); + aItem->setCheckState(Qt::Checked); + } else { + aItem->setCheckState(Qt::Unchecked); + } + myPlanesList->addItem(aItem); + myPlanes.append(aNewPlane); + } + } +} + +//************************************************************************* +void VisuGUI_ClippingPanel::showEvent(QShowEvent* event) +{ + fillPrsList(); + VisuGUI_Panel::showEvent(event); +} + +//************************************************************************* +// void VisuGUI_ClippingPanel::hideEvent(QHideEvent* event) +// { +// disconnect(myModule, SIGNAL(presentationCreated()), this, SLOT(onPresentationCreate())); +// VisuGUI_Panel::hideEvent(event); +// } + +//************************************************************************* +void VisuGUI_ClippingPanel::onPresentationCreate(VISU::Prs3d_i* thePrs) +{ + myPrsList->addItem(thePrs->GetName().c_str()); + myPresentations.append(thePrs); + for (int i = 0; i < myPlanes.size(); i++) { + const PlaneDef& aPlane = myPlanes.at(i); + if (aPlane.isAuto) + thePrs->AddClippingPlane(aPlane.plane); + } +} + +//************************************************************************* +PlaneDef VisuGUI_ClippingPanel::createEmptyPlane() +{ + PlaneDef aPlane; + aPlane.name = QString("Plane"); + aPlane.plane = CutPlaneFunction::New(); + aPlane.plane->Delete(); + aPlane.plane->SetOrigin(0.,0.,0.); + aPlane.plane->SetNormal(0.,0.,1.); + aPlane.isAuto = true; + return aPlane; +} + +//************************************************************************* +void VisuGUI_ClippingPanel::updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane) +{ + thePlane.name = QString(theObject->GetName().c_str()); + thePlane.plane->setPlaneObject(theObject); + + _PTR(GenericAttribute) anAttr; + if (theObject->FindAttribute(anAttr, "AttributeSequenceOfReal")) { + _PTR(AttributeSequenceOfReal) aArray(anAttr); + thePlane.plane->SetOrigin(aArray->Value(1), aArray->Value(2), aArray->Value(3)); + thePlane.plane->SetNormal(aArray->Value(4), aArray->Value(5), aArray->Value(6)); + } + if (theObject->FindAttribute(anAttr, "AttributeInteger")) { + _PTR(AttributeInteger) aFlag(anAttr); + thePlane.isAuto = (aFlag->Value() == 1); + } +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onNewPlane() +{ + disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane())); + disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj(); + + PlaneDef aNewPlane = createEmptyPlane(); + updatePlane(aPlaneSObj, aNewPlane); + + QListWidgetItem* aItem = new QListWidgetItem(aNewPlane.name, myPlanesList); + if (aNewPlane.isAuto) { + aItem->setFlags(0); + aItem->setCheckState(Qt::Checked); + for (int i = 0; i < myPresentations.size(); i++) { + myPresentations.at(i)->AddClippingPlane(aNewPlane.plane); + } + } else { + aItem->setCheckState(Qt::Unchecked); + } + myPlanesList->addItem(aItem); + myPlanes.append(aNewPlane); + + delete myPlaneDlg; + myPlaneDlg = 0; + + setPlanesVisible(myShowPlanes->checkState() == Qt::Checked); + + if (myViewWindow) + myViewWindow->Repaint(); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onPlaneEdited() +{ + disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane())); + disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj(); + + PlaneDef aPlane = myPlanes.at(myEditingPlanePos); + updatePlane(aPlaneSObj, aPlane); + + delete myPlaneDlg; + myPlaneDlg = 0; + + setPlanesVisible(myShowPlanes->checkState() == Qt::Checked); + + if (myViewWindow) + myViewWindow->Repaint(); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onEdit() +{ + if (!isVISUDataReady()) return; + if (myPlaneDlg) return; + + int aRow = myPlanesList->currentRow(); + if (aRow < 0) return; + + const PlaneDef& aPlane = myPlanes.at(aRow); + + myPlaneDlg = new VisuGUI_ClippingPlaneDlg(myModule); + myPlaneDlg->setPlaneObj(aPlane.plane->getPlaneObject()); + connect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onPlaneEdited())); + connect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + myEditingPlanePos = aRow; + myPlaneDlg->show(); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onNew() +{ + if (!isVISUDataReady()) return; + + if (myPlaneDlg) return; + + myPlaneDlg = new VisuGUI_ClippingPlaneDlg(myModule); + connect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane())); + connect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + myPlaneDlg->show(); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onPlaneDelete() +{ + if (!isVISUDataReady()) return; + if (myPlaneDlg) return; + + _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) ); + + + int aRow = myPlanesList->currentRow(); + if (aRow < 0) return; + + const PlaneDef& aPlane = myPlanes.at(aRow); + QMessageBox::StandardButton aRes = QMessageBox::warning(VISU::GetDesktop(myModule), + tr("TIT_DELETE_PLANE"), + tr("MSG_DELETE_PLANE").arg(aPlane.name), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); + if (aRes == QMessageBox::Yes) { + short aTag1 = aPlane.plane->getPlaneObject()->Tag(); + for (int i = 0; i < myPresentations.size(); i++) { + VISU::Prs3d_i* aPrs = myPresentations.at(i); + for (int j = aPrs->GetNumberOfClippingPlanes()-1; j > -1; j--) { + CutPlaneFunction* aPln = dynamic_cast(aPrs->GetClippingPlane(j)); + if (aPln) { + short aTag2 = aPln->getPlaneObject()->Tag(); + if (aTag1 == aTag2) { + aPrs->RemoveClippingPlane(j); + } + } + } + } + + _PTR(SObject) aSObj = aPlane.plane->getPlaneObject(); + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + aBuilder->RemoveObject(aSObj); + + myPlanesList->takeItem(aRow); + myPlanes.removeAt(aRow); + + VISU::UpdateObjBrowser(myModule); + + if (myViewWindow) + myViewWindow->Repaint(); + } +} + +//************************************************************************* +bool VisuGUI_ClippingPanel::isVISUDataReady() +{ + _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) ); + + _PTR(SComponent) aVisuSO = aStudy->FindComponent("VISU"); + if (!aVisuSO) return false; + + if(aStudy->GetProperties()->IsLocked()) return false; + return true; +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onApply() +{ + +} + +//************************************************************************* +void VisuGUI_ClippingPanel::setPlanesNonActive(bool theState) +{ + PlaneDef aPlane; + for (int i = 0; i < myPlanes.size(); i++) { + aPlane = myPlanes.at(i); + aPlane.plane->setActive(!theState); + } + if (myViewWindow) + myViewWindow->Repaint(); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::setPlanesVisible(bool theVisible) +{ + if (!myViewWindow) return; + + if (theVisible) { + // Hide previous + setPlanesVisible(false); + + double aBounds[6]; + ComputeVisiblePropBounds(myViewWindow->getRenderer(), aBounds); + for (int i = 0; i < myPlanes.size(); i++) { + PreviewPlane* aPreview = new PreviewPlane(myViewWindow, myPlanes.at(i), aBounds); + aPreview->setVisible(true); + myPreview.append(aPreview); + } + } else { + PreviewPlane* aPreview; + while (myPreview.size() > 0) { + aPreview = myPreview.last(); + myPreview.removeLast(); + delete aPreview; + } + } + myViewWindow->Repaint(); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onCancelDialog() +{ + disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane())); + disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + + delete myPlaneDlg; + myPlaneDlg = 0; +} + + +//************************************************************************* +void VisuGUI_ClippingPanel::onWindowActivated(SUIT_ViewWindow* theWindow) +{ + myViewWindow = dynamic_cast(theWindow); + printf("#### New window activated\n"); +} + + +//************************************************************************* +void VisuGUI_ClippingPanel::onHelp() +{ + QString aHelpFileName = "clipping_planes_page.html"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName), + QObject::tr("BUT_OK")); + } +} diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.h b/src/VISUGUI/VisuGUI_ClippingPanel.h new file mode 100644 index 00000000..79993422 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingPanel.h @@ -0,0 +1,98 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef DIALOGBOX_CLIPPINGPANEL_H +#define DIALOGBOX_CLIPPINGPANEL_H + + +class VisuGUI; +class QListWidget; +class VisuGUI_ClippingPlaneDlg; +class QCheckBox; +class SVTK_ViewWindow; +class SUIT_ViewWindow; + +#include "VISU_Prs3d_i.hh" +#include "VisuGUI_Panel.h" +#include + +#include + +#include + +class VisuGUI_ClippingPanel: public VisuGUI_Panel +{ + Q_OBJECT +public: + VisuGUI_ClippingPanel(VisuGUI* theModule); + ~VisuGUI_ClippingPanel(); + +protected: + virtual void showEvent(QShowEvent* event); + //virtual void hideEvent(QHideEvent* event); + +public slots: + void onPresentationCreate(VISU::Prs3d_i* thePrs); + +protected slots: + virtual void onApply(); + virtual void onHelp(); + +private slots: + void onNew(); + void onNewPlane(); + void onEdit(); + void onPlaneEdited(); + void onPlaneDelete(); + void onCancelDialog(); + void setPlanesNonActive(bool theState); + void setPlanesVisible(bool theVisible); + void onWindowActivated(SUIT_ViewWindow* theWindow); + + private: + void fillPrsList(); + void fillPlanesList(); + + void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane); + PlaneDef createEmptyPlane(); + + bool isVISUDataReady(); + + QList getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject); + + VisuGUI* myModule; + + QListWidget* myPrsList; + QListWidget* myPlanesList; + + QCheckBox* myShowPlanes; + QCheckBox* myNonActivePlanes; + QCheckBox* myAutoApply; + + QListOfPlanes myPlanes; + QList myPresentations; + ListOfPreview myPreview; + + VisuGUI_ClippingPlaneDlg* myPlaneDlg; + int myEditingPlanePos; + SVTK_ViewWindow* myViewWindow; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx new file mode 100644 index 00000000..219b9ad1 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx @@ -0,0 +1,362 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "VisuGUI_ClippingPlaneDlg.h" +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#define SIZEFACTOR 1.5 + + + + +//**************************************************************** +//**************************************************************** +//**************************************************************** +VisuGUI_ClippingPlaneDlg::VisuGUI_ClippingPlaneDlg(VisuGUI* theModule) + : QDialog(VISU::GetDesktop(theModule), Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myModule(theModule), + myCallback( vtkCallbackCommand::New() ), + myPreviewWidget(0), + myViewWindow(0) +{ + myViewWindow = VISU::GetActiveViewWindow(myModule); + ComputeVisiblePropBounds(myViewWindow->getRenderer(), myBounds); + + setWindowTitle(tr("TITLE")); + setSizeGripEnabled(true); + setModal(false); + + myCallback->SetClientData(this); + myCallback->SetCallback(VisuGUI_ClippingPlaneDlg::ProcessEvents); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this); + + QWidget* aPlanesWgt = new QWidget(this); + aMainLayout->addWidget(aPlanesWgt); + QVBoxLayout* aFrameLayout = new QVBoxLayout(aPlanesWgt); + + QWidget* aNameBox = new QWidget(aPlanesWgt); + aFrameLayout->addWidget(aNameBox); + QHBoxLayout* aNameLayout = new QHBoxLayout(aNameBox); + + aNameLayout->addWidget(new QLabel(tr("LBL_NAME"), aPlanesWgt)); + myNameEdt = new QLineEdit(); + + _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule)); + _PTR(SObject) aFolderSO; + if (VISU::getClippingPlanesFolder(aStudy, aFolderSO)) { + _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aFolderSO); + int i = 1; + for (; aIter->More(); aIter->Next()) i++; + + myNameEdt->setText(QString("Plane %1").arg(i)); + } + aNameLayout->addWidget(myNameEdt); + + QGroupBox* aOriginGroup = new QGroupBox( tr( "ORIGIN_TITLE" ), aPlanesWgt ); + aFrameLayout->addWidget(aOriginGroup); + QHBoxLayout* aOriginLayout = new QHBoxLayout(aOriginGroup); + + aOriginLayout->addWidget( new QLabel("X", aOriginGroup) ); + myXOrigin = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aOriginGroup ); + myXOrigin->setValue( 0.0 ); + connect(myXOrigin, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged())); + aOriginLayout->addWidget( myXOrigin ); + + aOriginLayout->addWidget( new QLabel("Y", aOriginGroup) ); + myYOrigin = new QtxDoubleSpinBox( -1000.0, 1000, 0.1, aOriginGroup ); + myYOrigin->setValue( 0.0 ); + connect(myYOrigin, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged())); + aOriginLayout->addWidget( myYOrigin ); + + aOriginLayout->addWidget( new QLabel("Z", aOriginGroup) ); + myZOrigin = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aOriginGroup ); + myZOrigin->setValue( 0.0 ); + connect(myZOrigin, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged())); + aOriginLayout->addWidget( myZOrigin ); + + QGroupBox* aDirGroup = new QGroupBox( tr( "DIRECTION_TITLE" ), aPlanesWgt ); + aFrameLayout->addWidget(aDirGroup); + QHBoxLayout* aDirLayout = new QHBoxLayout(aDirGroup); + + aDirLayout->addWidget( new QLabel("dX", aDirGroup) ); + myXDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup ); + myXDir->setValue( 0.0 ); + connect(myXDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged())); + aDirLayout->addWidget( myXDir ); + + aDirLayout->addWidget( new QLabel("dY", aDirGroup) ); + myYDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup ); + myYDir->setValue( 0.0 ); + connect(myYDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged())); + aDirLayout->addWidget( myYDir ); + + aDirLayout->addWidget( new QLabel("dZ", aDirGroup) ); + myZDir = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, aDirGroup ); + myZDir->setValue( 1.0 ); + connect(myZDir, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged())); + aDirLayout->addWidget( myZDir ); + + myAutoApply = new QCheckBox(tr("CHK_AUTOAPPLY"), aPlanesWgt); + myAutoApply->setCheckState(Qt::Checked); + aFrameLayout->addWidget(myAutoApply); + + // Dialog buttons + QGroupBox* aGroupButtons = new QGroupBox (this); + aMainLayout->addWidget(aGroupButtons); + + QSizePolicy aSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed ); + QHBoxLayout* aButtonsLayout = new QHBoxLayout(aGroupButtons); + + QPushButton* aBtnOk = new QPushButton(tr("BUT_OK"), aGroupButtons); + aButtonsLayout->addWidget(aBtnOk); + + aButtonsLayout->addStretch(); + + QPushButton* aBtnClose = new QPushButton(tr("BUT_CANCEL"), aGroupButtons); + aButtonsLayout->addWidget(aBtnClose); + + QPushButton* aBtnHelp = new QPushButton(tr("BUT_HELP"), aGroupButtons); + aButtonsLayout->addWidget(aBtnHelp); + + connect(aBtnOk , SIGNAL(clicked()), this, SLOT(accept())); + connect(aBtnClose, SIGNAL(clicked()), this, SLOT(reject())); + connect(aBtnHelp , SIGNAL(clicked()), this, SLOT(onHelp())); + + + myPreviewWidget = createPreviewWidget(); + myViewWindow->Repaint(); +} + +VisuGUI_ClippingPlaneDlg::~VisuGUI_ClippingPlaneDlg() +{ + if (myPreviewWidget) { + myPreviewWidget->Off(); + myPreviewWidget->Delete(); + } + myPreviewWidget = 0; + myCallback->Delete(); +} + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* vtkNotUsed(theCallData)) +{ + vtkImplicitPlaneWidget* aWidget = vtkImplicitPlaneWidget::SafeDownCast(theObject); + if (aWidget == NULL) return; + if (theClientData == NULL) return; + + VisuGUI_ClippingPlaneDlg* aDlg = (VisuGUI_ClippingPlaneDlg*) theClientData; + + double aOrigin[3]; + double aDir[3]; + + switch(theEvent){ + case vtkCommand::InteractionEvent: + aWidget->GetOrigin(aOrigin); + aWidget->GetNormal(aDir); + + aDlg->setOrigin(aOrigin); + aDlg->setDirection(aDir); + + break; + } +} + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::setOrigin(double theVal[3]) +{ + myXOrigin->setValue(theVal[0]); + myYOrigin->setValue(theVal[1]); + myZOrigin->setValue(theVal[2]); +} + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::setDirection(double theVal[3]) +{ + myXDir->setValue(theVal[0]); + myYDir->setValue(theVal[1]); + myZDir->setValue(theVal[2]); +} + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::onValueChanged() +{ + if (!myPreviewWidget) return; + double aOrigin[3]; + double aDir[3]; + aOrigin[0] = myXOrigin->value(); + aOrigin[1] = myYOrigin->value(); + aOrigin[2] = myZOrigin->value(); + + aDir[0] = myXDir->value(); + aDir[1] = myYDir->value(); + aDir[2] = myZDir->value(); + + myPreviewWidget->SetOrigin(aOrigin); + myPreviewWidget->SetNormal(aDir); +} + +//**************************************************************** +vtkImplicitPlaneWidget* VisuGUI_ClippingPlaneDlg::createPreviewWidget() +{ + vtkImplicitPlaneWidget* aPlaneWgt = vtkImplicitPlaneWidget::New(); + aPlaneWgt->SetInteractor(myViewWindow->getInteractor()); + aPlaneWgt->SetPlaceFactor(SIZEFACTOR); + aPlaneWgt->ScaleEnabledOff(); + aPlaneWgt->PlaceWidget(myBounds[0],myBounds[1],myBounds[2],myBounds[3],myBounds[4],myBounds[5]); + aPlaneWgt->SetOrigin(0,0,0); + aPlaneWgt->SetNormal(0,0,1); + aPlaneWgt->On(); + + //aPlaneWgt->OutlineTranslationOff(); + //aPlaneWgt->ScaleEnabledOn(); + aPlaneWgt->AddObserver(vtkCommand::InteractionEvent, + myCallback.GetPointer(), + 0.); + return aPlaneWgt; +} + + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::setPlaneObj(_PTR(SObject) thePlaneObj) +{ + myPlaneObj = thePlaneObj; + + myNameEdt->setText(QString(myPlaneObj->GetName().c_str())); + + _PTR(GenericAttribute) anAttr; + if (myPlaneObj->FindAttribute(anAttr, "AttributeSequenceOfReal")) { + _PTR(AttributeSequenceOfReal) aArray(anAttr); + myXOrigin->setValue(aArray->Value(1)); + myYOrigin->setValue(aArray->Value(2)); + myZOrigin->setValue(aArray->Value(3)); + + myPreviewWidget->SetOrigin(aArray->Value(1), aArray->Value(2), aArray->Value(3)); + + myXDir->setValue(aArray->Value(4)); + myYDir->setValue(aArray->Value(5)); + myZDir->setValue(aArray->Value(6)); + + myPreviewWidget->SetNormal(aArray->Value(4), aArray->Value(5), aArray->Value(6)); + } + if (myPlaneObj->FindAttribute(anAttr, "AttributeInteger")) { + _PTR(AttributeInteger) aFlag(anAttr); + myAutoApply->setCheckState((aFlag->Value() == 1)? Qt::Checked : Qt::Unchecked); + } + + myViewWindow->Repaint(); +} + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::accept() +{ + _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) ); + if(!aStudy->GetProperties()->IsLocked()) { + _PTR(SObject) aFolder; + if (VISU::getClippingPlanesFolder(aStudy, aFolder)) { + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + if (myPlaneObj == 0) { // Create a New plane + myPlaneObj = aBuilder->NewObject(aFolder); + } + // Save Name + _PTR(GenericAttribute) anAttr; + anAttr = aBuilder->FindOrCreateAttribute(myPlaneObj,"AttributeName"); + _PTR(AttributeName) aName(anAttr); + aName->SetValue(myNameEdt->text().toStdString()); + + //Save Parameters + double aParams[6]; + aParams[0] = myXOrigin->value(); + aParams[1] = myYOrigin->value(); + aParams[2] = myZOrigin->value(); + aParams[3] = myXDir->value(); + aParams[4] = myYDir->value(); + aParams[5] = myZDir->value(); + + anAttr = aBuilder->FindOrCreateAttribute(myPlaneObj,"AttributeSequenceOfReal"); + _PTR(AttributeSequenceOfReal) aArray(anAttr); + if (aArray->Length() == 6) { + for (int i = 0; i < 6; i++) + aArray->ChangeValue(i+1, aParams[i]); + } else { + for (int i = 0; i < 6; i++) + aArray->Add(aParams[i]); + } + // Save Bool Flag + anAttr = aBuilder->FindOrCreateAttribute(myPlaneObj,"AttributeInteger"); + _PTR(AttributeInteger) aFlag(anAttr); + aFlag->SetValue((myAutoApply->checkState() == Qt::Checked)? 1 : 0); + + VISU::UpdateObjBrowser(myModule); + } + } + QDialog::accept(); +} + + +//**************************************************************** +void VisuGUI_ClippingPlaneDlg::onHelp() +{ + QString aHelpFileName = "clipping_planes_page.html"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName), + QObject::tr("BUT_OK")); + } +} + diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneDlg.h b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.h new file mode 100644 index 00000000..35b917f8 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.h @@ -0,0 +1,90 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef DIALOGBOX_CLIPPINGPLANEDLG_H +#define DIALOGBOX_CLIPPINGPLANEDLG_H + +class VisuGUI; +class QLineEdit; +class QCheckBox; + +class QtxDoubleSpinBox; +class vtkImplicitPlaneWidget; +class vtkCallbackCommand; +class vtkObject; +class SVTK_ViewWindow; + +#include +#include +#include +#include + + +class VisuGUI_ClippingPlaneDlg: public QDialog +{ + Q_OBJECT +public: + VisuGUI_ClippingPlaneDlg(VisuGUI* theModule); + ~VisuGUI_ClippingPlaneDlg(); + + void setOrigin(double theVal[3]); + void setDirection(double theVal[3]); + + void setPlaneObj(_PTR(SObject) thePlaneObj); + _PTR(SObject) getPlaneObj() const { return myPlaneObj; } + +protected slots: + virtual void accept(); + +private slots: + void onHelp(); + void onValueChanged(); + + private: + void setEmptyPlane(PlaneDef& thePlane) const; + vtkImplicitPlaneWidget* createPreviewWidget(); + + + static void ProcessEvents(vtkObject* theObject, unsigned long theEvent, + void* theClientData, void* theCallData); + + VisuGUI* myModule; + SVTK_ViewWindow* myViewWindow; + + QLineEdit* myNameEdt; + + QtxDoubleSpinBox* myXOrigin; + QtxDoubleSpinBox* myYOrigin; + QtxDoubleSpinBox* myZOrigin; + + QtxDoubleSpinBox* myXDir; + QtxDoubleSpinBox* myYDir; + QtxDoubleSpinBox* myZDir; + + QCheckBox* myAutoApply; + + vtkImplicitPlaneWidget* myPreviewWidget; + vtkSmartPointer myCallback; + + double myBounds[6]; + _PTR(SObject) myPlaneObj; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index e9b26850..16f54967 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -242,8 +242,9 @@ bool VisuGUI_DeformedShapeDlg::onApply() // Create and Edit //////////////////////////////////////////////////////////////////////////////// -void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) +VISU::Prs3d_i* VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) { + VISU::DeformedShape_i* aPrs3d = NULL; _PTR(SObject) aTimeStamp; Handle(SALOME_InteractiveObject) anIO; VISU::ColoredPrs3d_i::EPublishInStudyMode aPublishInStudyMode; @@ -260,10 +261,10 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) QString aFieldName = aRestoringMap["myFieldName"]; QString aTimeStampId = aRestoringMap["myTimeStampId"]; - typedef VISU::DeformedShape_i TPrs3d_i; + //typedef VISU::DeformedShape_i TPrs3d_i; - TPrs3d_i* aPrs3d = - VISU::CreatePrs3dFromFactory(theModule, + aPrs3d = + VISU::CreatePrs3dFromFactory(theModule, aTimeStamp, aMeshName.toLatin1().data(), (VISU::Entity)anEntity.toInt(), @@ -277,9 +278,10 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) VisuGUI_DialogRunner r(aDlg); int dlgResult = r.run( false ); - if ( dlgResult == 0 ) + if ( dlgResult == 0 ) { aPrs3d->RemoveFromStudy(); - else { + aPrs3d = NULL; + } else { aDlg->storeToPrsObject( aPrs3d ); SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(); PublishInView(theModule, aPrs3d, aViewWindow); @@ -292,6 +294,7 @@ void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) delete aDlg; } } + return aPrs3d; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h index 099fc006..19528e26 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h @@ -71,7 +71,7 @@ public: virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); - static void CreatePrs3d(VisuGUI* theModule); + static VISU::Prs3d_i* CreatePrs3d(VisuGUI* theModule); static void EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d, Handle(SALOME_InteractiveObject)& theIO); void updatePrsCopy(); diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 5112c097..43a362e7 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -278,64 +278,68 @@ namespace VISU //--------------------------------------------------------------- template - void + TPrs3d_i* CreatePrs3dInViewer(VisuGUI* theModule, _PTR(SObject) theTimeStampSObj, ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode) { + TPrs3d_i* aPrs = 0; // Create new TViewWindow instance, if it does not exist. typedef typename TViewer::TViewWindow TViewWindow; if (!GetViewWindow(theModule)) - return; + return aPrs; - CreateAndEditPrs3d - (theModule,theTimeStampSObj,thePublishInStudyMode); + aPrs = CreateAndEditPrs3d + (theModule,theTimeStampSObj,thePublishInStudyMode); theModule->application()->putInfo(QObject::tr("INF_DONE")); + return aPrs; } //---------------------------------------------------------------------------- template - void + TPrs3d_i* CreatePrs3d(VisuGUI* theModule, const QString& theDesiredViewerType = QString()) { + TPrs3d_i* aPrs = 0; if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule))) - return; + return aPrs; _PTR(SObject) aTimeStampSObj; Handle(SALOME_InteractiveObject) anIO; ColoredPrs3d_i::EPublishInStudyMode aPublishInStudyMode; if (!CheckTimeStamp(theModule,aTimeStampSObj,anIO,aPublishInStudyMode)) - return; + return aPrs; if(aPublishInStudyMode == VISU::ColoredPrs3d_i::EPublishIndependently){ // CreatePrs3dInViewer // (theModule,aTimeStampSObj,aPublishInStudyMode); - CreatePrs3dInViewer - (theModule,aTimeStampSObj,aPublishInStudyMode); - return; + aPrs = CreatePrs3dInViewer + (theModule,aTimeStampSObj,aPublishInStudyMode); + return aPrs; }else{ if(theDesiredViewerType.isNull()){ if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()) if (aViewManager->getType() == VVTK_Viewer::Type()){ - CreatePrs3dInViewer - (theModule,aTimeStampSObj,aPublishInStudyMode); - return; + aPrs = CreatePrs3dInViewer + (theModule,aTimeStampSObj,aPublishInStudyMode); + return aPrs; } - CreatePrs3dInViewer - (theModule,aTimeStampSObj,aPublishInStudyMode); + aPrs = CreatePrs3dInViewer + (theModule,aTimeStampSObj,aPublishInStudyMode); }else{ if(theDesiredViewerType == VVTK_Viewer::Type()) { - CreatePrs3dInViewer - (theModule,aTimeStampSObj,aPublishInStudyMode); + aPrs = CreatePrs3dInViewer + (theModule,aTimeStampSObj,aPublishInStudyMode); } else { - CreatePrs3dInViewer - (theModule,aTimeStampSObj,aPublishInStudyMode); + aPrs = CreatePrs3dInViewer + (theModule,aTimeStampSObj,aPublishInStudyMode); } } } + return aPrs; } diff --git a/src/VISUGUI/VisuGUI_SegmentationMgr.h b/src/VISUGUI/VisuGUI_SegmentationMgr.h index 9c072073..d4489e37 100644 --- a/src/VISUGUI/VisuGUI_SegmentationMgr.h +++ b/src/VISUGUI/VisuGUI_SegmentationMgr.h @@ -36,6 +36,7 @@ #include #include #include +#include class VISU_Actor; class vtkPlane; @@ -58,7 +59,8 @@ public: void setActive(bool theActive); bool isActive() const { return myIsActive; } - //static void removeCutPlaneFunctions(VISU_Actor* theActor); + void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; } + _PTR(SObject) getPlaneObject() const { return mySObject; } protected: CutPlaneFunction(); @@ -66,6 +68,7 @@ protected: private: bool myIsActive; + _PTR(SObject) mySObject; }; diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index ef30aef2..3ebed845 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -37,7 +37,7 @@ #include "VISU_Prs3d_i.hh" #include "VISU_Result_i.hh" #include "VISU_Table_i.hh" -#include "VISU_Mesh_i.hh" +//#include "VISU_Mesh_i.hh" #include "VISU_ViewManager_i.hh" #include "VISU_Actor.h" @@ -1097,8 +1097,7 @@ namespace VISU //************************************************************ // Others - - void + VISU::Mesh_i* CreateMesh(VisuGUI* theModule, const Handle(SALOME_InteractiveObject)& theIO, SVTK_ViewWindow* theViewWindow) @@ -1113,11 +1112,11 @@ namespace VISU VISU::Result_var aResult; VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult); if (pResult == NULL) - return; + return NULL; Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj); if (aMap.empty()) - return; + return NULL; CORBA::Object_var aMesh; string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data(); @@ -1155,7 +1154,7 @@ namespace VISU SUIT_MessageBox::warning (GetDesktop(theModule), QObject::tr("WRN_VISU"), QObject::tr("ERR_CANT_BUILD_PRESENTATION") ); - return; + return NULL; } if (theViewWindow) { @@ -1187,6 +1186,7 @@ namespace VISU theModule->application()->putInfo(QObject::tr("INF_DONE")); // Make "Save" button active theModule->getApp()->updateActions(); + return pPresent; } // ======================================================================================== @@ -1228,6 +1228,7 @@ namespace VISU case VISU::TSTREAMLINES: case VISU::TPLOT3D: case VISU::TSCALARMAPONDEFORMEDSHAPE: + case VISU::TMESH: { PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); if (aServant.in()) { @@ -1364,4 +1365,21 @@ namespace VISU spinBox->setDecimals( decimals ); } //------------------------------------------------------------ + bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject) + { + _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU"); + if (!aVisuSO) return false; + _PTR(SObject) aFolder = theStudy->FindObject(CLIP_PLANES_FOLDER); + if (!aFolder) { + _PTR(StudyBuilder) aBuilder = theStudy->NewBuilder(); + aFolder = aBuilder->NewObject(aVisuSO); + + _PTR(GenericAttribute) anAttr; + anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName"); + _PTR(AttributeName) aName(anAttr); + aName->SetValue(CLIP_PLANES_FOLDER); + } + theSObject = aFolder; + return true; + } } diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 2d68def7..f8fd7d6d 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -58,6 +58,7 @@ class VisuGUI; #include #include +#include "VISU_Mesh_i.hh" namespace VISU { @@ -215,9 +216,9 @@ namespace VISU /*! Create mesh presentation and display it in \a theViewWindow. * If \a theViewWindow is NULL, no displaying will be done. */ - void CreateMesh(VisuGUI* theModule, - const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ViewWindow* theViewWindow); + VISU::Mesh_i* CreateMesh(VisuGUI* theModule, + const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ViewWindow* theViewWindow); // Others std::vector GetPrs3dList (const SalomeApp_Module* theModule, @@ -232,6 +233,10 @@ namespace VISU VISU::Prs3d_i* thePrs3d); void initSpinBox( QSpinBox*, int, int, int = 1 ); void initSpinBox( QDoubleSpinBox*, double, double, double = 0.1, int = 6 ); + +#define CLIP_PLANES_FOLDER "Clipping Planes" + + bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject); } #endif