- clean programming code

This commit is contained in:
mpa 2014-06-04 13:01:12 +04:00
parent 589fb20740
commit 182e941e7e
11 changed files with 441 additions and 542 deletions

View File

@ -17,6 +17,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// internal includes
#include "DependencyTree_Arrow.h" #include "DependencyTree_Arrow.h"
#include "DependencyTree_Object.h" #include "DependencyTree_Object.h"
@ -75,7 +76,7 @@ QRectF DependencyTree_Arrow::boundingRect() const
qreal extra; qreal extra;
QRectF boundingRect; QRectF boundingRect;
if( myStartItem == myEndItem ) { if( myStartItem == myEndItem ) {
extra = arrowSize / 2.0; extra = arrowSize / 2.0 + 2.0;
boundingRect = mySelfDependencyArrow; boundingRect = mySelfDependencyArrow;
} }
else { else {

View File

@ -17,6 +17,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// internal includes
#include "DependencyTree_Object.h" #include "DependencyTree_Object.h"
// GEOM includes // GEOM includes
@ -169,7 +170,6 @@ void DependencyTree_Object::updateName()
QString name = myGeomObject->GetName(); QString name = myGeomObject->GetName();
QString studyEntry = myGeomObject->GetStudyEntry(); QString studyEntry = myGeomObject->GetStudyEntry();
std::cout<<"\n\n name = " << name.toStdString() << " studyEntry = " << studyEntry.toStdString() << std::endl;
if( studyEntry.isEmpty() ) { if( studyEntry.isEmpty() ) {
if( name.isEmpty() ) if( name.isEmpty() )

View File

@ -17,6 +17,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// internal includes
#include "DependencyTree_Selector.h" #include "DependencyTree_Selector.h"
#include "DependencyTree_View.h" #include "DependencyTree_View.h"
#include "DependencyTree_ViewModel.h" #include "DependencyTree_ViewModel.h"
@ -28,8 +29,6 @@
//GEOM includes //GEOM includes
#include <GEOMBase.h> #include <GEOMBase.h>
#include <iostream>
DependencyTree_Selector::DependencyTree_Selector( DependencyTree_ViewModel* theModel, SUIT_SelectionMgr* theSelMgr ) DependencyTree_Selector::DependencyTree_Selector( DependencyTree_ViewModel* theModel, SUIT_SelectionMgr* theSelMgr )
:LightApp_GVSelector( (GraphicsView_Viewer*)theModel, theSelMgr ) :LightApp_GVSelector( (GraphicsView_Viewer*)theModel, theSelMgr )
{ {
@ -50,8 +49,11 @@ void DependencyTree_Selector::getSelection( SUIT_DataOwnerPtrList& theList ) con
if( DependencyTree_Object* treeObject = dynamic_cast<DependencyTree_Object*>( myView->selectedObject() ) ) { if( DependencyTree_Object* treeObject = dynamic_cast<DependencyTree_Object*>( myView->selectedObject() ) ) {
const char* entry; const char* entry;
const char* name; const char* name;
if( !treeObject->getGeomObject()->_is_nil() ) { GEOM::GEOM_BaseObject_var anObj = GeometryGUI::GetGeomGen()->GetObject( myView->getStudyId(),
QString studyEntry = treeObject->getGeomObject()->GetStudyEntry(); treeObject->getEntry().c_str() );
if( anObj->_is_nil() )
continue;
QString studyEntry = anObj->GetStudyEntry();
if( studyEntry.isEmpty() ) { if( studyEntry.isEmpty() ) {
entry = treeObject->getEntry().c_str(); entry = treeObject->getEntry().c_str();
name = "TEMP_IO_UNPUBLISHED"; name = "TEMP_IO_UNPUBLISHED";
@ -65,7 +67,6 @@ void DependencyTree_Selector::getSelection( SUIT_DataOwnerPtrList& theList ) con
theList.append( new LightApp_DataOwner( tmpIO ) ); theList.append( new LightApp_DataOwner( tmpIO ) );
} }
}
} }
//================================================================================= //=================================================================================
@ -93,7 +94,7 @@ void DependencyTree_Selector::setSelection( const SUIT_DataOwnerPtrList& theList
return; return;
entry = geomObject->GetEntry(); entry = geomObject->GetEntry();
} }
DependencyTree_Object* object = myView->getObjectByEntry( QString( entry ) ); DependencyTree_Object* object = myView->getObjectByEntry( entry );
if( object ) { if( object ) {
myView->setSelected( object ); myView->setSelected( object );
object->select( object->pos().x(), object->pos().y(), object->getRect() ); object->select( object->pos().x(), object->pos().y(), object->getRect() );

View File

@ -29,14 +29,17 @@ class DependencyTree_Selector: public LightApp_GVSelector
{ {
public: public:
DependencyTree_Selector( DependencyTree_ViewModel*, SUIT_SelectionMgr* ); DependencyTree_Selector( DependencyTree_ViewModel*, SUIT_SelectionMgr* );
~DependencyTree_Selector(); ~DependencyTree_Selector();
protected: protected:
virtual void getSelection( SUIT_DataOwnerPtrList& ) const; virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
virtual void setSelection( const SUIT_DataOwnerPtrList& ); virtual void setSelection( const SUIT_DataOwnerPtrList& );
private: private:
DependencyTree_View* myView; DependencyTree_View* myView;
}; };

File diff suppressed because it is too large Load Diff

View File

@ -31,36 +31,14 @@
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
// QT includes // QT includes
#include <QWidgetAction>
#include <QPushButton> #include <QPushButton>
#include <QSpinBox> #include <QSpinBox>
#include <QCheckBox> #include <QCheckBox>
#include <QThread>
#include <QMutex>
class DependencyTree_Object; class DependencyTree_Object;
class DependencyTree_Arrow; class DependencyTree_Arrow;
class DependencyTree_View; class DependencyTree_View;
class DependencyTree_QThread : public QThread
{
Q_OBJECT
public:
DependencyTree_QThread( DependencyTree_View* );
void sleepDraw();
void cancel();
DependencyTree_View* getView() { return myView; };
protected:
void run();
private:
DependencyTree_View* myView;
};
typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap; typedef std::map<std::string,DependencyTree_Object*> EntryObjectMap;
typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo; typedef std::map<std::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
@ -75,14 +53,14 @@ public:
void init( GraphicsView_ViewFrame* ); void init( GraphicsView_ViewFrame* );
void updateModel( bool = true, bool = true ); void updateModel( bool = true, bool = true );
void drawTree();
QString getViewName() const;
virtual void customEvent ( QEvent* );
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
DependencyTree_Object* getObjectByEntry( QString ); QString getViewName() const;
int getStudyId() const;
DependencyTree_Object* getObjectByEntry( const std::string& );
bool updateObjectName( const std::string& theEntry );
void setHierarchyType( const int ); void setHierarchyType( const int );
void setNodesMovable( const bool ); void setNodesMovable( const bool );
@ -94,50 +72,36 @@ public:
void setHighlightArrowColor( const QColor& ); void setHighlightArrowColor( const QColor& );
void setSelectArrowColor( const QColor& ); void setSelectArrowColor( const QColor& );
void setIsCompute( bool );
bool getIsCompute();
bool updateObjectName( const std::string &theEntry );
QMutex myMutex;
public slots: public slots:
void onUpdateModel();
void onRebuildModel(); void onRebuildModel();
protected:
void closeEvent( QCloseEvent* );
private slots: private slots:
void updateView();
void onUpdateModel();
void onMoveNodes( bool ); void onMoveNodes( bool );
void onHierarchyType(); void onHierarchyType();
void onCancel();
signals:
private: private:
void parseTree();
void parseTreeWard( const GEOMUtils::LevelsList& );
void parseTreeWardArrow( const GEOMUtils::LevelsList& );
void addNode( const std::string& ); void addNode( const std::string& );
void addArrow( DependencyTree_Object*, DependencyTree_Object* ); void addArrow( DependencyTree_Object*, DependencyTree_Object* );
void addNewItem( QGraphicsItem* );
void parseTree();
void parseTreeWard(const GEOMUtils::LevelsList);
void parseTreeWardArrow(const GEOMUtils::LevelsList);
void drawTree();
void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&, void drawWard( const GEOMUtils::LevelsList&, std::map< std::string, int >&,
std::map< int, std::vector< std::string > >&, int, const int ); std::map< int, std::vector< std::string > >&, int, const int );
void drawWardArrows( GEOMUtils::LevelsList ); void drawWardArrows( const GEOMUtils::LevelsList& );
void getNewTreeModel( bool = true, bool = true ); void updateView();
void clearView( bool ); void clearView( bool );
int checkMaxLevelsNumber(); void getNewTreeModel( bool = true, bool = true );
void calcTotalCost();
double getComputeProgress();
void changeWidgetState( bool ); int checkMaxLevelsNumber();
GEOMUtils::TreeModel myTreeModel; GEOMUtils::TreeModel myTreeModel;
@ -152,26 +116,13 @@ private:
QSpinBox* myHierarchyDepth; QSpinBox* myHierarchyDepth;
QCheckBox* myDisplayAscendants; QCheckBox* myDisplayAscendants;
QCheckBox* myDisplayDescendants; QCheckBox* myDisplayDescendants;
QWidgetAction* cancelAction;
QWidgetAction* progressAction;
QPushButton* updateButton; QPushButton* updateButton;
int myTimer;
bool myIsUpdate;
bool myIsCompute;
int myTotalCost;
int myComputedCost;
DependencyTree_QThread* qthread;
GEOM::string_array_var myMainEntries;
SALOMEDS::Study_var myStudy; SALOMEDS::Study_var myStudy;
LightApp_SelectionMgr* mySelectionMgr; LightApp_SelectionMgr* mySelectionMgr;
GEOM::string_array_var myMainEntries;
bool myIsUpdate;
}; };

View File

@ -17,6 +17,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// internal includes
#include "DependencyTree_ViewModel.h" #include "DependencyTree_ViewModel.h"
#include "DependencyTree_View.h" #include "DependencyTree_View.h"
@ -33,7 +34,6 @@
// QT includes // QT includes
#include <QMenu> #include <QMenu>
DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title ) DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title )
: GraphicsView_Viewer( title ) : GraphicsView_Viewer( title )
{ {
@ -48,6 +48,10 @@ DependencyTree_ViewModel::~DependencyTree_ViewModel()
{ {
} }
//=================================================================================
// function : onShowSelected()
// purpose : slot for showing selected objects in OCC Viewer
//=================================================================================
void DependencyTree_ViewModel::onShowSelected() void DependencyTree_ViewModel::onShowSelected()
{ {
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
@ -76,6 +80,10 @@ void DependencyTree_ViewModel::onShowSelected()
} }
} }
//=================================================================================
// function : onShowOnlySelected()
// purpose : slot for showing only selected objects in OCC Viewer
//=================================================================================
void DependencyTree_ViewModel::onShowOnlySelected() void DependencyTree_ViewModel::onShowOnlySelected()
{ {
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
@ -103,6 +111,10 @@ void DependencyTree_ViewModel::onShowOnlySelected()
} }
} }
//=================================================================================
// function : contextMenuPopup()
// purpose : process calling of context menu popup
//=================================================================================
void DependencyTree_ViewModel::contextMenuPopup( QMenu* theMenu ) void DependencyTree_ViewModel::contextMenuPopup( QMenu* theMenu )
{ {
GraphicsView_Viewer::contextMenuPopup( theMenu ); GraphicsView_Viewer::contextMenuPopup( theMenu );

View File

@ -28,6 +28,7 @@ class DependencyTree_ViewModel: public GraphicsView_Viewer
Q_OBJECT Q_OBJECT
public: public:
DependencyTree_ViewModel( const QString& title ); DependencyTree_ViewModel( const QString& title );
DependencyTree_ViewModel( const QString& title, QWidget* w ); DependencyTree_ViewModel( const QString& title, QWidget* w );
~DependencyTree_ViewModel(); ~DependencyTree_ViewModel();
@ -35,6 +36,7 @@ public:
virtual void contextMenuPopup( QMenu* ); virtual void contextMenuPopup( QMenu* );
private slots: private slots:
void onShowSelected(); void onShowSelected();
void onShowOnlySelected(); void onShowOnlySelected();

View File

@ -31,10 +31,6 @@
<source>UPDATE</source> <source>UPDATE</source>
<translation>Update</translation> <translation>Update</translation>
</message> </message>
<message>
<source>CANCEL</source>
<translation>Cancel</translation>
</message>
<name>DependencyTree_ViewModel</name> <name>DependencyTree_ViewModel</name>
<message> <message>
<source>REBUILD_THE_TREE</source> <source>REBUILD_THE_TREE</source>

View File

@ -31,10 +31,6 @@
<source>UPDATE</source> <source>UPDATE</source>
<translation type="unfinished">Update</translation> <translation type="unfinished">Update</translation>
</message> </message>
<message>
<source>CANCEL</source>
<translation type="unfinished">Cancel</translation>
</message>
<name>DependencyTree_ViewModel</name> <name>DependencyTree_ViewModel</name>
<message> <message>
<source>REBUILD_THE_TREE</source> <source>REBUILD_THE_TREE</source>

View File

@ -31,10 +31,6 @@
<source>UPDATE</source> <source>UPDATE</source>
<translation type="unfinished">Update</translation> <translation type="unfinished">Update</translation>
</message> </message>
<message>
<source>CANCEL</source>
<translation type="unfinished">Cancel</translation>
</message>
<name>DependencyTree_ViewModel</name> <name>DependencyTree_ViewModel</name>
<message> <message>
<source>REBUILD_THE_TREE</source> <source>REBUILD_THE_TREE</source>