TALL
};
+ /* Clipping planes management */
+ struct ClippingPlane {
+ double X;
+ double Y;
+ double Z;
+ double dX;
+ double dY;
+ double dZ;
+ boolean isAuto;
+ string name;
+ };
+
interface Base {
/*!
* Returns ID of the object.
* Get or create %ColoredPrs3dCache object.
*/
ColoredPrs3dCache GetColoredPrs3dCache(in SALOMEDS::Study theStudy);
+
+
+ /* Clipping planes management */
+
+ /*Create a clipping plane and return its ID (position in corresponded array)
+ Id of clipping plane could be changed after deletion of other clipping plane
+ */
+ long CreateClippingPlane(in double X, in double Y, in double Z,
+ in double dX, in double dY, in double dZ,
+ in boolean auto, in string name);
+
+ void EditClippingPlane(in long id, in double X, in double Y, in double Z,
+ in double dX, in double dY, in double dZ,
+ in boolean auto, in string name);
+
+ /* Returns clipping plane by its Id */
+ ClippingPlane GetClippingPlane(in long id);
+
+ /* Deletes clipping plane by its Id */
+ boolean DeleteClippingPlane(in long id);
+
+ /* Applyes a clipping plane with Id to presentation thePrs */
+ boolean ApplyClippingPlane(in Prs3d thePrs, in long id);
+
+ /* Detaches a clipping plane with Id from presentation thePrs */
+ boolean DetachClippingPlane(in Prs3d thePrs, in long id);
+
+
+ /* Get number of clipping planes */
+ long GetClippingPlanesNb();
+
};
/*! \brief %View interface
*/
void Destroy(in View theView);
};
+
+
};
#endif
{
return myVisuGen->GetColoredPrs3dCache(theStudy);
}
+
+
+
+ CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name)
+ {
+ return myVisuGen->CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
+ }
+
+
+ void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name)
+ {
+ myVisuGen->EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
+ }
+
+ /* Returns clipping plane by its Id */
+ VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
+ {
+ return myVisuGen->GetClippingPlane(id);
+ }
+
+ /* Deletes clipping plane by its Id */
+ CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
+ {
+ return myVisuGen->DeleteClippingPlane(id);
+ }
+
+ /* Applyes a clipping plane with Id to presentation thePrs */
+ CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
+ {
+ return myVisuGen->ApplyClippingPlane(thePrs, id);
+ }
+
+ CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
+ {
+ return myVisuGen->DetachClippingPlane(thePrs, id);
+ }
+
+ /* Get number of clipping planes */
+ CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
+ {
+ return myVisuGen->GetClippingPlanesNb();
+ }
};
virtual
VISU::ColoredPrs3dCache_ptr
GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy);
+
+
+
+ virtual CORBA::Long CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name);
+
+ virtual void EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name);
+
+ /* Returns clipping plane by its Id */
+ virtual VISU::ClippingPlane* GetClippingPlane(CORBA::Long id);
+
+ /* Deletes clipping plane by its Id */
+ virtual CORBA::Boolean DeleteClippingPlane(CORBA::Long id);
+
+ /* Applyes a clipping plane with Id to presentation thePrs */
+ virtual CORBA::Boolean ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id);
+
+ /* Detaches a clipping plane with Id from presentation thePrs */
+ virtual CORBA::Boolean DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id);
+
+ /* Get number of clipping planes */
+ virtual CORBA::Long GetClippingPlanesNb();
};
};
#include <VISU_ColoredPrs3dCache_i.hh>
+#include <VISU_Gen_i.hh>
+#include <VISU_ColoredPrs3dHolder_i.hh>
+
#include <LightApp_Application.h>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <SVTK_ViewWindow.h>
#include <VTKViewer_Utilities.h>
+
+
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
-#define SIZEFACTOR 1.5
+#define SIZEFACTOR 1.1
#define PRINT3(MARK, VAL) printf("#### %s x=%f, y=%f, z=%f\n", MARK, VAL[0], VAL[1], VAL[2]);
//****************************************************************
-PreviewPlane::PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds):
+//PreviewPlane::PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds):
+PreviewPlane::PreviewPlane(SVTK_ViewWindow* theWindow,
+ VISU_CutPlaneFunction* thePlane,
+ const double* theBounds):
myWindow(theWindow),
myBounds(theBounds)
{
AdjustBounds(myBounds, aBound, aCenter);
- myPlane = thePlane.plane;
+ //myPlane = thePlane.plane;
+ myPlane = thePlane;
myBox = vtkImageData::New();
myBox->SetDimensions(2, 2, 2);
//****************************************************************
//****************************************************************
//****************************************************************
-CutPlaneFunction* CutPlaneFunction::New()
+/*CutPlaneFunction* CutPlaneFunction::New()
{
return new CutPlaneFunction();
}
CutPlaneFunction::~CutPlaneFunction()
{
}
-
+*/
//****************************************************************
return aList;
}
+//*************************************************************************
+VISU_ClippingPlaneMgr& VisuGUI_ClippingPanel::getPlanesMgr() const
+{
+ return VISU::GetVisuGen(myModule)->GetClippingPlaneMgr();
+}
+
//*************************************************************************
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));
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ for (int i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(i);
+ myPlanesList->insertRow(i);
+ QTableWidgetItem* aItem = new QTableWidgetItem(aPlane->getName().c_str());
+ QTableWidgetItem* aCheckItem = new QTableWidgetItem();
+ aCheckItem->setCheckState((myNonActivePlanes->checkState() == Qt::Checked)?
+ Qt::Unchecked : Qt::Checked);
+ if (aPlane->isAuto()) { // If this is Auto plane
+ aItem->setFlags(0);
+ aItem->setCheckState(Qt::Checked);
+ } else { // if it is not auto
+ aItem->setCheckState(Qt::Unchecked);
+ // Check current presentation
+ int aPrsNum = myPrsList->currentRow();
+ if (aPrsNum >= 0) {
+ if (VISU_ClippingPlaneMgr::ContainsPlane(getPrs(myPresentations.at(aPrsNum)), aPlane))
+ aItem->setCheckState(Qt::Checked);
+ }
+ }
+ myPlanesList->setItem(i, 0, aItem);
+ myPlanesList->setItem(i, 1, aCheckItem);
+ }
+ myPlanesList->setHorizontalHeaderLabels(QString(tr("PLANES_TABLE_TITLES")).split(","));
+ if (myViewWindow)
+ myViewWindow->Repaint();
+ //myPlanes.clear();
+ /*_PTR(Study) aStudy = VISU::GetCStudy(VISU::GetAppStudy(myModule));
_PTR(SObject) aFolder;
if (VISU::getClippingPlanesFolder(aStudy, aFolder)) {
_PTR(ChildIterator) aIter = aStudy->NewChildIterator(aFolder);
}
myPlanesList->setHorizontalHeaderLabels(QString(tr("PLANES_TABLE_TITLES")).split(","));
if (myViewWindow)
- myViewWindow->Repaint();
+ myViewWindow->Repaint();*/
connect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
}
void VisuGUI_ClippingPanel::onPresentationCreate(VISU::Prs3d_i* thePrs)
{
myPrsList->addItem(getPrsName(thePrs));
- myPresentations.append(thePrs->GetEntry().c_str());
- for (int i = 0; i < myPlanes.size(); i++) {
+ string aEntry = thePrs->GetEntry();
+ if (aEntry.length() == 0) {
+ VISU::ColoredPrs3d_i* aColPrs = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs);
+ if (aColPrs)
+ aEntry = aColPrs->GetHolderEntry();
+ }
+
+ myPresentations.append(aEntry.c_str());
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ for (int i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(i);
+ if (aPlane->isAuto())
+ aMgr.ApplyClippingPlane(thePrs, i);
+ }
+ /* 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 VisuGUI_ClippingPanel::createEmptyPlane()
{
PlaneDef aPlane;
aPlane.name = QString("Plane");
aPlane.plane->SetNormal(0.,0.,1.);
aPlane.isAuto = true;
return aPlane;
-}
+}*/
//*************************************************************************
-void VisuGUI_ClippingPanel::updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane)
+/*void VisuGUI_ClippingPanel::updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane)
{
thePlane.name = QString(theObject->GetName().c_str());
thePlane.plane->setPlaneObject(theObject);
_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()));
disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
- _PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj();
+ //_PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj();
+ int aId = myPlaneDlg->planeId();
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
- PlaneDef aNewPlane = createEmptyPlane();
- updatePlane(aPlaneSObj, aNewPlane);
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(aId);
+ //PlaneDef aNewPlane = createEmptyPlane();
+ //updatePlane(aPlaneSObj, aNewPlane);
int aRow = myPlanesList->rowCount();
myPlanesList->insertRow(aRow);
- QTableWidgetItem* aItem = new QTableWidgetItem(aNewPlane.name);
+ //QTableWidgetItem* aItem = new QTableWidgetItem(aNewPlane.name);
+ QTableWidgetItem* aItem = new QTableWidgetItem(aPlane->getName().c_str());
QTableWidgetItem* aCheckItem = new QTableWidgetItem();
- aCheckItem->setCheckState((myNonActivePlanes->checkState() == Qt::Checked)? Qt::Unchecked : Qt::Checked);
- aNewPlane.plane->setActive(myNonActivePlanes->checkState() != Qt::Checked);
- if (aNewPlane.isAuto) {
+ aCheckItem->setCheckState((myNonActivePlanes->checkState() == Qt::Checked)?
+ Qt::Unchecked : Qt::Checked);
+ //aNewPlane.plane->setActive(myNonActivePlanes->checkState() != Qt::Checked);
+ aPlane->setActive(myNonActivePlanes->checkState() != Qt::Checked);
+ //if (aNewPlane.isAuto) {
+ if (aPlane->isAuto()) {
aItem->setFlags(0);
aItem->setCheckState(Qt::Checked);
- for (int i = 0; i < myPresentations.size(); i++) {
- getPrs(myPresentations.at(i))->AddClippingPlane(aNewPlane.plane);
- }
+// for (int i = 0; i < myPresentations.size(); i++) {
+// getPrs(myPresentations.at(i))->AddClippingPlane(aNewPlane.plane);
+// }
} else {
aItem->setCheckState(Qt::Unchecked);
}
myPlanesList->setItem(aRow, 0, aItem);
myPlanesList->setItem(aRow, 1, aCheckItem);
- myPlanes.append(aNewPlane);
+ //myPlanes.append(aNewPlane);
delete myPlaneDlg;
myPlaneDlg = 0;
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) {
+ //_PTR(SObject) aPlaneSObj = myPlaneDlg->getPlaneObj();
+
+ int aId = myPlaneDlg->planeId();
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(aId);
+ // PlaneDef aPlane = myPlanes.at(myEditingPlanePos);
+ //updatePlane(aPlaneSObj, aPlane);
+
+ //QTableWidgetItem* aItem = myPlanesList->item(myEditingPlanePos, 0);
+ QTableWidgetItem* aItem = myPlanesList->item(aId, 0);
+ // if (aPlane.isAuto) {
+ 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);
+// _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(getPrs(myPresentations.at(aPrsNum)), aPlane))
+ if (VISU_ClippingPlaneMgr::ContainsPlane(getPrs(myPresentations.at(aPrsNum)), aPlane))
aItem->setCheckState(Qt::Checked);
}
}
- aItem->setText(aPlane.name);
delete myPlaneDlg;
myPlaneDlg = 0;
- myPlanes.replace(myEditingPlanePos, aPlane);
+ //myPlanes.replace(myEditingPlanePos, aPlane);
setPlanesVisible(myShowPlanes->checkState() == Qt::Checked);
if (myViewWindow)
int aRow = myPlanesList->currentRow();
if (aRow < 0) return;
- const PlaneDef& aPlane = myPlanes.at(aRow);
+ // const PlaneDef& aPlane = myPlanes.at(aRow);
myPlaneDlg = new VisuGUI_ClippingPlaneDlg(myModule);
- myPlaneDlg->setPlaneObj(aPlane.plane->getPlaneObject());
+ //myPlaneDlg->setPlaneObj(aPlane.plane->getPlaneObject());
+ myPlaneDlg->setPlaneId(aRow);
connect(myPlaneDlg, SIGNAL(accepted()), this, SLOT(onPlaneEdited()));
connect(myPlaneDlg, SIGNAL(rejected()), this, SLOT(onCancelDialog()));
- myEditingPlanePos = aRow;
+ //myEditingPlanePos = aRow;
myPlaneDlg->show();
}
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);
+ // const PlaneDef& aPlane = myPlanes.at(aRow);
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(aRow);
+ QMessageBox::StandardButton aRes =
+ QMessageBox::warning(VISU::GetDesktop(myModule),
+ tr("TIT_DELETE_PLANE"),
+ tr("MSG_DELETE_PLANE").arg(aPlane->getName().c_str()),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No);
if (aRes == QMessageBox::Yes) {
- short aTag1 = aPlane.plane->getPlaneObject()->Tag();
+ aMgr.DeleteClippingPlane(aRow);
+ /* short aTag1 = aPlane.plane->getPlaneObject()->Tag();
for (int i = 0; i < myPresentations.size(); i++) {
VISU::Prs3d_i* aPrs = getPrs(myPresentations.at(i));
for (int j = aPrs->GetNumberOfClippingPlanes()-1; j > -1; j--) {
_PTR(SObject) aSObj = aPlane.plane->getPlaneObject();
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
aBuilder->RemoveObject(aSObj);
-
+ */
myPlanesList->removeRow(aRow);
- myPlanes.removeAt(aRow);
+ //myPlanes.removeAt(aRow);
VISU::UpdateObjBrowser(myModule);
{
if (myIsApplied) return;
- PlaneDef aPlane;
+ //PlaneDef aPlane;
int i;
- for(i = 0; i < myPlanes.size(); i++) {
- aPlane = myPlanes.at(i);
- aPlane.plane->setActive((myPlanesList->item(i, 1)->checkState() == Qt::Checked));
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ for (i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
+ aMgr.GetClippingPlane(i)->setActive((myPlanesList->item(i, 1)->checkState() == Qt::Checked));
}
+// for(i = 0; i < myPlanes.size(); i++) {
+// aPlane = myPlanes.at(i);
+// aPlane.plane->setActive((myPlanesList->item(i, 1)->checkState() == Qt::Checked));
+// }
myIsApplied = true;
int aPrsNum = myPrsList->currentRow();
if (aPrsNum > -1) {
- for(i = 0; i < myPlanes.size(); i++) {
+ // for(i = 0; i < myPlanes.size(); i++) {
+ for(i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
applyPlaneToPrs(i, aPrsNum, (myPlanesList->item(i, 0)->checkState() == Qt::Checked));
}
//myCheckedPlanes.clear();
//*************************************************************************
void VisuGUI_ClippingPanel::setPlanesNonActive(bool theState)
{
- PlaneDef aPlane;
+ //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);
+ //for (int i = 0; i < myPlanes.size(); i++) {
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ VISU_CutPlaneFunction* aPlane = 0;
+ for (int i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
+ //aPlane = myPlanes.at(i);
+ aPlane = aMgr.GetClippingPlane(i);
+ //aPlane.plane->setActive(!theState);
+ aPlane->setActive(!theState);
myPlanesList->item(i, 1)->setCheckState((theState)? Qt::Unchecked : Qt::Checked);
}
if (myViewWindow)
double aBounds[6];
ComputeVisiblePropBounds(myViewWindow->getRenderer(), aBounds);
- for (int i = 0; i < myPlanes.size(); i++) {
- PreviewPlane* aPreview = new PreviewPlane(myViewWindow, myPlanes.at(i), aBounds);
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ //for (int i = 0; i < myPlanes.size(); i++) {
+ for (int i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
+ //PreviewPlane* aPreview = new PreviewPlane(myViewWindow, myPlanes.at(i), aBounds);
+ PreviewPlane* aPreview = new PreviewPlane(myViewWindow, aMgr.GetClippingPlane(i), aBounds);
aPreview->setVisible(true);
myPreview.append(aPreview);
}
//*************************************************************************
void VisuGUI_ClippingPanel::onCellChanged(int row, int col)
{
- PlaneDef aPlane = myPlanes.at(row);
+ //PlaneDef aPlane = myPlanes.at(row);
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(row);
bool isChecked = (myPlanesList->item(row, col)->checkState() == Qt::Checked);
if (col == 1) { // activate column clicked
if (isAutoApply())
- aPlane.plane->setActive(isChecked);
+ //aPlane.plane->setActive(isChecked);
+ aPlane->setActive(isChecked);
else {
myIsApplied = false;
return;
}
} else { // Plane checked
- if (aPlane.isAuto) return;
+ //if (aPlane.isAuto) return;
+ if (aPlane->isAuto()) return;
if (!isAutoApply()) {
//myCheckedPlanes.append(row);
//*************************************************************************
void VisuGUI_ClippingPanel::applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool isChecked)
{
- PlaneDef aPlane = myPlanes.at(thePlaneNum);
+ VISU::Prs3d_i* aPrs = getPrs(myPresentations.at(thePrsNum));
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ if (isChecked) { // Apply
+ aMgr.ApplyClippingPlane(aPrs, thePlaneNum);
+ } else { // Detach
+ aMgr.DetachClippingPlane(aPrs, thePlaneNum);
+ }
+ /* PlaneDef aPlane = myPlanes.at(thePlaneNum);
_PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
VISU::Prs3d_i* aPrs = getPrs(myPresentations.at(thePrsNum));
}
}
}
- }
+ }*/
}
//*************************************************************************
-bool VisuGUI_ClippingPanel::containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane)
+/*bool VisuGUI_ClippingPanel::containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane)
{
//bool isContains = false;
for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) {
}
}
return false;
-}
+}*/
//*************************************************************************
void VisuGUI_ClippingPanel::onPrsSelected(int thePrs)
{
if (thePrs < 0) return;
+ if (thePrs > myPresentations.size()) return;
disconnect(myPlanesList, SIGNAL(cellChanged(int,int)), this, SLOT(onCellChanged(int,int)));
VISU::Prs3d_i* aPrs = getPrs(myPresentations.at(thePrs));
- QListOfPlanes::const_iterator aIt;
- int i = 0;
- for (aIt = myPlanes.begin(), i = 0; aIt != myPlanes.end(); ++aIt, i++) {
+ if (!aPrs) return;
+ //QListOfPlanes::const_iterator aIt;
+ VISU_ClippingPlaneMgr& aMgr = getPlanesMgr();
+ for (int i = 0; i < aMgr.GetClippingPlanesNb(); i++) {
+ QTableWidgetItem* aItem = myPlanesList->item(i, 0);
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(i);
+ if (!aPlane->isAuto())
+ aItem->setCheckState(VISU_ClippingPlaneMgr::ContainsPlane(aPrs, aPlane)?
+ Qt::Checked : Qt::Unchecked);
+ }
+ /* 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)));
}
#include "VISU_Prs3d_i.hh"
#include "VisuGUI_Panel.h"
//#include <VisuGUI_SegmentationMgr.h>
+#include <VISU_ClippingPlaneMgr.hxx>
#include <QList>
#include <vtkActor.h>
#include <SALOMEDSClient_SObject.hxx>
-class CutPlaneFunction: public vtkPlane
+
+/*class CutPlaneFunction: public vtkPlane
{
public:
static CutPlaneFunction* New();
bool isAuto;
QString name;
};
-
+*/
class PreviewPlane
{
public:
- PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds);
+ //PreviewPlane(SVTK_ViewWindow* theWindow, const PlaneDef& thePlane, const double* theBounds);
+ PreviewPlane(SVTK_ViewWindow* theWindow, VISU_CutPlaneFunction* thePlane, const double* theBounds);
~PreviewPlane();
void setVisible(bool theVisible)
};
-typedef QList<PlaneDef> QListOfPlanes;
+//typedef QList<PlaneDef> QListOfPlanes;
typedef QList<vtkPlane*> ListOfvtkPlanes;
typedef QList<PreviewPlane*> ListOfPreview;
bool isAutoApply() const;
+ VISU_ClippingPlaneMgr& getPlanesMgr() const;
+
- void updatePlane(_PTR(SObject) theObject, PlaneDef& thePlane);
- PlaneDef createEmptyPlane();
- static bool containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane);
+ //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);
QCheckBox* myNonActivePlanes;
QCheckBox* myAutoApply;
- QListOfPlanes myPlanes;
+ //QListOfPlanes myPlanes;
// QList<VISU::Prs3d_i*> myPresentations;
QStringList myPresentations; // Stores entries of presentation objects
ListOfPreview myPreview;
VisuGUI_ClippingPlaneDlg* myPlaneDlg;
- int myEditingPlanePos;
+ //int myEditingPlanePos;
SVTK_ViewWindow* myViewWindow;
bool myIsApplied;
//QList<int> myCheckedPlanes;
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include <VISU_Gen_i.hh>
+
#include <LightApp_Application.h>
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#include <vtkImplicitPlaneWidget.h>
-#define SIZEFACTOR 1.5
+#define SIZEFACTOR 1.1
myModule(theModule),
myCallback( vtkCallbackCommand::New() ),
myPreviewWidget(0),
- myViewWindow(0)
+ myViewWindow(0),
+ myPlaneId(-1)
{
myViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
ComputeVisiblePropBounds(myViewWindow->getRenderer(), myBounds);
//****************************************************************
-void VisuGUI_ClippingPlaneDlg::setPlaneObj(_PTR(SObject) thePlaneObj)
+void VisuGUI_ClippingPlaneDlg::setPlaneId(int theId)
+{
+ myPlaneId = theId;
+ VISU_ClippingPlaneMgr& aMgr = VISU::GetVisuGen(myModule)->GetClippingPlaneMgr();
+
+ VISU_CutPlaneFunction* aPlane = aMgr.GetClippingPlane(myPlaneId);
+ if (aPlane) {
+ myNameEdt->setText(QString(aPlane->getName().c_str()));
+ double aOrigin[3], aDir[3];
+ aPlane->GetOrigin(aOrigin);
+ aPlane->GetNormal(aDir);
+
+ myXOrigin->setValue(aOrigin[0]);
+ myYOrigin->setValue(aOrigin[1]);
+ myZOrigin->setValue(aOrigin[2]);
+ myPreviewWidget->SetOrigin(aOrigin);
+
+ myXDir->setValue(aDir[0]);
+ myYDir->setValue(aDir[1]);
+ myZDir->setValue(aDir[2]);
+
+ myPreviewWidget->SetNormal(aDir);
+
+ myAutoApply->setCheckState((aPlane->isAuto())? Qt::Checked : Qt::Unchecked);
+ myViewWindow->Repaint();
+ }
+}
+/*void VisuGUI_ClippingPlaneDlg::setPlaneObj(_PTR(SObject) thePlaneObj)
{
myPlaneObj = thePlaneObj;
}
myViewWindow->Repaint();
-}
+}*/
//****************************************************************
void VisuGUI_ClippingPlaneDlg::accept()
{
_PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
+ if(!aStudy->GetProperties()->IsLocked()) {
+ VISU_ClippingPlaneMgr& aMgr = VISU::GetVisuGen(myModule)->GetClippingPlaneMgr();
+ if (myPlaneId == -1) { // Create a New plane
+ myPlaneId = aMgr.CreateClippingPlane(myXOrigin->value(), myYOrigin->value(), myZOrigin->value(),
+ myXDir->value(), myYDir->value(), myZDir->value(),
+ myAutoApply->checkState() == Qt::Checked,
+ qPrintable(myNameEdt->text()));
+ } else { // Edit Plane
+ aMgr.EditClippingPlane(myPlaneId,
+ myXOrigin->value(), myYOrigin->value(), myZOrigin->value(),
+ myXDir->value(), myYDir->value(), myZDir->value(),
+ myAutoApply->checkState() == Qt::Checked,
+ qPrintable(myNameEdt->text()));
+ }
+ VISU::UpdateObjBrowser(myModule);
+ }
+ /* _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
if(!aStudy->GetProperties()->IsLocked()) {
_PTR(SObject) aFolder;
if (VISU::getClippingPlanesFolder(aStudy, aFolder)) {
VISU::UpdateObjBrowser(myModule);
}
- }
+ }*/
QDialog::accept();
}
void setOrigin(double theVal[3]);
void setDirection(double theVal[3]);
- void setPlaneObj(_PTR(SObject) thePlaneObj);
- _PTR(SObject) getPlaneObj() const { return myPlaneObj; }
+ void setPlaneId(int theId);
+ int planeId() const { return myPlaneId; }
+ //void setPlaneObj(_PTR(SObject) thePlaneObj);
+ //_PTR(SObject) getPlaneObj() const { return myPlaneObj; }
protected slots:
virtual void accept();
void onValueChanged();
private:
- void setEmptyPlane(PlaneDef& thePlane) const;
+ //void setEmptyPlane(PlaneDef& thePlane) const;
vtkImplicitPlaneWidget* createPreviewWidget();
vtkSmartPointer<vtkCallbackCommand> myCallback;
double myBounds[6];
- _PTR(SObject) myPlaneObj;
+ //_PTR(SObject) myPlaneObj;
+ int myPlaneId;
};
#endif
VISU_TimeAnimation.h \
VISU_ScalarMapOnDeformedShape_i.hh \
VISU_ColoredPrs3dFactory.hh \
- SALOME_GenericObjPointer.hh
+ SALOME_GenericObjPointer.hh \
+ VISU_ClippingPlaneMgr.hxx
libVISUEngineImpl_la_SOURCES = \
VISUConfig.cc \
VISU_View_i.cc \
VISU_Table_i.cc \
VISU_DumpPython.cc \
- SALOME_GenericObjPointer.cc
+ SALOME_GenericObjPointer.cc \
+ VISU_ClippingPlaneMgr.cxx
MOC_FILES = VISU_TimeAnimation_moc.cxx
nodist_libVISUEngineImpl_la_SOURCES= $(MOC_FILES)
--- /dev/null
+// Copyright (C) 2003 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 "VISU_ClippingPlaneMgr.hxx"
+#include "VISU_ColoredPrs3dHolder_i.hh"
+
+//#include CORBA_SERVER_HEADER(SALOMEDS)
+//#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDSClient_GenericAttribute.hxx"
+#include "SALOMEDSClient_AttributeName.hxx"
+#include "SALOMEDSClient_AttributeSequenceOfReal.hxx"
+#include "SALOMEDSClient_AttributeInteger.hxx"
+
+
+#include <vtkImplicitFunctionCollection.h>
+
+
+#define CLIP_PLANES_FOLDER "Clipping Planes"
+
+
+//*************************************************************
+VISU_ClippingPlaneMgr::VISU_ClippingPlaneMgr()
+{
+ myPlanes = vtkImplicitFunctionCollection::New();
+}
+
+//*************************************************************
+VISU_ClippingPlaneMgr::~VISU_ClippingPlaneMgr()
+{
+ myPlanes->Delete();
+}
+
+//*************************************************************
+void VISU_ClippingPlaneMgr::SetStudy(_PTR(Study) theStudy)
+{
+ myStudy = theStudy;
+ myPlanes->RemoveAllItems();
+ _PTR(SObject) aFolder = GetClippingPlanesFolder(false);
+ if (aFolder) {
+ _PTR(ChildIterator) aIter = myStudy->NewChildIterator(aFolder);
+ int i;
+ for (i = 0; aIter->More(); aIter->Next(), i++) { // For each plane
+ _PTR(SObject) aSObject = aIter->Value();
+ VISU_CutPlaneFunction* aPlane = VISU_CutPlaneFunction::New();
+ aPlane->setPlaneObject(aSObject);
+ aPlane->setName(aSObject->GetName());
+
+ _PTR(GenericAttribute) anAttr;
+ if (aSObject->FindAttribute(anAttr, "AttributeSequenceOfReal")) {
+ _PTR(AttributeSequenceOfReal) aArray(anAttr);
+ aPlane->SetOrigin(aArray->Value(1), aArray->Value(2), aArray->Value(3));
+ aPlane->SetNormal(aArray->Value(4), aArray->Value(5), aArray->Value(6));
+ }
+ if (aSObject->FindAttribute(anAttr, "AttributeInteger")) {
+ _PTR(AttributeInteger) aFlag(anAttr);
+ aPlane->setAuto(aFlag->Value() == 1);
+ } else
+ aPlane->setAuto(false);
+
+ applyPlaneToAll(aPlane);
+ myPlanes->AddItem(aPlane);
+ }
+ }
+}
+
+
+void VISU_ClippingPlaneMgr::applyPlaneToAll(VISU_CutPlaneFunction* thePlane)
+{
+ _PTR(SComponent) aVisuSO = myStudy->FindComponent("VISU");
+ _PTR(ChildIterator) aChildIter = myStudy->NewChildIterator(aVisuSO);
+ for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
+ _PTR(SObject) aSObject = aChildIter->Value();
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+ if(VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in())) {
+ VISU::Prs3d_i* aPrs;
+ if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
+ CORBA::Object_var anObject = aBase->_this();
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ VISU::Prs3d_var aPrs3d = aHolder->GetDevice();
+ aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
+ } else {
+ aPrs = dynamic_cast<VISU::Prs3d_i*>(aBase);
+ }
+ if (aPrs) {
+ if (!ContainsPlane(aPrs, thePlane)) {
+ if (thePlane->isAuto())
+ aPrs->AddClippingPlane(thePlane);
+ else {
+ string aPrsEntry = aPrs->GetEntry();
+ if (aPrsEntry.length() == 0) {
+ VISU::ColoredPrs3d_i* aColPrs = dynamic_cast<VISU::ColoredPrs3d_i*>(aPrs);
+ if (aColPrs)
+ aPrsEntry = aColPrs->GetHolderEntry();
+ }
+
+ _PTR(SObject) aSObject = thePlane->getPlaneObject();
+ _PTR(ChildIterator) aRefIter = myStudy->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 (aRefPrsObject->GetID() == aPrsEntry) {
+ aPrs->AddClippingPlane(thePlane);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//*************************************************************
+long VISU_ClippingPlaneMgr::CreateClippingPlane(double X,double Y, double Z,
+ double dX, double dY, double dZ,
+ bool isAuto, const char* name)
+{
+ _PTR(SObject) aObjPtr = CreateClippingPlaneObject(X, Y, Z, dX, dY, dZ, isAuto, name);
+ return myPlanes->GetNumberOfItems() - 1;
+}
+
+
+//*************************************************************
+_PTR(SObject) VISU_ClippingPlaneMgr::CreateClippingPlaneObject(double X,double Y, double Z,
+ double dX, double dY, double dZ,
+ bool isAuto, const char* name)
+{
+ _PTR(SObject) aPlaneObj;
+ if(!myStudy->GetProperties()->IsLocked()) {
+ _PTR(SObject) aFolder = GetClippingPlanesFolder(true);
+ if (aFolder) {
+ _PTR(StudyBuilder) aBuilder = myStudy->NewBuilder();
+ aPlaneObj = aBuilder->NewObject(aFolder);
+
+ // Save Name
+ _PTR(GenericAttribute) anAttr;
+ anAttr = aBuilder->FindOrCreateAttribute(aPlaneObj,"AttributeName");
+ _PTR(AttributeName) aName(anAttr);
+ aName->SetValue(name);
+
+ //Save Parameters
+ double aParams[6];
+ aParams[0] = X;
+ aParams[1] = Y;
+ aParams[2] = Z;
+ aParams[3] = dX;
+ aParams[4] = dY;
+ aParams[5] = dZ;
+
+ anAttr = aBuilder->FindOrCreateAttribute(aPlaneObj,"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(aPlaneObj,"AttributeInteger");
+ _PTR(AttributeInteger) aFlag(anAttr);
+ aFlag->SetValue(isAuto? 1 : 0);
+
+ vtkSmartPointer<VISU_CutPlaneFunction> aPlane = VISU_CutPlaneFunction::New();
+ aPlane->Delete(); //vtkSmartPointer specific
+ aPlane->setPlaneObject(aPlaneObj);
+ aPlane->SetOrigin(X, Y, Z);
+ aPlane->SetNormal(dX, dY, dZ);
+ aPlane->setName(name);
+ aPlane->setAuto(isAuto);
+ applyPlaneToAll(aPlane);
+ myPlanes->AddItem(aPlane.GetPointer());
+ }
+ }
+ return aPlaneObj;
+}
+
+
+//*************************************************************
+void VISU_ClippingPlaneMgr::EditClippingPlane(long id, double X,double Y, double Z,
+ double dX, double dY, double dZ,
+ bool isAuto, const char* name)
+{
+ VISU_CutPlaneFunction* aPlane = GetClippingPlane(id);
+ if (aPlane != NULL) {
+ _PTR(SObject) aSObj = aPlane->getPlaneObject();
+ aPlane->SetOrigin(X, Y, Z);
+ aPlane->SetNormal(dX, dY, dZ);
+ aPlane->setName(name);
+ aPlane->setAuto(isAuto);
+
+ if(!myStudy->GetProperties()->IsLocked()) {
+ _PTR(GenericAttribute) anAttr;
+ if (aSObj->FindAttribute(anAttr, "AttributeSequenceOfReal")) {
+ _PTR(AttributeSequenceOfReal) aArray(anAttr);
+ aArray->ChangeValue(1, X);
+ aArray->ChangeValue(2, Y);
+ aArray->ChangeValue(3, Z);
+ aArray->ChangeValue(4, dX);
+ aArray->ChangeValue(5, dY);
+ aArray->ChangeValue(6, dZ);
+ }
+ if (aSObj->FindAttribute(anAttr, "AttributeInteger")) {
+ _PTR(AttributeInteger) aFlag(anAttr);
+ aFlag->SetValue(isAuto? 1 : 0);
+ }
+ if (aSObj->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName(anAttr);
+ aName->SetValue(name);
+ }
+ // Remove references on presentations if it becomes Auto plane
+ _PTR(SObject) aPlaneSObj = aPlane->getPlaneObject();
+ if (aPlane->isAuto()) {
+ _PTR(ChildIterator) aIter = myStudy->NewChildIterator(aPlaneSObj);
+ _PTR(StudyBuilder) aBuilder = myStudy->NewBuilder();
+ for (; aIter->More(); aIter->Next()) {
+ _PTR(SObject) aObj = aIter->Value();
+ aBuilder->RemoveObject(aObj);
+ }
+ }
+ }
+ }
+}
+
+
+
+//*************************************************************
+ /* Returns clipping plane by its Id */
+VISU_CutPlaneFunction* VISU_ClippingPlaneMgr::GetClippingPlane(long id)
+{
+ if ((id < 0) || (id >= GetClippingPlanesNb()))
+ return NULL;
+ return (VISU_CutPlaneFunction*) myPlanes->GetItemAsObject(id);
+}
+
+//*************************************************************
+ /* Deletes clipping plane by its Id */
+bool VISU_ClippingPlaneMgr::DeleteClippingPlane(long id)
+{
+ _PTR(SObject) aFolder = GetClippingPlanesFolder(false);
+ if (aFolder) {
+ VISU_CutPlaneFunction* aPlane = GetClippingPlane(id);
+ if (aPlane != NULL) {
+ _PTR(SComponent) aVisuSO = myStudy->FindComponent("VISU");
+ _PTR(ChildIterator) aChildIter = myStudy->NewChildIterator(aVisuSO);
+ for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
+ _PTR(SObject) aSObject = aChildIter->Value();
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+ if(VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in())) {
+ VISU::Prs3d_i* aPrs;
+ if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
+ CORBA::Object_var anObject = aBase->_this();
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
+ VISU::Prs3d_var aPrs3d = aHolder->GetDevice();
+ aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
+ } else
+ aPrs = dynamic_cast<VISU::Prs3d_i*>(aBase);
+
+ if (aPrs) {
+ if (ContainsPlane(aPrs, aPlane)) {
+ short aTag1 = aPlane->getPlaneObject()->Tag();
+ for (int j = aPrs->GetNumberOfClippingPlanes()-1; j > -1; j--) {
+ VISU_CutPlaneFunction* aPln = dynamic_cast<VISU_CutPlaneFunction*>
+ (aPrs->GetClippingPlane(j));
+ if (aPln) {
+ short aTag2 = aPln->getPlaneObject()->Tag();
+ if (aTag1 == aTag2) {
+ aPrs->RemoveClippingPlane(j);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ _PTR(SObject) aSObj = aPlane->getPlaneObject();
+ if (aSObj) {
+ _PTR(StudyBuilder) aBuilder = myStudy->NewBuilder();
+ aBuilder->RemoveObject(aSObj);
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+//*************************************************************
+bool VISU_ClippingPlaneMgr::ContainsPlane(VISU::Prs3d_ptr thePrs, VISU_CutPlaneFunction* thePlane)
+{
+ VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
+ return ContainsPlane(aPrs, thePlane);
+}
+
+//*************************************************************
+bool VISU_ClippingPlaneMgr::ContainsPlane(VISU::Prs3d_i* thePrs, VISU_CutPlaneFunction* thePlane)
+{
+ VISU::Prs3d_i* aPrs = thePrs;
+ if (thePrs->GetType() == VISU::TCOLOREDPRS3DHOLDER) {
+ VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast<VISU::ColoredPrs3dHolder_i*>(thePrs);
+ if (!aHolder) return false;
+ aPrs = aHolder->GetPrs3dDevice();
+ }
+ string aEntry = thePlane->getPlaneObject()->GetID();
+ for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) {
+ VISU_CutPlaneFunction* aPlane = dynamic_cast<VISU_CutPlaneFunction*>(thePrs->GetClippingPlane(i));
+ if (aPlane) {
+ if (aPlane->getPlaneObject()->GetID() == aEntry) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
+//*************************************************************
+ /* Applyes a clipping plane with Id to presentation thePrs */
+bool VISU_ClippingPlaneMgr::ApplyClippingPlane(VISU::Prs3d_i* thePrs, long id)
+{
+ //VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
+ if (!thePrs) return false;
+
+ VISU_CutPlaneFunction* aPlane = GetClippingPlane(id);
+ if (!aPlane) return false;
+ if (!ContainsPlane(thePrs, aPlane)) {
+ thePrs->AddClippingPlane(aPlane);
+ if (!aPlane->isAuto()) {
+ string aEntry = thePrs->GetEntry();
+ if (aEntry.length() == 0) {
+ VISU::ColoredPrs3d_i* aColPrs = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs);
+ if (aColPrs)
+ aEntry = aColPrs->GetHolderEntry();
+ }
+ if(!myStudy->GetProperties()->IsLocked()) {
+ _PTR(StudyBuilder) aBuilder = myStudy->NewBuilder();
+ _PTR(SObject) aPrsSObj = myStudy->FindObjectID(aEntry);
+ _PTR(SObject) aSObject = aPlane->getPlaneObject();
+ _PTR(SObject) aNewObj = aBuilder->NewObject(aSObject);
+ aBuilder->Addreference(aNewObj, aPrsSObj);
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+//*************************************************************
+bool VISU_ClippingPlaneMgr::DetachClippingPlane(VISU::Prs3d_i* thePrs, long id)
+{
+ VISU_CutPlaneFunction* aPlane = GetClippingPlane(id);
+ //VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
+ if (aPlane && thePrs) {
+ if (ContainsPlane(thePrs, aPlane)) {
+ bool isRemoved = false;
+ short aTag1 = aPlane->getPlaneObject()->Tag();
+ for (int j = thePrs->GetNumberOfClippingPlanes()-1; j > -1; j--) {
+ VISU_CutPlaneFunction* aPln = dynamic_cast<VISU_CutPlaneFunction*>
+ (thePrs->GetClippingPlane(j));
+ if (aPln) {
+ short aTag2 = aPln->getPlaneObject()->Tag();
+ if (aTag1 == aTag2) {
+ thePrs->RemoveClippingPlane(j);
+ isRemoved = true;
+ break;
+ }
+ }
+ }
+ if(!myStudy->GetProperties()->IsLocked()) {
+ _PTR(SObject) aSObject = aPlane->getPlaneObject();
+ _PTR(StudyBuilder) aBuilder = myStudy->NewBuilder();
+
+ string aEntry = thePrs->GetEntry();
+ if (aEntry.length() == 0) {
+ VISU::ColoredPrs3d_i* aColPrs = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs);
+ if (aColPrs)
+ aEntry = aColPrs->GetHolderEntry();
+ }
+ _PTR(ChildIterator) aIter = myStudy->NewChildIterator(aSObject);
+ for (; aIter->More(); aIter->Next()) {
+ _PTR(SObject) aRefObj = aIter->Value();
+ if(aRefObj) {
+ _PTR(SObject) aRefPrsObject;
+ if (aRefObj->ReferencedObject(aRefPrsObject)) {
+ if (aRefPrsObject->GetID() == aEntry) {
+ aBuilder->RemoveObject(aRefObj);
+ break;
+ }
+ }
+ }
+ }
+ }
+ return isRemoved;
+ }
+ }
+ return false;
+}
+
+
+//*************************************************************
+ /* Get number of clipping planes */
+long VISU_ClippingPlaneMgr::GetClippingPlanesNb()
+{
+ return myPlanes->GetNumberOfItems();
+}
+
+
+//*************************************************************
+_PTR(SObject) VISU_ClippingPlaneMgr::GetClippingPlanesFolder(bool toCreate)
+{
+ _PTR(SObject) aFolder;
+ _PTR(SComponent) aVisuSO = myStudy->FindComponent("VISU");
+ if (!aVisuSO) return aFolder;
+
+ aFolder = myStudy->FindObject(CLIP_PLANES_FOLDER);
+ if (!aFolder && toCreate) {
+ _PTR(StudyBuilder) aBuilder = myStudy->NewBuilder();
+ aFolder = aBuilder->NewObject(aVisuSO);
+
+ _PTR(GenericAttribute) anAttr;
+ anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName");
+ _PTR(AttributeName) aName(anAttr);
+ aName->SetValue(CLIP_PLANES_FOLDER);
+ }
+ return aFolder;
+}
+
+
+
+
+//****************************************************************
+//****************************************************************
+//****************************************************************
+VISU_CutPlaneFunction* VISU_CutPlaneFunction::New()
+{
+ return new VISU_CutPlaneFunction();
+}
+
+void VISU_CutPlaneFunction::setActive(bool theActive)
+{
+ myIsActive = theActive;
+ Modified();
+}
+
+double VISU_CutPlaneFunction::EvaluateFunction(double x[3])
+{
+ if (myIsActive)
+ return vtkPlane::EvaluateFunction(x);
+ else
+ return -1;
+}
+
+double VISU_CutPlaneFunction::EvaluateFunction(double x, double y, double z)
+{
+ if (myIsActive)
+ return vtkPlane::EvaluateFunction(x,y,z);
+ else
+ return -1;
+}
+
+VISU_CutPlaneFunction::VISU_CutPlaneFunction():
+ myIsActive(true)
+{
+
+}
+
+VISU_CutPlaneFunction::~VISU_CutPlaneFunction()
+{
+}
+
--- /dev/null
+
+// VISU OBJECT : interactive object for VISU entities implementation
+//
+// Copyright (C) 2003 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
+//
+//
+// File : VISU_ClippingPlaneMgr.hxx
+// Author : VSV
+// Module : VISU
+
+
+#ifndef _VISU_ClippingPlane_H_
+#define _VISU_ClippingPlane_H_
+
+#include "VISU_I.hxx"
+#include "VISUConfig.hh"
+#include "SALOME_Component_i.hxx"
+#include "VISU_ColoredPrs3d_i.hh"
+
+#include <vtkPlane.h>
+#include <string>
+
+class vtkImplicitFunctionCollection;
+
+
+class VISU_CutPlaneFunction: public vtkPlane
+{
+public:
+ static VISU_CutPlaneFunction* New();
+
+ vtkTypeMacro(VISU_CutPlaneFunction, vtkPlane);
+
+ virtual double EvaluateFunction(double x[3]);
+ virtual double EvaluateFunction(double x, double y, double z);
+
+ void setActive(bool theActive);
+ bool isActive() const { return myIsActive; }
+
+ void setPlaneObject(_PTR(SObject) aSOPlane) { mySObject = aSOPlane; }
+ _PTR(SObject) getPlaneObject() const { return mySObject; }
+
+ void setName(string theName) { myName = theName; }
+ string getName() const { return myName; }
+
+ void setAuto(bool isAuto) { myIsAuto = isAuto; }
+ bool isAuto() const { return myIsAuto; }
+
+protected:
+ VISU_CutPlaneFunction();
+ ~VISU_CutPlaneFunction();
+
+private:
+ bool myIsActive;
+ _PTR(SObject) mySObject;
+ string myName;
+ bool myIsAuto;
+};
+
+
+
+class VISU_ClippingPlaneMgr {
+public:
+ VISU_ClippingPlaneMgr();
+ ~VISU_ClippingPlaneMgr();
+
+ void SetStudy(_PTR(Study) theStudy);
+
+
+ long CreateClippingPlane(double X,double Y, double Z,
+ double dX, double dY, double dZ,
+ bool isAuto, const char* name);
+
+ void EditClippingPlane(long id, double X,double Y, double Z,
+ double dX, double dY, double dZ,
+ bool isAuto, const char* name);
+
+ _PTR(SObject) CreateClippingPlaneObject(double X,double Y, double Z,
+ double dX, double dY, double dZ,
+ bool isAuto, const char* name);
+
+ /* Returns clipping plane by its Id */
+ VISU_CutPlaneFunction* GetClippingPlane(long id);
+
+ /* Deletes clipping plane by its Id */
+ bool DeleteClippingPlane(long id);
+
+ /* Applyes a clipping plane with Id to presentation thePrs */
+ bool ApplyClippingPlane(VISU::Prs3d_i* thePrs, long id);
+
+ bool DetachClippingPlane(VISU::Prs3d_i* thePrs, long id);
+
+ /* Get number of clipping planes */
+ long GetClippingPlanesNb();
+
+ _PTR(SObject) GetClippingPlanesFolder(bool toCreate);
+
+ static bool ContainsPlane(VISU::Prs3d_ptr thePrs, VISU_CutPlaneFunction* thePlane);
+ static bool ContainsPlane(VISU::Prs3d_i* thePrs, VISU_CutPlaneFunction* thePlane);
+
+ vtkImplicitFunctionCollection* GetPlanesList() const { return myPlanes; }
+
+
+private:
+ void applyPlaneToAll(VISU_CutPlaneFunction* thePlane);
+
+
+ _PTR(Study) myStudy;
+
+ vtkImplicitFunctionCollection* myPlanes;
+};
+
+#endif
CORBA::String_var aStudyName = aListOfOpenStudies[0];
//aFileInfo.setFile(aStudyName.in());
myStudyDocument = aStudyManager->GetStudyByName(aStudyName/*aFileInfo.baseName()*/);
+ myClippingPlaneMgr.SetStudy(GetStudy(myStudyDocument));
}else
if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!");
}
std::string aStudyName (aName.in());
if(MYDEBUG) MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'");
myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
+ myClippingPlaneMgr.SetStudy(GetStudy(myStudyDocument));
ProcessVoidEvent(new TEvent(aStudyName));
{
return ColoredPrs3dCache_i::GetInstance(theStudy);
}
+
+
+ CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name)
+ {
+ return myClippingPlaneMgr.CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
+ }
+
+
+ void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name)
+ {
+ myClippingPlaneMgr.EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
+ }
+
+ /* Returns clipping plane by its Id */
+ VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
+ {
+ VISU_CutPlaneFunction* aPlane = myClippingPlaneMgr.GetClippingPlane(id);
+
+ if (aPlane != NULL) {
+ double aOrigin[3];
+ double aDir[3];
+ aPlane->GetOrigin(aOrigin);
+ aPlane->GetNormal(aDir);
+
+ VISU::ClippingPlane* aRetPlane = new VISU::ClippingPlane;
+ aRetPlane->X = aOrigin[0];
+ aRetPlane->Y = aOrigin[1];
+ aRetPlane->Z = aOrigin[2];
+ aRetPlane->dX = aDir[0];
+ aRetPlane->dY = aDir[1];
+ aRetPlane->dZ = aDir[2];
+ aRetPlane->isAuto = aPlane->isAuto();
+
+ aRetPlane->name = aPlane->getName().c_str();
+ return aRetPlane;
+ }
+ return NULL;
+ }
+
+ /* Deletes clipping plane by its Id */
+ CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
+ {
+ return myClippingPlaneMgr.DeleteClippingPlane(id);
+ }
+
+ /* Applyes a clipping plane with Id to presentation thePrs */
+ CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
+ {
+ VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
+ return myClippingPlaneMgr.ApplyClippingPlane(aPrs, id);
+ }
+
+ /* Detaches a clipping plane with Id from presentation thePrs */
+ CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
+ {
+ VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
+ return myClippingPlaneMgr.DetachClippingPlane(aPrs, id);
+ }
+
+ /* Get number of clipping planes */
+ CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
+ {
+ return myClippingPlaneMgr.GetClippingPlanesNb();
+ }
+
+
}
#include "SALOME_Component_i.hxx"
#include "SALOME_NamingService.hxx"
#include "VISU_ColoredPrs3d_i.hh"
+#include "VISU_ClippingPlaneMgr.hxx"
#include <string>
public virtual Base_i
{
SALOMEDS::Study_var myStudyDocument;
+ VISU_ClippingPlaneMgr myClippingPlaneMgr;
+
VISU_Gen_i(const VISU::VISU_Gen_i &);
public:
VISU_Gen_i(CORBA::ORB_ptr theORB,
virtual
VISU::ColoredPrs3dCache_ptr
GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy);
+
+
+ virtual CORBA::Long CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name);
+
+ virtual void EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
+ CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
+ CORBA::Boolean isAuto, const char* name);
+
+ /* Returns clipping plane by its Id */
+ virtual VISU::ClippingPlane* GetClippingPlane(CORBA::Long id);
+
+ /* Deletes clipping plane by its Id */
+ virtual CORBA::Boolean DeleteClippingPlane(CORBA::Long id);
+
+ /* Applyes a clipping plane with Id to presentation thePrs */
+ virtual CORBA::Boolean ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id);
+
+ /* Detaches a clipping plane with Id from presentation thePrs */
+ virtual CORBA::Boolean DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id);
+
+ /* Get number of clipping planes */
+ virtual CORBA::Long GetClippingPlanesNb();
+
+ VISU_ClippingPlaneMgr& GetClippingPlaneMgr() { return myClippingPlaneMgr; }
+
};
}