From: vsv Date: Wed, 23 Jul 2008 12:45:40 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: TG_VISU_2008_2008-08-22~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=659a6233c7038a0e547e7a764d97422e2b5def88;p=modules%2Fvisu.git *** empty log message *** --- diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 3d629cb5..875f32a0 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -79,7 +79,6 @@ dist_libVISU_la_SOURCES= \ VisuGUI_Sweep.cxx \ VisuGUI_InputPane.cxx \ VisuGUI_FieldFilter.cxx \ - VisuGUI_ViewExtender.cxx \ VisuGUI_ClippingPlaneMgr.cxx \ VisuGUI_SegmentationMgr.cxx \ VisuGUI_ClippingPanel.cxx \ @@ -121,7 +120,6 @@ MOC_FILES= \ VisuGUI_Slider_moc.cxx \ VisuGUI_Sweep_moc.cxx \ VisuGUI_InputPane_moc.cxx \ - VisuGUI_ViewExtender_moc.cxx \ VisuGUI_ClippingPlaneMgr_moc.cxx \ VisuGUI_SegmentationMgr_moc.cxx \ VisuGUI_ClippingPanel_moc.cxx \ diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index c09967b7..a3afb3ec 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -3606,7 +3606,11 @@ Please, refer to the documentation. CHK_AUTO_APPLY Auto apply - + + PLANES_TABLE_TITLES + Plane,Active + + VisuGUI_ClippingPlaneDlg @@ -3627,7 +3631,7 @@ Please, refer to the documentation. CHK_AUTOAPPLY - Auto apply + Global CHK_SHOW_PREVIEW diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 03adac48..13ecf6ef 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1250,6 +1250,7 @@ VisuGUI for (i = 0; i < nbSelected; i++) { VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), anEntries[i]); if(_PTR(SObject) aSObject = anObjectInfo.mySObject){ + emit beforeObjectDelete(QString(aSObject->GetID().c_str())); _PTR(SObject) aRefSObject; if (aSObject->ReferencedObject(aRefSObject)) { // It can be a reference on curve, published under a container. @@ -2988,6 +2989,8 @@ VisuGUI shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) ); action(VISU_IMPORT_FROM_FILE)->setShortcuts(shortcuts); + ((VisuGUI_ClippingPanel*) myPanels[ClippingPlanesPanelId])->init(); + emit moduleActivated(); return aResult; @@ -3029,6 +3032,7 @@ VisuGUI void VisuGUI::studyActivated() { GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this)))); + } /* diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index b7ba9a78..df9aec95 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -90,6 +90,7 @@ signals: void moduleDeactivated(); void moduleActivated(); void presentationCreated(VISU::Prs3d_i* thePrs); + void beforeObjectDelete(QString theEntry); public slots: virtual bool deactivateModule( SUIT_Study* ); diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index e3bab7c3..e9e63afe 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -24,7 +24,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" #include "VisuGUI_SegmentationMgr.h" -#include "VisuGUI_ViewExtender.h" #include "VisuGUI_ClippingPlaneMgr.h" #include "VISU_Prs3d_i.hh" @@ -265,47 +264,9 @@ VisuGUI_ClippingDlg::VisuGUI_ClippingDlg (VisuGUI* theModule, QVBoxLayout* VisuGUI_ClippingDlgLayout = new QVBoxLayout(this); VisuGUI_ClippingDlgLayout->setSpacing(6); VisuGUI_ClippingDlgLayout->setMargin(11); - - myHasGlobalPl = hasGlobalPlanes(); - - if (myHasGlobalPl) { - QGroupBox* aTypeFrm = new QGroupBox (tr("GRP_TYPE"), this); - QHBoxLayout* aTypeLayout = new QHBoxLayout(aTypeFrm); - aTypeFrm->setLayout(aTypeLayout); - VisuGUI_ClippingDlgLayout->addWidget(aTypeFrm); - - myPlaneTypeGrp = new QButtonGroup (aTypeFrm); - myPlaneTypeGrp->setExclusive(true); - - QRadioButton* aGlobalBtn = new QRadioButton(tr("GLOBAL_BTN"), aTypeFrm); - aGlobalBtn->setChecked(true); - aTypeLayout->addWidget(aGlobalBtn); - myPlaneTypeGrp->addButton(aGlobalBtn, 0); - - aTypeLayout->addStretch(); - - QRadioButton* aLocalBtn = new QRadioButton(tr("LOCAL_BTN"), aTypeFrm); - aTypeLayout->addWidget(aLocalBtn); - myPlaneTypeGrp->addButton(aLocalBtn, 1); - } QStackedWidget* aStackWidget = new QStackedWidget(this); VisuGUI_ClippingDlgLayout->addWidget(aStackWidget); - if (myHasGlobalPl) { - connect(myPlaneTypeGrp, SIGNAL(buttonClicked(int)), aStackWidget, SLOT(setCurrentIndex(int)) ); - connect(myPlaneTypeGrp, SIGNAL(buttonClicked(int)), this, SLOT(onPlaneType(int)) ); - - // Global planes - QGroupBox* aViewerPlanes = new QGroupBox (tr("GRP_VIEWER_PLANES"), aStackWidget); - QVBoxLayout* aGPlanesLayout = new QVBoxLayout(aStackWidget); - aViewerPlanes->setLayout(aGPlanesLayout); - aStackWidget->addWidget(aViewerPlanes); - - myGlobalPlanes = new QListWidget(aViewerPlanes); - connect(myGlobalPlanes, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onPlaneCheck())); - - aGPlanesLayout->addWidget(myGlobalPlanes); - } // Local planes QWidget* aLocalPlanes = new QWidget(aStackWidget); QVBoxLayout* aLocalLayout = new QVBoxLayout(aLocalPlanes); @@ -411,8 +372,6 @@ VisuGUI_ClippingDlg::VisuGUI_ClippingDlg (VisuGUI* theModule, SpinBoxDistance->setValue(0.5); - initGlobalPlanes(); - onSelectionChanged(); // signals and slots connections : @@ -447,9 +406,6 @@ VisuGUI_ClippingDlg::VisuGUI_ClippingDlg (VisuGUI* theModule, //================================================================================= VisuGUI_ClippingDlg::~VisuGUI_ClippingDlg() { - if (myHasGlobalPl) - deleteGlobalPlanesPreview(); - // no need to delete child widgets, Qt does it all for us SetPrs3d(NULL); std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); @@ -548,18 +504,7 @@ QWidget* VisuGUI_ClippingDlg::createIJKParamsTab() //================================================================================= void VisuGUI_ClippingDlg::ClickOnApply() { - if (myHasGlobalPl) { - switch (myPlaneTypeGrp->checkedId()) { - case 0: // Global plane - applyGlobalPlanes(); - break; - case 1: // Local plane - applyLocalPlanes(); - break; - } - } else { - applyLocalPlanes(); - } + applyLocalPlanes(); } @@ -636,32 +581,6 @@ void VisuGUI_ClippingDlg::applyLocalPlanes() } -//================================================================================= -// function : applyGlobalPlanes() -// purpose : -//================================================================================= -void VisuGUI_ClippingDlg::applyGlobalPlanes() -{ - if (!myDSActor) return; - - VisuGUI_ViewExtender* aVisuExtender = dynamic_cast(myVisuGUI->getViewExtender()); - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI); - VisuGUI_SegmentationMgr* aSegmentationMgr = aVisuExtender->getSegmentationMgr(aViewWindow); - - myDSActor->RemoveAllClippingPlanes(); - - const QListOfPlanes& aPlanes = aSegmentationMgr->getPlanes(); - PlaneDef aPlane; - - for (int i = 0; i < myGlobalPlanes->count(); i++) { - if (myGlobalPlanes->item(i)->checkState() == Qt::Checked) { - aPlane = aPlanes.at(i); - myDSActor->AddClippingPlane(aPlane.plane); - } - } - VISU::RenderViewWindow(aViewWindow); -} - //================================================================================= @@ -1299,20 +1218,7 @@ void VisuGUI_ClippingDlg::onIJKAxisChanged(int axisId) //================================================================================= void VisuGUI_ClippingDlg::OnPreviewToggle (bool theIsToggled) { - if (myHasGlobalPl) { - switch (myPlaneTypeGrp->checkedId()) { - case 0: // Global plane - previewGlobalPlanes(theIsToggled); - std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); - break; - case 1: // Local plane - previewGlobalPlanes(false); - std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); - break; - } - } else { - std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); - } + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); if (SVTK_ViewWindow* vw = VISU::GetActiveViewWindow(myVisuGUI)) VISU::RenderViewWindow(vw); } @@ -1347,138 +1253,6 @@ void VisuGUI_ClippingDlg::SetPrs3d(VISU::Prs3d_i* thePrs) return; } -//================================================================================= -// function : hasGlobalPlanes() -// purpose : -//================================================================================= -bool VisuGUI_ClippingDlg::hasGlobalPlanes() -{ - VisuGUI_ViewExtender* aVisuExtender = dynamic_cast(myVisuGUI->getViewExtender()); - if (!aVisuExtender) return false; - - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI); - if (!aViewWindow) return false; - - VisuGUI_SegmentationMgr* aSegmentationMgr = aVisuExtender->getSegmentationMgr(aViewWindow); - return aSegmentationMgr->getPlanes().size() > 0; -} - -//================================================================================= -// function : initGlobalPlanes() -// purpose : -//================================================================================= -void VisuGUI_ClippingDlg::initGlobalPlanes() -{ - if (!myHasGlobalPl) return; - VisuGUI_ViewExtender* aVisuExtender = dynamic_cast(myVisuGUI->getViewExtender()); - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI); - VisuGUI_SegmentationMgr* aSegmentationMgr = aVisuExtender->getSegmentationMgr(aViewWindow); - - double aBounds[6]; - ComputeVisiblePropBounds(aViewWindow->getRenderer(), aBounds); - - // Add planes names to list - const QListOfPlanes& aPlanes = aSegmentationMgr->getPlanes(); - PlaneDef aPlane; - for (int i = 0; i < aPlanes.size(); i++) { - aPlane = aPlanes.at(i); - QListWidgetItem* aItem = new QListWidgetItem(aPlane.name, myGlobalPlanes); - if (aPlane.isAuto) - aItem->setFlags(0); - // else - aItem->setCheckState(Qt::Unchecked); - myGlobalPlanes->addItem(aItem); - - //Create preview - PreviewPlane* aPreview = new PreviewPlane(aViewWindow, aPlane, aBounds); - aPreview->setVisible(PreviewCheckBox->checkState() == Qt::Checked); - myPreviewList.append(aPreview); - } - - // Check items according to already added planes - myDSActor = getSelectedActor(); - if (!myDSActor) return; - - vtkImplicitFunctionCollection* aFunctions = myDSActor->GetClippingPlanes(); - aFunctions->InitTraversal(); - vtkImplicitFunction* aItem; - while (aItem = aFunctions->GetNextItem()) { - for (int i = 0; i < aPlanes.size(); i++) { - aPlane = aPlanes.at(i); - if (aPlane.plane.GetPointer() == aItem) { - myGlobalPlanes->item(i)->setCheckState(Qt::Checked); - break; - } - } - } -} - -//================================================================================= -// function : initGlobalPlanes() -// purpose : -//================================================================================= -VISU_Actor* VisuGUI_ClippingDlg::getSelectedActor() -{ - SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI); - - VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(myVisuGUI); - if(aSelectionInfo.empty()) return 0; - - VISU::TSelectionItem aSelectionItem = aSelectionInfo.front(); - VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; - if(!aBase) return 0; - - VISU::Prs3d_i* aPrs = dynamic_cast(aBase); - if (!aPrs) return 0; - - VISU_Actor* aActor = VISU::FindActor(aViewWindow, aPrs); - return aActor; -} - -//================================================================================= -// function : onPlaneCheck() -// purpose : -//================================================================================= -void VisuGUI_ClippingDlg::onPlaneCheck() -{ - if (AutoApplyCheckBox->checkState() == Qt::Checked) { - applyGlobalPlanes(); - } -} -//================================================================================= -// function : previewGlobalPlanes() -// purpose : -//================================================================================= -void VisuGUI_ClippingDlg::previewGlobalPlanes(bool theShow) -{ - for (int i = 0; i < myPreviewList.size(); i++) { - myPreviewList.at(i)->setVisible(theShow); - } -} -//================================================================================= -// function : deleteGlobalPlanesPreview() -// purpose : -//================================================================================= -void VisuGUI_ClippingDlg::deleteGlobalPlanesPreview() -{ - PreviewPlane* aPreview = 0; - while (myPreviewList.size() > 0) { - aPreview = myPreviewList.last(); - myPreviewList.removeLast(); - delete aPreview; - } -} - -//================================================================================= -// function : deleteGlobalPlanesPreview() -// purpose : -//================================================================================= -void VisuGUI_ClippingDlg::onPlaneType(int theType) -{ - previewGlobalPlanes(theType == 0); - std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theType == 1)); - VISU::RenderViewWindow(VISU::GetActiveViewWindow(myVisuGUI)); -} diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.h b/src/VISUGUI/VisuGUI_ClippingDlg.h index 87e14e86..a6be8ed6 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.h +++ b/src/VISUGUI/VisuGUI_ClippingDlg.h @@ -136,17 +136,10 @@ private: void keyPressEvent( QKeyEvent* e ); void SetPrs3d(VISU::Prs3d_i* thePrs); - - void initGlobalPlanes(); - bool hasGlobalPlanes(); VISU_Actor* getSelectedActor(); void applyLocalPlanes(); - void applyGlobalPlanes(); - - void deleteGlobalPlanesPreview(); - void previewGlobalPlanes(bool theShow); private: @@ -190,9 +183,6 @@ private: bool myIsSelectPlane; - QButtonGroup* myPlaneTypeGrp; - QListWidget* myGlobalPlanes; - bool myHasGlobalPl; VISU_Actor* myDSActor; QList myPreviewList; @@ -218,8 +208,8 @@ public slots: void ClickOnCancel(); void ClickOnApply(); void ClickOnHelp(); - void onPlaneCheck(); - void onPlaneType(int); }; #endif // DIALOGBOX_TRANSPARENCYDLG_H + + diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.cxx b/src/VISUGUI/VisuGUI_ClippingPanel.cxx index b08f4567..b06088ed 100644 --- a/src/VISUGUI/VisuGUI_ClippingPanel.cxx +++ b/src/VISUGUI/VisuGUI_ClippingPanel.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,9 @@ #include #include + + + VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule) : VisuGUI_Panel(tr("TITLE"), theModule, VISU::GetDesktop(theModule), ApplyBtn | HelpBtn ), myModule(theModule), @@ -60,12 +64,15 @@ VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule) aMainLayout->addWidget(new QLabel(tr("PRESENTATIONS_LBL"), mainFrame())); myPrsList = new QListWidget(mainFrame()); myPrsList->setSelectionMode(QAbstractItemView::SingleSelection); + connect(myPrsList, SIGNAL(currentRowChanged(int)), this, SLOT(onPrsSelected(int))); aMainLayout->addWidget(myPrsList); // List of planes aMainLayout->addWidget(new QLabel(tr("PLANES_LBL"), mainFrame())); - myPlanesList = new QListWidget(mainFrame()); + myPlanesList = new QTableWidget(0, 2, mainFrame()); + myPlanesList->setColumnWidth(1, 50); myPlanesList->setSelectionMode(QAbstractItemView::SingleSelection); + connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); aMainLayout->addWidget(myPlanesList); // Management buttons @@ -100,17 +107,22 @@ VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule) aMainLayout->addWidget(myNonActivePlanes); myAutoApply = new QCheckBox(tr("CHK_AUTO_APPLY"), mainFrame()); + connect(myAutoApply, SIGNAL(toggled(bool)), myApply, SLOT(setDisabled(bool))); + myAutoApply->setCheckState(Qt::Checked); aMainLayout->addWidget(myAutoApply); - fillPrsList(); - fillPlanesList(); + // fillPrsList(); + // fillPlanesList(); connect(myModule, SIGNAL(presentationCreated(VISU::Prs3d_i*)), this, SLOT(onPresentationCreate(VISU::Prs3d_i*))); + connect(myModule, SIGNAL(beforeObjectDelete(QString)), + this, SLOT(onObjectDelete(QString))); SUIT_Desktop* aDesktop = VISU::GetDesktop(myModule); - connect(aDesktop, SIGNAL(windowActivated(SUIT_ViewWindow*)), this, SLOT(onWindowActivated(SUIT_ViewWindow*))); + connect(aDesktop, SIGNAL(windowActivated(SUIT_ViewWindow*)), + this, SLOT(onWindowActivated(SUIT_ViewWindow*))); } @@ -132,11 +144,33 @@ void VisuGUI_ClippingPanel::fillPrsList() myPresentations = getPrsList(aStudy, aVisuSO); QStringList aNames; for (int i = 0; i < myPresentations.size(); i++) { - aNames.append(myPresentations.at(i)->GetName().c_str()); + aNames.append(getPrsName(myPresentations.at(i))); } myPrsList->addItems(aNames); } +//************************************************************************* +QString VisuGUI_ClippingPanel::getPrsName(VISU::Prs3d_i* thePrs) +{ + QString aName; + QStringList aPath; + SALOMEDS::SObject_var aFather = thePrs->GetSObject()->GetFather(); + while (!aFather->_is_nil()) { + SALOMEDS::GenericAttribute_var anAttr; + if (aFather->FindAttribute(anAttr, "AttributeName")) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + aPath.append(aValue.in()); + aFather = aFather->GetFather(); + } else + break; + } + for (int j = aPath.size() - 2; j >= 0; j--) + aName += aPath.at(j) + "/"; + aName += thePrs->GetName().c_str(); + return aName; +} + //************************************************************************* QList VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject) @@ -166,6 +200,7 @@ QList VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy, //************************************************************************* void VisuGUI_ClippingPanel::fillPlanesList() { + disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); myPlanesList->clear(); myPlanes.clear(); _PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule)); @@ -173,32 +208,70 @@ void VisuGUI_ClippingPanel::fillPlanesList() 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(); + for (i = 0; aIter->More(); aIter->Next(), i++) { // For each plane + _PTR(SObject) aSObject = aIter->Value(); PlaneDef aNewPlane = createEmptyPlane(); updatePlane(aSObject, aNewPlane); - QListWidgetItem* aItem = new QListWidgetItem(aNewPlane.name, myPlanesList); + myPlanesList->insertRow(i); + QTableWidgetItem* aItem = new QTableWidgetItem(aNewPlane.name); + QTableWidgetItem* aCheckItem = new QTableWidgetItem(); + aCheckItem->setCheckState((myNonActivePlanes->checkState() == Qt::Checked)? Qt::Unchecked : Qt::Checked); - if (aNewPlane.isAuto) { + if (aNewPlane.isAuto) { // If this is Auto plane aItem->setFlags(0); + // apply to all presentations aItem->setCheckState(Qt::Checked); - } else { + foreach(VISU::Prs3d_i* aPrs, myPresentations) { + aPrs->AddClippingPlane(aNewPlane.plane); + } + } else { // if it is not auto + foreach(VISU::Prs3d_i* aPrs, myPresentations) { + _PTR(ChildIterator) aRefIter = aStudy->NewChildIterator(aSObject); + for (; aRefIter->More(); aRefIter->Next()) { + _PTR(SObject) aObj = aRefIter->Value(); + _PTR(SObject) aRefPrsObject; + if (aObj->ReferencedObject(aRefPrsObject)) { // If it is referenced on current plane + if (QString(aRefPrsObject->GetID().c_str()) == QString(aPrs->GetEntry().c_str())) { + aPrs->AddClippingPlane(aNewPlane.plane); + } + } + } + } aItem->setCheckState(Qt::Unchecked); + // Check current presentation + int aPrsNum = myPrsList->currentRow(); + if (aPrsNum >= 0) { + if (containsPlane(myPresentations.at(aPrsNum), aNewPlane)) + aItem->setCheckState(Qt::Checked); + } } - myPlanesList->addItem(aItem); + myPlanesList->setItem(i, 0, aItem); + myPlanesList->setItem(i, 1, aCheckItem); myPlanes.append(aNewPlane); } } + myPlanesList->setHorizontalHeaderLabels(QString(tr("PLANES_TABLE_TITLES")).split(",")); + if (myViewWindow) + myViewWindow->Repaint(); + connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); } + //************************************************************************* -void VisuGUI_ClippingPanel::showEvent(QShowEvent* event) +void VisuGUI_ClippingPanel::init() { + myViewWindow = VISU::GetViewWindow(myModule); fillPrsList(); - VisuGUI_Panel::showEvent(event); + fillPlanesList(); } +//************************************************************************* +//void VisuGUI_ClippingPanel::showEvent(QShowEvent* event) +//{ +// VisuGUI_Panel::showEvent(event); +//} + //************************************************************************* // void VisuGUI_ClippingPanel::hideEvent(QHideEvent* event) // { @@ -209,7 +282,8 @@ void VisuGUI_ClippingPanel::showEvent(QShowEvent* event) //************************************************************************* void VisuGUI_ClippingPanel::onPresentationCreate(VISU::Prs3d_i* thePrs) { - myPrsList->addItem(thePrs->GetName().c_str()); + + myPrsList->addItem(getPrsName(thePrs)); myPresentations.append(thePrs); for (int i = 0; i < myPlanes.size(); i++) { const PlaneDef& aPlane = myPlanes.at(i); @@ -254,12 +328,18 @@ void VisuGUI_ClippingPanel::onNewPlane() { disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane())); disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj(); PlaneDef aNewPlane = createEmptyPlane(); updatePlane(aPlaneSObj, aNewPlane); + int aRow = myPlanesList->rowCount(); + myPlanesList->insertRow(aRow); - QListWidgetItem* aItem = new QListWidgetItem(aNewPlane.name, myPlanesList); + QTableWidgetItem* aItem = new QTableWidgetItem(aNewPlane.name); + QTableWidgetItem* aCheckItem = new QTableWidgetItem(); + aCheckItem->setCheckState((myNonActivePlanes->checkState() == Qt::Checked)? Qt::Unchecked : Qt::Checked); + aNewPlane.plane->setActive(myNonActivePlanes->checkState() != Qt::Checked); if (aNewPlane.isAuto) { aItem->setFlags(0); aItem->setCheckState(Qt::Checked); @@ -269,7 +349,8 @@ void VisuGUI_ClippingPanel::onNewPlane() } else { aItem->setCheckState(Qt::Unchecked); } - myPlanesList->addItem(aItem); + myPlanesList->setItem(aRow, 0, aItem); + myPlanesList->setItem(aRow, 1, aCheckItem); myPlanes.append(aNewPlane); delete myPlaneDlg; @@ -279,6 +360,7 @@ void VisuGUI_ClippingPanel::onNewPlane() if (myViewWindow) myViewWindow->Repaint(); + connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); } //************************************************************************* @@ -286,18 +368,43 @@ void VisuGUI_ClippingPanel::onPlaneEdited() { disconnect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onNewPlane())); disconnect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog())); + disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj(); PlaneDef aPlane = myPlanes.at(myEditingPlanePos); updatePlane(aPlaneSObj, aPlane); + QTableWidgetItem* aItem = myPlanesList->item(myEditingPlanePos, 0); + if (aPlane.isAuto) { + aItem->setCheckState(Qt::Checked); + aItem->setFlags(0); + _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) ); + _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aPlaneSObj); + for (; aIter->More(); aIter->Next()) { + _PTR(SObject) aObj = aIter->Value(); + VISU::DeleteSObject(myModule, aStudy, aObj); + } + VISU::UpdateObjBrowser(myModule); + } else { + aItem->setCheckState(Qt::Unchecked); + aItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); + int aPrsNum = myPrsList->currentRow(); + if (aPrsNum >= 0) { + if (containsPlane(myPresentations.at(aPrsNum), aPlane)) + aItem->setCheckState(Qt::Checked); + } + } + aItem->setText(aPlane.name); + delete myPlaneDlg; myPlaneDlg = 0; + myPlanes.replace(myEditingPlanePos, aPlane); setPlanesVisible(myShowPlanes->checkState() == Qt::Checked); if (myViewWindow) myViewWindow->Repaint(); + connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); } //************************************************************************* @@ -369,7 +476,7 @@ void VisuGUI_ClippingPanel::onPlaneDelete() _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); aBuilder->RemoveObject(aSObj); - myPlanesList->takeItem(aRow); + myPlanesList->removeRow(aRow); myPlanes.removeAt(aRow); VISU::UpdateObjBrowser(myModule); @@ -401,12 +508,15 @@ void VisuGUI_ClippingPanel::onApply() void VisuGUI_ClippingPanel::setPlanesNonActive(bool theState) { PlaneDef aPlane; + disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); for (int i = 0; i < myPlanes.size(); i++) { aPlane = myPlanes.at(i); aPlane.plane->setActive(!theState); + myPlanesList->item(i, 1)->setCheckState((theState)? Qt::Unchecked : Qt::Checked); } if (myViewWindow) myViewWindow->Repaint(); + connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); } //************************************************************************* @@ -450,11 +560,116 @@ void VisuGUI_ClippingPanel::onCancelDialog() //************************************************************************* void VisuGUI_ClippingPanel::onWindowActivated(SUIT_ViewWindow* theWindow) { + setPlanesVisible(false); myViewWindow = dynamic_cast(theWindow); - printf("#### New window activated\n"); + setPlanesVisible(myShowPlanes->checkState() == Qt::Checked); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onCellChanged(int row, int col) +{ + PlaneDef aPlane = myPlanes.at(row); + bool isChecked = (myPlanesList->item(row, col)->checkState() == Qt::Checked); + if (col == 1) { // activate column clicked + aPlane.plane->setActive(isChecked); + } else { // Plane checked + + if (aPlane.isAuto) return; + + int aPrsNum = myPrsList->currentRow(); + if (aPrsNum < 0) return; + + _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) ); + _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder(); + VISU::Prs3d_i* aPrs = myPresentations.at(aPrsNum); + _PTR(SObject) aSObject = aPlane.plane->getPlaneObject(); + _PTR(SObject) aPrsSObj = aStudy->FindObjectID(aPrs->GetEntry()); + if (isChecked) { + if (!containsPlane(aPrs, aPlane)) + aPrs->AddClippingPlane(aPlane.plane); + + if(!aStudy->GetProperties()->IsLocked()) { + _PTR(SObject) aNewObj = aBuilder->NewObject(aSObject); + aBuilder->Addreference(aNewObj, aPrsSObj); + } + } else { + for (int i = 0; i < aPrs->GetNumberOfClippingPlanes(); i++) { + if (aPrs->GetClippingPlane(i) == aPlane.plane.GetPointer()) { + aPrs->RemoveClippingPlane(i); + break; + } + } + if(!aStudy->GetProperties()->IsLocked()) { + _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject); + for (; aIter->More(); aIter->Next()) { + _PTR(SObject) aRefObj = aIter->Value(); + if(aRefObj) { + _PTR(SObject) aRefPrsObject; + if (aRefObj->ReferencedObject(aRefPrsObject)) { + if (QString(aRefPrsObject->GetID().c_str()) == QString(aPrs->GetEntry().c_str())) { + VISU::DeleteSObject(myModule, aStudy, aRefObj); + break; + } + } + } + } + } + } + VISU::UpdateObjBrowser(myModule); + } + if (myViewWindow) + myViewWindow->Repaint(); +} + + +//************************************************************************* +bool VisuGUI_ClippingPanel::containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane) +{ + bool isContains = false; + for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) { + if (thePrs->GetClippingPlane(i) == thePlane.plane.GetPointer()) { + return true; + } + } + return false; } +//************************************************************************* +void VisuGUI_ClippingPanel::onObjectDelete(QString theEntry) +{ + disconnect(myPrsList, SIGNAL(currentRowChanged(int)), this, SLOT(onPrsSelected(int))); + int i = 0; + foreach (VISU::Prs3d_i* aPrs, myPresentations) { + QString aID(aPrs->GetEntry().c_str()); + if (aID == theEntry) { + myPresentations.removeAt(i); + myPrsList->takeItem(i); + break; + } + i++; + } + connect(myPrsList, SIGNAL(currentRowChanged(int)), this, SLOT(onPrsSelected(int))); + onPrsSelected(myPrsList->currentRow()); +} + +//************************************************************************* +void VisuGUI_ClippingPanel::onPrsSelected(int thePrs) +{ + if (thePrs < 0) return; + disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); + VISU::Prs3d_i* aPrs = myPresentations.at(thePrs); + QListOfPlanes::const_iterator aIt; + int i = 0; + for (aIt = myPlanes.begin(), i = 0; aIt != myPlanes.end(); ++aIt, i++) { + QTableWidgetItem* aItem = myPlanesList->item(i, 0); + const PlaneDef& aPlane = *aIt; + if (!aPlane.isAuto) + aItem->setCheckState(containsPlane(aPrs, aPlane)? Qt::Checked : Qt::Unchecked); + } + connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int))); +} + //************************************************************************* void VisuGUI_ClippingPanel::onHelp() { diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.h b/src/VISUGUI/VisuGUI_ClippingPanel.h index 79993422..585e7723 100644 --- a/src/VISUGUI/VisuGUI_ClippingPanel.h +++ b/src/VISUGUI/VisuGUI_ClippingPanel.h @@ -24,6 +24,7 @@ class VisuGUI; class QListWidget; +class QTableWidget; class VisuGUI_ClippingPlaneDlg; class QCheckBox; class SVTK_ViewWindow; @@ -44,8 +45,10 @@ public: VisuGUI_ClippingPanel(VisuGUI* theModule); ~VisuGUI_ClippingPanel(); -protected: - virtual void showEvent(QShowEvent* event); + void init(); + + //protected: + //virtual void showEvent(QShowEvent* event); //virtual void hideEvent(QHideEvent* event); public slots: @@ -65,6 +68,9 @@ private slots: void setPlanesNonActive(bool theState); void setPlanesVisible(bool theVisible); void onWindowActivated(SUIT_ViewWindow* theWindow); + void onCellChanged(int row, int col); + void onObjectDelete(QString theEntry); + void onPrsSelected(int thePrs); private: void fillPrsList(); @@ -72,6 +78,9 @@ private slots: void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane); PlaneDef createEmptyPlane(); + static bool containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane); + + QString getPrsName(VISU::Prs3d_i* thePrs); bool isVISUDataReady(); @@ -80,7 +89,7 @@ private slots: VisuGUI* myModule; QListWidget* myPrsList; - QListWidget* myPlanesList; + QTableWidget* myPlanesList; QCheckBox* myShowPlanes; QCheckBox* myNonActivePlanes; diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx index 8e87d74e..25c616d9 100644 --- a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx +++ b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.cxx @@ -22,7 +22,6 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" -#include "VisuGUI_ViewExtender.h" #include "VISU_Actor.h" @@ -156,7 +155,7 @@ VisuGUI_ClippingPlaneMgr::VisuGUI_ClippingPlaneMgr(VisuGUI* theModule, aManageBox->addWidget(aDeleteBtn); QPushButton* aImportBtn = new QPushButton(tr("BTN_IMPORT"), this); - connect(aImportBtn, SIGNAL(clicked()), this, SLOT(onImportPlane())); + //connect(aImportBtn, SIGNAL(clicked()), this, SLOT(onImportPlane())); aManageBox->addWidget(aImportBtn); aManageBox->addStretch(); @@ -594,7 +593,7 @@ void VisuGUI_ClippingPlaneMgr::setDirection(double theVal[3]) //**************************************************************** -void VisuGUI_ClippingPlaneMgr::onImportPlane() +/*void VisuGUI_ClippingPlaneMgr::onImportPlane() { SalomeApp_Application* aApp = myModule->getApp(); if (!aApp) return; @@ -653,7 +652,7 @@ void VisuGUI_ClippingPlaneMgr::onImportPlane() myViewWindow->Repaint(); } } - +*/ //**************************************************************** void VisuGUI_ClippingPlaneMgr::onShowPreview(int theVal) { diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h index 013d646a..a24b54b7 100644 --- a/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h +++ b/src/VISUGUI/VisuGUI_ClippingPlaneMgr.h @@ -73,7 +73,7 @@ private slots: void onNewPlane(); void onDeletePlane(); void onValueChanged(); - void onImportPlane(); + // void onImportPlane(); void onShowPreview(int); private: diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 8b732c1d..02507a9f 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -27,7 +27,6 @@ // $Header$ #include "VisuGUI_Module.h" -#include "VisuGUI_ViewExtender.h" #include "QtxPopupMgr.h" @@ -182,7 +181,6 @@ namespace VISU VisuGUI_Module::VisuGUI_Module() : VisuGUI() { - myExtender = new VisuGUI_ViewExtender(this); } diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index 548fe2ca..4ba8be2a 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -31,8 +31,6 @@ #include "VisuGUI.h" #include "STD_Application.h" #include "SALOMEDSClient_SObject.hxx" -#include -#include "VisuGUI_ViewExtender.h" class SUIT_ViewManager; class SVTK_ViewManager; @@ -83,9 +81,6 @@ public: void restoreVisualParameters(int savePoint); - //! Returns Module dedicated extension for Viewer. Returns 0 if module has no extension - // virtual CAM_ViewExtender* getViewExtender() { return myExtender; } - public slots: //! Reimplemented method of the module deactivation. virtual @@ -166,8 +161,6 @@ protected: void setProperty( SVTK_ViewWindow*, const QString& ); // set a property (speed_increment, etc ) for SVTK ViewWindow void setProperty( SVTK_ViewManager*, const QString& ); // set a property for SVTK ViewWindow // set only 1 property for all ViewWindows of given view manager - - VisuGUI_ViewExtender* myExtender; }; #endif