- 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
//
// internal includes
#include "DependencyTree_Arrow.h"
#include "DependencyTree_Object.h"
@ -75,7 +76,7 @@ QRectF DependencyTree_Arrow::boundingRect() const
qreal extra;
QRectF boundingRect;
if( myStartItem == myEndItem ) {
extra = arrowSize / 2.0;
extra = arrowSize / 2.0 + 2.0;
boundingRect = mySelfDependencyArrow;
}
else {

View File

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

View File

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

View File

@ -29,14 +29,17 @@ 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;
};

File diff suppressed because it is too large Load Diff

View File

@ -31,36 +31,14 @@
#include <SalomeApp_Application.h>
// QT includes
#include <QWidgetAction>
#include <QPushButton>
#include <QSpinBox>
#include <QCheckBox>
#include <QThread>
#include <QMutex>
class DependencyTree_Object;
class DependencyTree_Arrow;
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::pair<DependencyTree_Object*,DependencyTree_Object*>,DependencyTree_Arrow*> ArrowsInfo;
@ -75,14 +53,14 @@ public:
void init( GraphicsView_ViewFrame* );
void updateModel( bool = true, bool = true );
void drawTree();
QString getViewName() const;
virtual void customEvent ( QEvent* );
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 setNodesMovable( const bool );
@ -94,50 +72,36 @@ public:
void setHighlightArrowColor( const QColor& );
void setSelectArrowColor( const QColor& );
void setIsCompute( bool );
bool getIsCompute();
bool updateObjectName( const std::string &theEntry );
QMutex myMutex;
public slots:
void onUpdateModel();
void onRebuildModel();
protected:
void closeEvent( QCloseEvent* );
private slots:
void updateView();
void onUpdateModel();
void onMoveNodes( bool );
void onHierarchyType();
void onCancel();
signals:
private:
void parseTree();
void parseTreeWard( const GEOMUtils::LevelsList& );
void parseTreeWardArrow( const GEOMUtils::LevelsList& );
void addNode( const std::string& );
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 >&,
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 );
int checkMaxLevelsNumber();
void calcTotalCost();
double getComputeProgress();
void getNewTreeModel( bool = true, bool = true );
void changeWidgetState( bool );
int checkMaxLevelsNumber();
GEOMUtils::TreeModel myTreeModel;
@ -152,26 +116,13 @@ private:
QSpinBox* myHierarchyDepth;
QCheckBox* myDisplayAscendants;
QCheckBox* myDisplayDescendants;
QWidgetAction* cancelAction;
QWidgetAction* progressAction;
QPushButton* updateButton;
int myTimer;
bool myIsUpdate;
bool myIsCompute;
int myTotalCost;
int myComputedCost;
DependencyTree_QThread* qthread;
GEOM::string_array_var myMainEntries;
SALOMEDS::Study_var myStudy;
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
//
// internal includes
#include "DependencyTree_ViewModel.h"
#include "DependencyTree_View.h"
@ -33,7 +34,6 @@
// QT includes
#include <QMenu>
DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& 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()
{
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()
{
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 )
{
GraphicsView_Viewer::contextMenuPopup( theMenu );

View File

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

View File

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

View File

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

View File

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