]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
*** empty log message ***
authorvsv <vsv@opencascade.com>
Wed, 17 Sep 2008 14:40:37 +0000 (14:40 +0000)
committervsv <vsv@opencascade.com>
Wed, 17 Sep 2008 14:40:37 +0000 (14:40 +0000)
src/VISUGUI/VisuGUI_ClippingPanel.cxx

index 60bcbaf5203df6eb5f810d2aca81950d340d7527..eb3536f3135c71e982469487009ea8125a5d6ae3 100644 (file)
@@ -25,6 +25,8 @@
 #include "VisuGUI_ClippingPlaneDlg.h"
 #include "VisuGUI_ViewTools.h"
 
+#include <VISU_ColoredPrs3dCache_i.hh>
+
 #include <LightApp_Application.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_Session.h>
@@ -286,9 +288,20 @@ void VisuGUI_ClippingPanel::fillPrsList()
     return;
   }
   myPresentations = getPrsList(aStudy, aVisuSO);
+
+  //Process Cache system folder
+  _PTR(SObject) aSObjPtr = aStudy->FindObject(VISU::ColoredPrs3dCache_i::GetFolderName().c_str());
+  if (aSObjPtr) {
+    _PTR(ChildIterator) Iter = aStudy->NewChildIterator( aSObjPtr );
+    for ( ; Iter->More(); Iter->Next() ) {
+      _PTR(SObject) aChildObj = Iter->Value();
+      myPresentations.append(aChildObj->GetID().c_str());
+    }
+  }
+
   QStringList aNames;
   for (int i = 0; i < myPresentations.size(); i++) {
-    aNames.append(getPrsName(myPresentations.at(i)));
+    aNames.append(getPrsName(getPrs(myPresentations.at(i))));
   }
   myPrsList->addItems(aNames);
 }
@@ -333,25 +346,28 @@ QString VisuGUI_ClippingPanel::getPrsName(VISU::Prs3d_i* thePrs)
 }
 
 //*************************************************************************
-QList<VISU::Prs3d_i*> VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy, 
-                                                              _PTR(SObject) theObject)
+QStringList VisuGUI_ClippingPanel::getPrsList(_PTR(Study) theStudy, 
+                                             _PTR(SObject) theObject)
 {
-  QList<VISU::Prs3d_i*> aList;
+  //QList<VISU::Prs3d_i*> aList;
+  QStringList aList;
   _PTR(ChildIterator) aIter = theStudy->NewChildIterator(theObject);
   for (aIter->InitEx(true); aIter->More(); aIter->Next()) {
     _PTR(SObject) aSObject = aIter->Value();
     std::vector<VISU::Prs3d_i*> aSTLList = VISU::GetPrs3dList(myModule, aSObject);
     for (int i = 0; i < aSTLList.size(); i++) {
       VISU::Prs3d_i* aPrs = aSTLList[i];
-      if (!aList.contains(aPrs))
-       aList.append(aPrs);
+      if (!aList.contains(aPrs->GetEntry().c_str()))
+       aList.append(aPrs->GetEntry().c_str());
     }
     if (aList.size() == 0) {
-      QList<VISU::Prs3d_i*> aSubList = getPrsList(theStudy, aSObject);
+      //QList<VISU::Prs3d_i*> aSubList = getPrsList(theStudy, aSObject);
+      QStringList aSubList = getPrsList(theStudy, aSObject);
        for (int i = 0; i < aSubList.size(); i++) {
-       VISU::Prs3d_i* aPrs = aSubList[i];
-       if (!aList.contains(aPrs))
-         aList.append(aSubList[i]);
+        //VISU::Prs3d_i* aPrs = aSubList[i];
+       QString aPrsEntry = aSubList[i];
+       if (!aList.contains(aPrsEntry))
+         aList.append(aPrsEntry);
       }
     }
   }
@@ -383,18 +399,18 @@ void VisuGUI_ClippingPanel::fillPlanesList()
        aItem->setFlags(0);
        // apply to all presentations
        aItem->setCheckState(Qt::Checked);
-       foreach(VISU::Prs3d_i* aPrs, myPresentations) {
-         aPrs->AddClippingPlane(aNewPlane.plane);
+       foreach(QString aPrsEntry, myPresentations) {
+         getPrs(aPrsEntry)->AddClippingPlane(aNewPlane.plane);
        }
       } else { // if it is not auto
-       foreach(VISU::Prs3d_i* aPrs, myPresentations) {
+       foreach(QString aPrsEntry, 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);
+             if (QString(aRefPrsObject->GetID().c_str()) == aPrsEntry) {
+               getPrs(aPrsEntry)->AddClippingPlane(aNewPlane.plane);
              }
            }
          }
@@ -403,7 +419,7 @@ void VisuGUI_ClippingPanel::fillPlanesList()
        // Check current presentation
        int aPrsNum = myPrsList->currentRow();
        if (aPrsNum >= 0) {
-         if (containsPlane(myPresentations.at(aPrsNum), aNewPlane))
+         if (containsPlane(getPrs(myPresentations.at(aPrsNum)), aNewPlane))
            aItem->setCheckState(Qt::Checked);
        }
       }
@@ -452,8 +468,9 @@ void VisuGUI_ClippingPanel::onWindowDestroyed(QObject* theWnd)
 //*************************************************************************
 void VisuGUI_ClippingPanel::onPresentationCreate(VISU::Prs3d_i* thePrs)
 {
+  printf("#### onPresentationCreate PrsNb = %i\n", myPresentations.size());
   myPrsList->addItem(getPrsName(thePrs));
-  myPresentations.append(thePrs);
+  myPresentations.append(thePrs->GetEntry().c_str());
   for (int i = 0; i < myPlanes.size(); i++) {
     const PlaneDef& aPlane = myPlanes.at(i);
     if (aPlane.isAuto)
@@ -513,7 +530,7 @@ void VisuGUI_ClippingPanel::onNewPlane()
     aItem->setFlags(0);
     aItem->setCheckState(Qt::Checked);
     for (int i = 0; i < myPresentations.size(); i++) {
-      myPresentations.at(i)->AddClippingPlane(aNewPlane.plane);
+      getPrs(myPresentations.at(i))->AddClippingPlane(aNewPlane.plane);
     }
   } else {
     aItem->setCheckState(Qt::Unchecked);
@@ -559,7 +576,7 @@ void VisuGUI_ClippingPanel::onPlaneEdited()
     aItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
     int aPrsNum = myPrsList->currentRow();
     if (aPrsNum >= 0) {
-      if (containsPlane(myPresentations.at(aPrsNum), aPlane))
+      if (containsPlane(getPrs(myPresentations.at(aPrsNum)), aPlane))
        aItem->setCheckState(Qt::Checked);
     }
   }
@@ -629,7 +646,7 @@ void VisuGUI_ClippingPanel::onPlaneDelete()
   if (aRes == QMessageBox::Yes) {
     short aTag1 = aPlane.plane->getPlaneObject()->Tag();
     for (int i = 0; i < myPresentations.size(); i++) {
-      VISU::Prs3d_i* aPrs = myPresentations.at(i);
+      VISU::Prs3d_i* aPrs = getPrs(myPresentations.at(i));
       for (int j = aPrs->GetNumberOfClippingPlanes()-1; j > -1; j--) {
        CutPlaneFunction* aPln = dynamic_cast<CutPlaneFunction*>(aPrs->GetClippingPlane(j));
        if (aPln) {
@@ -792,7 +809,7 @@ void VisuGUI_ClippingPanel::applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool
   PlaneDef aPlane = myPlanes.at(thePlaneNum);
   _PTR(Study) aStudy = VISU::GetCStudy( VISU::GetAppStudy( myModule ) );
   _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
-  VISU::Prs3d_i* aPrs = myPresentations.at(thePrsNum);
+  VISU::Prs3d_i* aPrs = getPrs(myPresentations.at(thePrsNum));
   _PTR(SObject) aSObject = aPlane.plane->getPlaneObject();
   _PTR(SObject) aPrsSObj = aStudy->FindObjectID(aPrs->GetEntry());
   if (isChecked) {
@@ -832,7 +849,7 @@ void VisuGUI_ClippingPanel::applyPlaneToPrs(int thePlaneNum, int thePrsNum, bool
 //*************************************************************************
 bool VisuGUI_ClippingPanel::containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef& thePlane)
 {
-  bool isContains = false;
+  //bool isContains = false;
   for (int i = 0; i < thePrs->GetNumberOfClippingPlanes(); i++) {
     if (thePrs->GetClippingPlane(i) == thePlane.plane.GetPointer()) {
       return true;
@@ -845,16 +862,20 @@ bool VisuGUI_ClippingPanel::containsPlane(VISU::Prs3d_i* thePrs, const PlaneDef&
 //*************************************************************************
 void VisuGUI_ClippingPanel::onObjectDelete(QString theEntry)
 {
+  printf("#### onObjectDelete PrsSize = %i\n", myPresentations.size());
   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;
+  foreach (QString aPrsEntry, myPresentations) {
+    VISU::Prs3d_i* aPrs = getPrs(aPrsEntry);
+    if (aPrs) {
+      QString aID(aPrs->GetEntry().c_str());
+      if (aID == theEntry) {
+       myPresentations.removeAt(i);
+       myPrsList->takeItem(i);
+       break;
+      }
+      i++;
     }
-    i++;
   }
   connect(myPrsList, SIGNAL(currentRowChanged(int)), this, SLOT(onPrsSelected(int)));
   onPrsSelected(myPrsList->currentRow());
@@ -865,7 +886,7 @@ 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);
+  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++) {
@@ -884,6 +905,15 @@ bool VisuGUI_ClippingPanel::isAutoApply() const
 }
 
 
+//*************************************************************************
+VISU::Prs3d_i* VisuGUI_ClippingPanel::getPrs(QString theEntry)
+{
+  VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(VISU::GetAppStudy(myModule), 
+                                                         qPrintable(theEntry));
+  return VISU::GetPrs3dFromBase(anObjectInfo.myBase);
+}
+
+
 //*************************************************************************
 void VisuGUI_ClippingPanel::onHelp()
 {