DependencyTree.h
DependencyTree_Arrow.h
DependencyTree_Object.h
+ DependencyTree_Selector.h
)
# header files / to be processed by moc
DependencyTree_View.cxx
DependencyTree_Object.cxx
DependencyTree_Arrow.cxx
+ DependencyTree_Selector.cxx
#arrow.cxx
DependencyTree_ViewModel.cxx
${_moc_SOURCES}
#include <QtxActionToolMgr.h>
#include "DependencyTree_View.h"
+#include <DependencyTree_Selector.h>
+
#include <GraphicsView_Viewer.h>
#include <GraphicsView_ViewFrame.h>
#include <GraphicsView_Scene.h>
#include <SUIT_Session.h>
#include <SUIT_ViewManager.h>
+#include <SUIT_SelectionMgr.h>
#include <SalomeApp_Application.h>
+
#include <QList>
#include <QGraphicsView>
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;
+ LightApp_SelectionMgr* mySelMgr = app->selectionMgr();
+
SUIT_ViewManager *svm = app->getViewManager(GraphicsView_Viewer::Type(), false );
if(!svm) {
myView = new DependencyTree_View();
DependencyTree_ViewModel* ViewModel = new DependencyTree_ViewModel(GraphicsView_Viewer::Type(), myView);
SUIT_ViewManager *svm = app->createViewManager( ViewModel );
+ new DependencyTree_Selector( ViewModel,
+ ( SUIT_SelectionMgr*)mySelMgr );
SUIT_ViewWindow* svw = svm->getActiveView();
GraphicsView_ViewFrame* aViewFrame = 0;
if (!svw) svw = svm->createViewWindow();
--- /dev/null
+// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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 "DependencyTree_Selector.h"
+#include "DependencyTree_View.h"
+#include "DependencyTree_ViewModel.h"
+#include "DependencyTree_Object.h"
+
+// GUI includes
+#include <LightApp_DataOwner.h>
+
+//GEOM includes
+#include <GEOMBase.h>
+
+#include <iostream>
+
+DependencyTree_Selector::DependencyTree_Selector( DependencyTree_ViewModel* theModel, SUIT_SelectionMgr* theSelMgr )
+:LightApp_GVSelector( (GraphicsView_Viewer*)theModel, theSelMgr )
+{
+ myView = dynamic_cast<DependencyTree_View*>( theModel->getActiveViewPort() );
+}
+
+DependencyTree_Selector::~DependencyTree_Selector()
+{
+}
+
+//=================================================================================
+// function : getSelection()
+// purpose : get list of selected Data Owner objects.
+//=================================================================================
+void DependencyTree_Selector::getSelection( SUIT_DataOwnerPtrList& theList ) const
+{
+ for( myView->initSelected(); myView->moreSelected(); myView->nextSelected() )
+ if( DependencyTree_Object* treeObject = dynamic_cast<DependencyTree_Object*>( myView->selectedObject() ) ) {
+ const char* entry;
+ const char* name;
+ QString studyEntry = treeObject->getGeomObject()->GetStudyEntry();
+ if( studyEntry.isEmpty() ) {
+ entry = treeObject->getEntry().c_str();
+ name = "TEMP_IO_UNPUBLISHED";
+ }
+ else {
+ entry = studyEntry.toStdString().c_str();
+ name = "TEMP_IO";
+ }
+ Handle(SALOME_InteractiveObject) tmpIO =
+ new SALOME_InteractiveObject( entry, "GEOM", name);
+
+ theList.append( new LightApp_DataOwner( tmpIO ) );
+ }
+}
+
+//=================================================================================
+// function : setSelection()
+// purpose : set to selected list of Data Owner objects.
+//=================================================================================
+void DependencyTree_Selector::setSelection( const SUIT_DataOwnerPtrList& theList )
+{
+ myView->clearSelected();
+
+ for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it ) {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+ if ( owner )
+ if( !owner->IO().IsNull() ) {
+ const char* name = owner->IO()->getName();
+ const char* entry;
+ if( strcmp( owner->IO()->getComponentDataType(), "GEOM" ) != 0 )
+ return;
+
+ if( strcmp( name, "TEMP_IO_UNPUBLISHED" ) == 0 )
+ entry = owner->IO()->getEntry();
+ else {
+ GEOM::GEOM_Object_var geomObject = GEOMBase::ConvertIOinGEOMObject( owner->IO() );
+ if( geomObject->_is_nil() )
+ return;
+ entry = geomObject->GetEntry();
+ }
+ DependencyTree_Object* object = myView->getObjectByEntry( QString( entry ) );
+ if( object ) {
+ myView->setSelected( object );
+ object->select( object->pos().x(), object->pos().y(), object->getRect() );
+ }
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+
+#ifndef DEPENDENCYTREE_SELECTOR_H
+#define DEPENDENCYTREE_SELECTOR_H
+
+#include <LightApp_GVSelector.h>
+
+class DependencyTree_ViewModel;
+class DependencyTree_View;
+
+class DependencyTree_Selector: public LightApp_GVSelector
+{
+
+public:
+ DependencyTree_Selector( DependencyTree_ViewModel*, SUIT_SelectionMgr* );
+ ~DependencyTree_Selector();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+ DependencyTree_View* myView;
+
+};
+
+#endif
#include "DependencyTree_Object.h"
#include "DependencyTree_Arrow.h"
-#include <GEOM_InteractiveObject.hxx>
-#include <GeometryGUI.h>
#include <GEOMBase.h>
// GUI includes
mySelectionMgr = app->selectionMgr();
if ( !mySelectionMgr ) return;
+ myMainEntries = new GEOM::string_array();
+
getNewTreeModel();
}
connect( myHierarchyDepth, SIGNAL( valueChanged ( int ) ), this, SLOT( onHierarchyType() ) );
connect( myDisplayAscendants , SIGNAL( toggled( bool ) ), this, SLOT( onHierarchyType() ) );
connect( myDisplayDescendants, SIGNAL( toggled( bool ) ), this, SLOT( onHierarchyType() ) );
- connect( updateButton, SIGNAL( clicked() ), this, SLOT( onUpdateModel( false ) ) );
+ connect( updateButton, SIGNAL( clicked() ), this, SLOT( onUpdateModel() ) );
connect( cancelButton, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
setPrefBackgroundColor( resMgr->colorValue( "Geometry", "dependency_tree_background_color", QColor( 255, 255, 255 ) ) );
setHierarchyType( resMgr->integerValue( "Geometry", "dependency_tree_hierarchy_type", 0 ) );
}
-void DependencyTree_View::updateModel( bool getSelectedObjects )
+void DependencyTree_View::updateModel( bool theUseSelectedObject, bool theUseOB )
{
- getNewTreeModel( getSelectedObjects );
-
- SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
-
- setPrefBackgroundColor( resMgr->colorValue( "Geometry", "dependency_tree_background_color", QColor( 255, 255, 255 ) ) );
- setNodesMovable( resMgr->booleanValue( "Geometry", "dependency_tree_move_nodes", true ) );
- setHierarchyType( resMgr->integerValue( "Geometry", "dependency_tree_hierarchy_type", 0 ) );
+ getNewTreeModel( theUseSelectedObject, theUseOB );
+ onHierarchyType();
}
void DependencyTree_View::drawTree()
}
-int DependencyTree_View::select( const QRectF& theRect, bool theIsAppend )
-{
- GraphicsView_ViewPort::select( theRect, theIsAppend );
-
- mySelectionMgr->clearSelected();
-
- // get selection
- SALOME_ListIO listIO;
- int StudyId = myStudy->StudyId();
- for( initSelected(); moreSelected(); nextSelected() )
- if( DependencyTree_Object* treeObject = dynamic_cast<DependencyTree_Object*>( selectedObject() ) ) {
- CORBA::String_var studyEntry = treeObject->getGeomObject()->GetStudyEntry();
- Handle(SALOME_InteractiveObject) tmpIO =
- new SALOME_InteractiveObject( studyEntry.in(), "GEOM", "TEMP_IO");
- listIO.Append( tmpIO );
- }
- mySelectionMgr->setSelectedObjects( listIO, true );
-}
-
void DependencyTree_View::customEvent( QEvent * event )
{
if( event->type() == DRAW_EVENT ) {
}
}
+DependencyTree_Object* DependencyTree_View::getObjectByEntry( QString theEntry )
+{
+ return myTreeMap[theEntry.toStdString()];
+}
+
void DependencyTree_View::setHierarchyType( const int theType )
{
myIsUpdate = false;
event->accept();
}
-void DependencyTree_View::onUpdateModel( bool getSelectedObjects )
+void DependencyTree_View::onUpdateModel()
+{
+ updateModel( false );
+}
+
+void DependencyTree_View::onRebuildModel()
{
- updateModel( getSelectedObjects );
+ updateModel( true, false );
}
void DependencyTree_View::updateView()
}
}
-void DependencyTree_View::getNewTreeModel( bool getSelectedObjects )
+void DependencyTree_View::getNewTreeModel( bool theUseSelectedObject, bool theUseOB )
{
- clearView( true );
- if( getSelectedObjects )
- mySelectionMgr->selectedObjects( myMainObjects );
-
- // create a list of selected object entry
GEOM::string_array_var objectsEntry = new GEOM::string_array();
- objectsEntry->length( myMainObjects.Extent());
int iter = 0;
- for ( SALOME_ListIteratorOfListIO It( myMainObjects ); It.More(); It.Next(), iter++ ) {
- Handle( SALOME_InteractiveObject ) io = It.Value();
- GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil();
- geomObject = GEOMBase::ConvertIOinGEOMObject( io );
- QString entry = geomObject->GetEntry();
- objectsEntry[ iter ] = entry.toLatin1().constData();
+
+ if( theUseSelectedObject ) {
+ if( theUseOB ) {
+ SALOME_ListIO mainObjects;
+ mySelectionMgr->selectedObjects( mainObjects );
+ // create a list of selected object entry
+ objectsEntry->length( mainObjects.Extent());
+ for ( SALOME_ListIteratorOfListIO It( mainObjects ); It.More(); It.Next(), iter++ ) {
+ Handle( SALOME_InteractiveObject ) io = It.Value();
+ GEOM::GEOM_Object_var geomObject = GEOM::GEOM_Object::_nil();
+ geomObject = GEOMBase::ConvertIOinGEOMObject( io );
+ QString entry = geomObject->GetEntry();
+ objectsEntry[ iter ] = entry.toLatin1().constData();
+ }
+ }
+ else {
+ objectsEntry->length( nbSelected() );
+ for( initSelected(); moreSelected(); nextSelected(), iter++ )
+ if( DependencyTree_Object* treeObject = dynamic_cast<DependencyTree_Object*>( selectedObject() ) ) {
+ objectsEntry[ iter ] = treeObject->getEntry().c_str();
+ std::cout << "\n\n\n ----------- entry = " << treeObject->getEntry() << std::endl;
+ }
+ }
+
+ myMainEntries = objectsEntry;
}
// get string which describes dependency tree structure
SALOMEDS::TMPFile_var SeqFile =
- GeometryGUI::GetGeomGen()->GetDependencyTree( myStudy, objectsEntry );
+ GeometryGUI::GetGeomGen()->GetDependencyTree( myStudy, myMainEntries );
char* buf = (char*) &SeqFile[0];
std::cout << "\n\n\n\n\n TREE = " << buf << std::endl;
+ clearView( true );
// get dependency tree structure
GEOMUtils::ConvertStringToTree( buf, myTreeModel );
#include <SALOME_ListIO.hxx>
#include <GEOMUtils.hxx>
+#include <GEOM_InteractiveObject.hxx>
+#include <GeometryGUI.h>
+
#include <QWidgetAction>
#include <QPushButton>
~DependencyTree_View();
void init( GraphicsView_ViewFrame* );
- void updateModel( bool = true );
+ void updateModel( bool = true, bool = true );
void drawTree();
- virtual int select( const QRectF&, bool );
virtual void customEvent ( QEvent* );
void mouseMoveEvent(QMouseEvent *event);
+ DependencyTree_Object* getObjectByEntry( QString );
+
void setHierarchyType( const int );
void setNodesMovable( const bool );
void setPrefBackgroundColor( const QColor& );
QMutex myMutex;
public slots:
- void onUpdateModel( bool = true );
+ void onUpdateModel();
+ void onRebuildModel();
protected:
void closeEvent( QCloseEvent* );
std::map< int, std::vector< std::string > >&, int, const int );
void drawWardArrows( GEOMUtils::LevelsList );
- void getNewTreeModel( bool = true );
+ void getNewTreeModel( bool = true, bool = true );
void clearView( bool );
int checkMaxLevelsNumber();
DependencyTree_ComputeDlg_QThread* qthread;
- SALOME_ListIO myMainObjects;
+ GEOM::string_array_var myMainEntries;
SALOMEDS::Study_var myStudy;
LightApp_SelectionMgr* mySelectionMgr;
theMenu->clear();
theMenu->addAction( tr( "MEN_DISPLAY" ), this, SLOT( onShowSelected() ) );
theMenu->addAction( tr( "MEN_DISPLAY_ONLY" ), this, SLOT( onShowOnlySelected() ) );
- theMenu->addAction( tr( "REBUILD_THE_TREE"), aViewPort, SLOT( onUpdateModel() ) );
+ theMenu->addAction( tr( "REBUILD_THE_TREE"), aViewPort, SLOT( onRebuildModel() ) );
}
}
mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpShowDependencyTree ), -1, -1 ); // Show dependency tree
- mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0" + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
+ mgr->setRule( action( GEOMOp::OpShowDependencyTree ), clientOCCorVTKorOB + " and selcount>0 and ($component={'GEOM'}) and type='Shape'", QtxPopupMgr::VisibleRule );
mgr->hide( mgr->actionId( action( myEraseAll ) ) );