Salome HOME
Issue #2210: Object Browser : new show / hide button
authorvsv <vsv@opencascade.com>
Tue, 27 Jun 2017 13:16:32 +0000 (16:16 +0300)
committervsv <vsv@opencascade.com>
Tue, 27 Jun 2017 13:16:32 +0000 (16:16 +0300)
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_DataModel.cpp
src/XGUI/XGUI_DataModel.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/eyeclosed.png [new file with mode: 0644]
src/XGUI/pictures/eyemiclosed.png [new file with mode: 0644]
src/XGUI/pictures/eyeopen.png [new file with mode: 0644]

index bd88803878d9e0690addcc0f7c83764a1388ce5e..a9845e2a57c3f542750a8a1681dd008eaf3fea68 100755 (executable)
@@ -1263,7 +1263,7 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
       aTreeView->setExpanded(myActivePartIndex, false);
 
     XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
-    myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
+    myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
     bool needUpdate = false;
     if (myActivePartIndex.isValid()) {
       needUpdate = aTreeView->isExpanded(myActivePartIndex);
@@ -1335,7 +1335,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex)
     //aMgr->setActiveDocument(aMgr->moduleDocument());
     return;
   }
-  if (theIndex.column() != 0) // Use only first column
+  if (theIndex.column() != 1) // Use only first column
     return;
 
   XGUI_Workshop* aWorkshop = getWorkshop();
index 47c1be475e771f287436cfff9e7e07312f45a41b..e7f6c5f55d9ff66a6a2774b6b2f4197d7a85f6b2 100644 (file)
@@ -724,7 +724,7 @@ void XGUI_ContextMenuMgr::addFeatures(QMenu* theMenu) const
   bool aIsRoot = false;
   foreach(QModelIndex aIdx, aSelectedIndexes) {
     // Process only first column
-    if (aIdx.column() == 0) {
+    if (aIdx.column() == 1) {
       aIsRoot = !aIdx.parent().isValid();
       // Exit if the selected index belongs to non active document
       if (aIsRoot && (aActiveDoc != aMgr->moduleDocument()))
index 30cf4e574342ab50ac1d7090115d3cf5c5f71b15..196957cc5f871da697a783a2a8074f3697645cf9 100644 (file)
@@ -19,6 +19,9 @@
 //
 
 #include "XGUI_DataModel.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ObjectsBrowser.h"
+#include "XGUI_Displayer.h"
 
 #include <ModuleBase_IconFactory.h>
 
@@ -81,6 +84,9 @@ ModelAPI_Document* getSubDocument(void* theObj)
 XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent)//,
   //myIsEventsProcessingBlocked(false)
 {
+  XGUI_ObjectsBrowser* aOB = qobject_cast<XGUI_ObjectsBrowser*>(theParent);
+  myWorkshop = aOB->workshop();
+
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED));
@@ -136,7 +142,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
           } else {
             int aFolderId = myXMLReader->rootFolderId(aObjType);
             if (aFolderId != -1) {
-              insertRow(aRow, createIndex(aFolderId, 0, (void*)Q_NULLPTR));
+              insertRow(aRow, createIndex(aFolderId, 1, (void*)Q_NULLPTR));
             }
           }
         }
@@ -162,7 +168,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
               if (aRow != -1) {
                 int aFolderId = folderId(aObjType, aDoc.get());
                 if (aFolderId != -1) {
-                  QModelIndex aParentFolder = createIndex(aFolderId, 0, aDoc.get());
+                  QModelIndex aParentFolder = createIndex(aFolderId, 1, aDoc.get());
                   insertRow(aRow, aParentFolder);
                   emit dataChanged(aParentFolder, aParentFolder);
                 }
@@ -210,7 +216,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
           // Process root sub-folder
           int aFolderId = myXMLReader->rootFolderId(aGroup);
           if (aFolderId != -1) {
-            QModelIndex aFolderIndex = createIndex(aFolderId, 0, (void*)Q_NULLPTR);
+            QModelIndex aFolderIndex = createIndex(aFolderId, 1, (void*)Q_NULLPTR);
             removeRow(aRow, aFolderIndex);
             //rebuildBranch(0, aRow);
           }
@@ -239,7 +245,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
             // List of objects under a folder
             int aFolderId = folderId(aGroup, aDoc.get());
             if (aFolderId != -1) {
-              QModelIndex aFolderRoot = createIndex(aFolderId, 0, aDoc.get());
+              QModelIndex aFolderRoot = createIndex(aFolderId, 1, aDoc.get());
               removeRow(aRow, aFolderRoot);
               //rebuildBranch(0, aRow, aFolderRoot);
             }
@@ -303,7 +309,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
         if (aGroup == myXMLReader->rootType()) // Update objects under root
           aStartId = foldersCount();
         else // Update objects in folder under root
-          aParent = createIndex(folderId(aGroup), 0, (void*)Q_NULLPTR);
+          aParent = createIndex(folderId(aGroup), 1, (void*)Q_NULLPTR);
       } else {
         // Update a sub-document
         if (aGroup == myXMLReader->subType()) {
@@ -312,7 +318,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
           aStartId = foldersCount(aDoc.get());
         } else
           // update folder in sub-document
-          aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+          aParent = createIndex(folderId(aGroup, aDoc.get()), 1, aDoc.get());
       }
       int aChildNb = rowCount(aParent);
       rebuildBranch(aStartId, aChildNb - aStartId, aParent);
@@ -363,7 +369,7 @@ ObjectPtr XGUI_DataModel::object(const QModelIndex& theIndex) const
 }
 
 //******************************************************
-QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const
+QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject, int theColumn) const
 {
   std::string aType = theObject->groupName();
   DocumentPtr aDoc = theObject->document();
@@ -398,7 +404,7 @@ QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const
     if (aRow == -1)
       return QModelIndex();
     else
-      return createIndex(aRow, 0, theObject.get());
+      return createIndex(aRow, theColumn, theObject.get());
   }
   SessionPtr aSession = ModelAPI_Session::get();
   DocumentPtr aRootDoc = aSession->moduleDocument();
@@ -409,7 +415,7 @@ QModelIndex XGUI_DataModel::objectIndex(const ObjectPtr theObject) const
     // The object from sub document
     aRow += foldersCount(aDoc.get());
   }
-  return createIndex(aRow, 0, theObject.get());
+  return createIndex(aRow, theColumn, theObject.get());
 }
 
 //******************************************************
@@ -420,10 +426,26 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const
   int aNbFolders = foldersCount();
   int theIndexRow = theIndex.row();
 
-  if ((theRole == Qt::DecorationRole) && (theIndex == lastHistoryIndex()))
-    return QIcon(":pictures/arrow.png");
+  if (theRole == Qt::DecorationRole) {
+    if (theIndex == lastHistoryIndex())
+      return QIcon(":pictures/arrow.png");
+    else if (theIndex.column() == 0) {
+      VisibilityState aState = getVisibilityState(theIndex);
+      switch (aState) {
+      case NoneState:
+        return QIcon();
+      case Visible:
+        return QIcon(":pictures/eyeopen.png");
+      case SemiVisible:
+        return QIcon(":pictures/eyemiclosed.png");
+      case Hidden:
+        return QIcon(":pictures/eyeclosed.png");
+      }
+    }
+  }
 
-  if (theIndex.column() == 1)
+  //if (theIndex.column() == 1)
+  if (theIndex.column() != 1)
     return QVariant();
 
   quintptr aParentId = theIndex.internalId();
@@ -596,7 +618,7 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const
 //******************************************************
 int XGUI_DataModel::columnCount(const QModelIndex& theParent) const
 {
-  return 2;
+  return 3;
 }
 
 //******************************************************
@@ -616,7 +638,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
       int aObjId = theRow - aNbFolders;
       if (aObjId < aRootDoc->size(aType)) {
         ObjectPtr aObj = aRootDoc->object(aType, aObjId);
-        aIndex = objectIndex(aObj);
+        aIndex = objectIndex(aObj, theColumn);
       }
     }
   } else {
@@ -626,7 +648,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
       std::string aType = myXMLReader->rootFolderType(aParentPos);
       if (theRow < aRootDoc->size(aType)) {
         ObjectPtr aObj = aRootDoc->object(aType, theRow);
-        aIndex = objectIndex(aObj);
+        aIndex = objectIndex(aObj, theColumn);
       }
     } else {
       // It is an object which could have children
@@ -641,7 +663,7 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
           std::string aType = myXMLReader->subFolderType(aParentRow);
           if (theRow < aDoc->size(aType)) {
             ObjectPtr aObj = aDoc->object(aType, theRow);
-            aIndex = objectIndex(aObj);
+            aIndex = objectIndex(aObj, theColumn);
           }
         }
       } else {
@@ -659,24 +681,24 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
             // this is an object under sub document root
             std::string aType = myXMLReader->subType();
             ObjectPtr aObj = aSubDoc->object(aType, theRow - aNbSubFolders);
-            aIndex = objectIndex(aObj);
+            aIndex = objectIndex(aObj, theColumn);
           }
         } else {
           // Check for composite object
           ModelAPI_CompositeFeature* aCompFeature =
             dynamic_cast<ModelAPI_CompositeFeature*>(aParentObj);
           if (aCompFeature) {
-            aIndex = objectIndex(aCompFeature->subFeature(theRow));
+            aIndex = objectIndex(aCompFeature->subFeature(theRow), theColumn);
           } else {
             ModelAPI_ResultCompSolid* aCompRes =
               dynamic_cast<ModelAPI_ResultCompSolid*>(aParentObj);
             if (aCompRes)
-              aIndex = objectIndex(aCompRes->subResult(theRow));
+              aIndex = objectIndex(aCompRes->subResult(theRow), theColumn);
             else {
               ModelAPI_ResultField* aFieldRes =
                 dynamic_cast<ModelAPI_ResultField*>(aParentObj);
               if (aFieldRes) {
-                aIndex = createIndex(theRow, 0, aFieldRes->step(theRow));
+                aIndex = createIndex(theRow, theColumn, aFieldRes->step(theRow));
               }
             }
           }
@@ -684,8 +706,6 @@ QModelIndex XGUI_DataModel::index(int theRow, int theColumn, const QModelIndex &
       }
     }
   }
-  if (theColumn != 0)
-    return createIndex(aIndex.row(), theColumn, aIndex.internalPointer());
   return aIndex;
 }
 
@@ -754,7 +774,7 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const
         // return first level of folder index
         int aFolderId = myXMLReader->rootFolderId(aType);
         // Items in a one row must have the same parent
-        return createIndex(aFolderId, 0, (void*)Q_NULLPTR);
+        return createIndex(aFolderId, 1, (void*)Q_NULLPTR);
       }
     } else {
       if (aType == myXMLReader->subType())
@@ -763,7 +783,7 @@ QModelIndex XGUI_DataModel::parent(const QModelIndex& theIndex) const
         // return first level of folder index
         int aFolderId = folderId(aType, aSubDoc.get());
         // Items in a one row must have the same parent
-        return createIndex(aFolderId, 0, aSubDoc.get());
+        return createIndex(aFolderId, 1, aSubDoc.get());
       }
     }
   }
@@ -821,15 +841,15 @@ Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const
   if (aObj) {
     // An object
     if (aObj->isDisabled())
-      return theIndex.column() == 1? Qt::ItemIsSelectable : aNullFlag;
+      return theIndex.column() == 2? Qt::ItemIsSelectable : aNullFlag;
 
     if (aSession->moduleDocument() != aObj->document())
       if (aActiveDoc != aObj->document())
-        return theIndex.column() == 1? Qt::ItemIsSelectable : aNullFlag;
+        return theIndex.column() == 2? Qt::ItemIsSelectable : aNullFlag;
 
     bool isCompositeSub = false;
-    // An object which is sub-object of a composite object can not be accessible in column 1
-    if (theIndex.column() == 1) {
+    // An object which is sub-object of a composite object can not be accessible in column 2
+    if (theIndex.column() == 2) {
       ObjectPtr aObjPtr = aObj->data()->owner();
       FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObjPtr);
       if (aFeature.get()) {
@@ -866,7 +886,7 @@ Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const
 }
 
 //******************************************************
-QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDoc) const
+QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDoc, int aColumn) const
 {
   SessionPtr aSession = ModelAPI_Session::get();
   DocumentPtr aRootDoc = aSession->moduleDocument();
@@ -882,7 +902,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo
         if (myXMLReader->rootType() == ModelAPI_Feature::group()) {
           aRow += foldersCount();
         }
-        return createIndex(aRow, 0, aObj.get());
+        return createIndex(aRow, aColumn, aObj.get());
       }
     }
   } else { // If document is attached to feature
@@ -896,7 +916,7 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo
         int aRow = i;
         if (myXMLReader->rootType() == ModelAPI_Feature::group())
           aRow += foldersCount();
-        return createIndex(aRow, 0, aObj.get());
+        return createIndex(aRow, aColumn, aObj.get());
       }
     }
   }
@@ -904,14 +924,14 @@ QModelIndex XGUI_DataModel::findDocumentRootIndex(const ModelAPI_Document* theDo
 }
 
 //******************************************************
-QModelIndex XGUI_DataModel::documentRootIndex(DocumentPtr theDoc) const
+QModelIndex XGUI_DataModel::documentRootIndex(DocumentPtr theDoc, int theColumn) const
 {
   SessionPtr aSession = ModelAPI_Session::get();
   DocumentPtr aRootDoc = aSession->moduleDocument();
   if (theDoc == aRootDoc)
     return QModelIndex();
   else
-    return findDocumentRootIndex(theDoc.get());
+    return findDocumentRootIndex(theDoc.get(), theColumn);
 }
 
 //******************************************************
@@ -994,12 +1014,12 @@ QModelIndex XGUI_DataModel::lastHistoryIndex() const
   FeaturePtr aFeature = aCurDoc->currentFeature(true);
   if (aFeature.get()) {
     QModelIndex aInd = objectIndex(aFeature);
-    return createIndex(aInd.row(), 1, aInd.internalPointer());
+    return createIndex(aInd.row(), 2, aInd.internalPointer());
   } else {
     if (aCurDoc == aSession->moduleDocument())
-      return createIndex(foldersCount() - 1, 1, -1);
+      return createIndex(foldersCount() - 1, 2, -1);
     else
-      return createIndex(foldersCount(aCurDoc.get()) - 1, 1, aCurDoc.get());
+      return createIndex(foldersCount(aCurDoc.get()) - 1, 2, aCurDoc.get());
   }
 }
 
@@ -1052,3 +1072,37 @@ void XGUI_DataModel::rebuildBranch(int theRow, int theCount, const QModelIndex&
 //  myIsEventsProcessingBlocked = theState;
 //  return aPreviousState;
 //}
+
+//******************************************************
+XGUI_DataModel::VisibilityState
+  XGUI_DataModel::getVisibilityState(const QModelIndex& theIndex) const
+{
+  ObjectPtr aObj = object(theIndex);
+  if (aObj.get()) {
+    ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+    if (aResObj.get()) {
+      XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+      ResultCompSolidPtr aCompRes = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(aResObj);
+      if (aCompRes.get()) {
+        VisibilityState aState = NoneState;
+        for (int i = 0; i < aCompRes->numberOfSubs(true); i++) {
+          ResultPtr aSubRes = aCompRes->subResult(i, true);
+          VisibilityState aS = aDisplayer->isVisible(aSubRes)? Visible : Hidden;
+          if (aState == NoneState)
+            aState = aS;
+          else if (aState != aS) {
+            aState = SemiVisible;
+            break;
+          }
+        }
+        return aState;
+      } else {
+        if (aDisplayer->isVisible(aResObj))
+          return Visible;
+        else
+          return Hidden;
+      }
+    }
+  }
+  return NoneState;
+}
index 39cbd3dc44589e748707fc5eb197bfb9e2d9e784..cbcb030daf645f294010ebc9c893ed1b9e48fc30 100644 (file)
@@ -30,6 +30,7 @@
 #include <QAbstractItemModel>
 
 class Config_DataModelReader;
+class XGUI_Workshop;
 
 /**\class XGUI_DataModel
  * \ingroup GUI
@@ -63,7 +64,7 @@ public:
 
   //! Returns index of the object
   //! \param theObject object to find
-  virtual QModelIndex objectIndex(const ObjectPtr theObject) const;
+  virtual QModelIndex objectIndex(const ObjectPtr theObject, int theColumn = 1) const;
 
   //! Clear internal data
   virtual void clear();
@@ -130,7 +131,7 @@ public:
 
   /// Returns an index which is root of the given document
   /// \param theDoc a document
-  QModelIndex documentRootIndex(DocumentPtr theDoc) const;
+  QModelIndex documentRootIndex(DocumentPtr theDoc, int theColumn = 1) const;
 
   /// Returns last history object index
   virtual QModelIndex lastHistoryIndex() const;
@@ -146,9 +147,15 @@ signals:
   void treeRebuilt();
 
 private:
+  enum VisibilityState {
+    NoneState,
+    Visible,
+    SemiVisible,
+    Hidden };
+
   /// Find a root index which contains objects of the given document
   /// \param theDoc the document object
-  QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc) const;
+  QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc, int aColumn = 1) const;
 
   /// Returns number of folders in document.
   /// Considered folders which has to be shown only if they are not empty.
@@ -171,13 +178,15 @@ private:
   /// \param theParent - index of parent folder
   void rebuildBranch(int theRow, int theCount, const QModelIndex& theParent = QModelIndex());
 
-
   /// Returns list of folders types which can not be shown empty
   /// \param fromRoot - root document flag
   QStringList listOfShowNotEmptyFolders(bool fromRoot = true) const;
 
+  VisibilityState getVisibilityState(const QModelIndex& theIndex) const;
+
   Config_DataModelReader* myXMLReader;
 
+  XGUI_Workshop* myWorkshop;
   //bool myIsEventsProcessingBlocked;
 };
 
index 101ab27fb1c1385cbc503134db093daab314ea61..5b86c1c0338802ccd92a85e420016d1b66dc3b49 100644 (file)
 #include <QStyledItemDelegate>
 #include <QMessageBox>
 
+#ifdef DEBUG_INDXES
+#include <QToolTip>
+#endif
 
 /// Width of second column (minimum acceptable = 27)
+#define FIRST_COL_WIDTH 30
 #define SECOND_COL_WIDTH 30
 
 
@@ -81,11 +85,12 @@ XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
     : QTreeView(theParent)
 {
   setHeaderHidden(true);
+  setTreePosition(1);
   setEditTriggers(QAbstractItemView::NoEditTriggers);
   setSelectionBehavior(QAbstractItemView::SelectRows);
   setSelectionMode(QAbstractItemView::ExtendedSelection);
 
-  setItemDelegateForColumn(0, new XGUI_TreeViewItemDelegate(this));
+  setItemDelegateForColumn(1, new XGUI_TreeViewItemDelegate(this));
 
   connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
     SLOT(onDoubleClick(const QModelIndex&)));
@@ -141,15 +146,44 @@ void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent)
   QTreeView::resizeEvent(theEvent);
   QSize aSize = theEvent->size();
   if (aSize.isValid()) {
-    setColumnWidth(0, aSize.width() - SECOND_COL_WIDTH - 7);
-    setColumnWidth(1, SECOND_COL_WIDTH);
+    setColumnWidth(0, FIRST_COL_WIDTH);
+    setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 12);
+    setColumnWidth(2, SECOND_COL_WIDTH);
   }
 }
 
-void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+#ifdef DEBUG_INDXES
+void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent)
 {
-  if (theIndex.column() != 1)
+  QTreeView::mousePressEvent(theEvent);
+  if (theEvent->button() != Qt::MidButton)
     return;
+  QModelIndex aInd = indexAt(theEvent->pos());
+  QString aTxt = QString("r=%1 c=%2 p=%3").arg(aInd.row()).arg(aInd.column()).arg((long)aInd.internalPointer());
+
+  QModelIndex aPar = aInd.parent();
+  QString aTxt1 = QString("r=%1 c=%2 p=%3").arg(aPar.row()).arg(aPar.column()).arg((long)aPar.internalPointer());
+  QToolTip::showText(theEvent->globalPos(), aTxt + '\n' + aTxt1);
+}
+#endif
+
+void XGUI_DataTree::mouseReleaseEvent(QMouseEvent* theEvent)
+{
+  QTreeView::mouseReleaseEvent(theEvent);
+#ifdef DEBUG_INDXES
+  if (theEvent->button() != Qt::MidButton)
+    return;
+  QToolTip::hideText();
+#endif
+  if (theEvent->button() == Qt::LeftButton) {
+    QModelIndex aInd = indexAt(theEvent->pos());
+    if (aInd.column() == 0)
+      processEyeClick(aInd);
+  }
+}
+
+void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex)
+{
   SessionPtr aMgr = ModelAPI_Session::get();
   // When operation is opened then we can not change history
   if (aMgr->isOperation())
@@ -187,6 +221,35 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
   for (int i = 0; i < aSize; i++) {
     update(aModel->index(i, 0, aParent));
     update(aModel->index(i, 1, aParent));
+    update(aModel->index(i, 2, aParent));
+  }
+}
+
+void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
+{
+  XGUI_DataModel* aModel = dataModel();
+  ObjectPtr aObj = aModel->object(theIndex);
+  if (aObj.get()) {
+    ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+    if (aResObj.get()) {
+      aResObj->setDisplayed(!aResObj->isDisplayed());
+      Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+      update(theIndex);
+    }
+    // Update list of selected objects because this event happens after selection event in object browser
+    XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+    if (aObjBrowser) {
+      aObjBrowser->onSelectionChanged();
+    }
+  }
+}
+
+void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+{
+  switch (theIndex.column()) {
+  case 2:
+    processHistoryChange(theIndex);
+    break;
   }
 }
 
@@ -289,8 +352,8 @@ void XGUI_ActiveDocLbl::unselect()
 //********************************************************************
 //********************************************************************
 //********************************************************************
-XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
-    : QWidget(theParent), myDocModel(0)
+XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop)
+    : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop)
 {
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
@@ -473,12 +536,20 @@ void XGUI_ObjectsBrowser::clearContent()
   myTreeView->clear();
 }
 
+//***************************************************
 void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
                                        const QItemSelection& theDeselected)
+{
+  onSelectionChanged();
+}
+
+//***************************************************
+void XGUI_ObjectsBrowser::onSelectionChanged()
 {
   emit selectionChanged();
 }
 
+//***************************************************
 QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) const
 {
   QObjectPtrList aList;
@@ -486,7 +557,7 @@ QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes)
   XGUI_DataModel* aModel = dataModel();
   QModelIndexList::const_iterator aIt;
   for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
-    if ((*aIt).column() == 0) {
+    if ((*aIt).column() == 1) {
       ObjectPtr aObject = aModel->object(*aIt);
       if (aObject) {
         aList.append(aObject);
@@ -517,7 +588,7 @@ std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
   QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
   int aNbChild = aModel->rowCount(aRootIdx);
   for (int i = 0; i < aNbChild; i++) {
-    QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
+    QModelIndex aIdx = aModel->index(i, 1, aRootIdx);
     aStates.push_back(myTreeView->isExpanded(aIdx));
   }
   return aStates;
index c1a9527bde13639ade41a9f18c05dfb6f2e4ca60..fd522c61a8dd253aaafc940fec2aadac2b942018 100644 (file)
@@ -34,6 +34,9 @@
 class ModuleBase_IDocumentDataModel;
 class XGUI_DataModel;
 class Config_DataModelReader;
+class XGUI_Workshop;
+
+//#define DEBUG_INDXES
 
 /**
 * \ingroup GUI
@@ -118,6 +121,22 @@ public slots:
 
    /// Redefinition of virtual method
   virtual void resizeEvent(QResizeEvent* theEvent);
+
+   /// Redefinition of virtual method
+  virtual void mouseReleaseEvent(QMouseEvent* theEvent);
+
+#ifdef DEBUG_INDXES
+  virtual void mousePressEvent(QMouseEvent* theEvent);
+#endif
+
+private:
+  /// Process a history change request
+  /// \param theIndex a clicked data index
+  void processHistoryChange(const QModelIndex& theIndex);
+
+  /// Process a visibility change request
+  /// \param theIndex a clicked data index
+  void processEyeClick(const QModelIndex& theIndex);
 };
 
 /**\class XGUI_ObjectsBrowser
@@ -130,7 +149,7 @@ Q_OBJECT
  public:
    /// Constructor
    /// \param theParent a parent widget
-  XGUI_ObjectsBrowser(QWidget* theParent);
+  XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop);
   virtual ~XGUI_ObjectsBrowser();
 
   //! Returns Model which provides access to data objects
@@ -182,6 +201,12 @@ Q_OBJECT
   /// \param theStates list of booleans with state expanded or not
   void setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates);
 
+  /// Returns current workshop
+  XGUI_Workshop* workshop() const { return myWorkshop; }
+
+  void onSelectionChanged();
+
+
 public slots:
   //! Called on Edit command request
   void onEditItem();
@@ -219,6 +244,7 @@ signals:
   XGUI_DataModel* myDocModel;
   XGUI_ActiveDocLbl* myActiveDocLbl;
   XGUI_DataTree* myTreeView;
+  XGUI_Workshop* myWorkshop;
 
   /// A field to store expanded items before model reset
   QModelIndexList myExpandedItems;
index 462359e0976930a15071f07b66ef740c351b3a27..2dee78840129e9e41210d04fdb4d4d69062c1723 100755 (executable)
@@ -1228,7 +1228,7 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
   aObjDock->setWindowTitle(tr("Object browser"));
   aObjDock->setStyleSheet(
       "::title { position: relative; padding-left: 5px; text-align: left center }");
-  myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
+  myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock, this);
   myObjectBrowser->setXMLReader(myDataModelXMLReader);
   myModule->customizeObjectBrowser(myObjectBrowser);
   aObjDock->setWidget(myObjectBrowser);
index 86cc1b28f73014dfab36d55da5bb68f971abe8d3..222dfd208af47fb5b1cf90f762e6f12026980708 100644 (file)
@@ -56,5 +56,9 @@
      <file>pictures/wire.png</file>
      <file>pictures/result.png</file>
      <file>pictures/find_result.png</file>
+
+     <file>pictures/eyeclosed.png</file>
+     <file>pictures/eyemiclosed.png</file>
+     <file>pictures/eyeopen.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/eyeclosed.png b/src/XGUI/pictures/eyeclosed.png
new file mode 100644 (file)
index 0000000..df57123
Binary files /dev/null and b/src/XGUI/pictures/eyeclosed.png differ
diff --git a/src/XGUI/pictures/eyemiclosed.png b/src/XGUI/pictures/eyemiclosed.png
new file mode 100644 (file)
index 0000000..e05e411
Binary files /dev/null and b/src/XGUI/pictures/eyemiclosed.png differ
diff --git a/src/XGUI/pictures/eyeopen.png b/src/XGUI/pictures/eyeopen.png
new file mode 100644 (file)
index 0000000..e578fe6
Binary files /dev/null and b/src/XGUI/pictures/eyeopen.png differ