#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"
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);
SpinBoxDistance->setValue(0.5);
- initGlobalPlanes();
-
onSelectionChanged();
// signals and slots connections :
//=================================================================================
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));
//=================================================================================
void VisuGUI_ClippingDlg::ClickOnApply()
{
- if (myHasGlobalPl) {
- switch (myPlaneTypeGrp->checkedId()) {
- case 0: // Global plane
- applyGlobalPlanes();
- break;
- case 1: // Local plane
- applyLocalPlanes();
- break;
- }
- } else {
- applyLocalPlanes();
- }
+ applyLocalPlanes();
}
}
-//=================================================================================
-// function : applyGlobalPlanes()
-// purpose :
-//=================================================================================
-void VisuGUI_ClippingDlg::applyGlobalPlanes()
-{
- if (!myDSActor) return;
-
- VisuGUI_ViewExtender* aVisuExtender = dynamic_cast<VisuGUI_ViewExtender*>(myVisuGUI->getViewExtender());
- SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(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);
-}
-
//=================================================================================
//=================================================================================
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<SVTK_ViewWindow>(myVisuGUI))
VISU::RenderViewWindow(vw);
}
return;
}
-//=================================================================================
-// function : hasGlobalPlanes()
-// purpose :
-//=================================================================================
-bool VisuGUI_ClippingDlg::hasGlobalPlanes()
-{
- VisuGUI_ViewExtender* aVisuExtender = dynamic_cast<VisuGUI_ViewExtender*>(myVisuGUI->getViewExtender());
- if (!aVisuExtender) return false;
-
- SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(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<VisuGUI_ViewExtender*>(myVisuGUI->getViewExtender());
- SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(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<SVTK_ViewWindow>(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<VISU::Prs3d_i*>(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<SVTK_ViewWindow>(myVisuGUI));
-}
#include <QToolButton>
#include <QGroupBox>
#include <QListWidget>
+#include <QTableWidget>
#include <QStringList>
#include <QMessageBox>
#include <QCheckBox>
#include <SALOMEDSClient_AttributeSequenceOfReal.hxx>
#include <SALOMEDSClient_AttributeInteger.hxx>
+
+
+
VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule)
: VisuGUI_Panel(tr("TITLE"), theModule, VISU::GetDesktop(theModule), ApplyBtn | HelpBtn ),
myModule(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
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*)));
}
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<VISU::Prs3d_i*> VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy,
_PTR(SObject) theObject)
//*************************************************************************
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));
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<SVTK_Viewer>(myModule);
fillPrsList();
- VisuGUI_Panel::showEvent(event);
+ fillPlanesList();
}
+//*************************************************************************
+//void VisuGUI_ClippingPanel::showEvent(QShowEvent* event)
+//{
+// VisuGUI_Panel::showEvent(event);
+//}
+
//*************************************************************************
// void VisuGUI_ClippingPanel::hideEvent(QHideEvent* 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);
{
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);
} else {
aItem->setCheckState(Qt::Unchecked);
}
- myPlanesList->addItem(aItem);
+ myPlanesList->setItem(aRow, 0, aItem);
+ myPlanesList->setItem(aRow, 1, aCheckItem);
myPlanes.append(aNewPlane);
delete myPlaneDlg;
if (myViewWindow)
myViewWindow->Repaint();
+ connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
}
//*************************************************************************
{
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)));
}
//*************************************************************************
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
aBuilder->RemoveObject(aSObj);
- myPlanesList->takeItem(aRow);
+ myPlanesList->removeRow(aRow);
myPlanes.removeAt(aRow);
VISU::UpdateObjBrowser(myModule);
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)));
}
//*************************************************************************
//*************************************************************************
void VisuGUI_ClippingPanel::onWindowActivated(SUIT_ViewWindow* theWindow)
{
+ setPlanesVisible(false);
myViewWindow = dynamic_cast<SVTK_ViewWindow*>(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()
{