Creation of GUI part

This commit is contained in:
mpa 2014-05-21 17:42:20 +04:00
parent fa14a07690
commit bec320673b
27 changed files with 2228 additions and 2 deletions

View File

@ -243,7 +243,7 @@ IF(SALOME_BUILD_GUI)
LIST(APPEND _${PROJECT_NAME}_exposed_targets
AdvancedGUI BasicGUI BlocksGUI BooleanGUI BuildGUI DisplayGUI DlgRef EntityGUI GEOMBase
GEOMFiltersSelection GEOM GEOMToolsGUI GenerationGUI GroupGUI Material MeasureGUI GEOMObject
OperationGUI PrimitiveGUI RepairGUI TransformationGUI ImportExportGUI
OperationGUI PrimitiveGUI RepairGUI TransformationGUI ImportExportGUI DependencyTree
)
ENDIF(SALOME_BUILD_GUI)

View File

@ -162,6 +162,7 @@ SET(GEOM_GEOMBase GEOMBase)
SET(GEOM_GEOMFiltersSelection GEOMFiltersSelection)
SET(GEOM_GEOM GEOM)
SET(GEOM_GEOMToolsGUI GEOMToolsGUI)
SET(GEOM_DependencyTree DependencyTree)
SET(GEOM_GenerationGUI GenerationGUI)
SET(GEOM_GroupGUI GroupGUI)
SET(GEOM_Material Material)

View File

@ -54,6 +54,7 @@ FIND_LIBRARY(GEOM_GEOMBase GEOMBase ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_GEOMFiltersSelection GEOMFiltersSelection ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_GEOM GEOM ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_GEOMToolsGUI GEOMToolsGUI ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_DependencyTree DependencyTree ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_GenerationGUI GenerationGUI ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_GroupGUI GroupGUI ${GEOM_ROOT_DIR}/lib/salome)
FIND_LIBRARY(GEOM_Material Material ${GEOM_ROOT_DIR}/lib/salome)

View File

@ -67,6 +67,15 @@
<parameter name="measures_line_width" value="1" />
<parameter name="iso_number_u" value="0" />
<parameter name="iso_number_v" value="0" />
<parameter name="dependency_tree_hierarchy_type" value="0" />
<parameter name="dependency_tree_move_nodes" value="true" />
<parameter name="dependency_tree_background_color" value="255, 255, 255" />
<parameter name="dependency_tree_node_color" value="62, 180, 238" />
<parameter name="dependency_tree_main_node_color" value="238, 90, 125" />
<parameter name="dependency_tree_select_node_color" value="237, 243, 58" />
<parameter name="dependency_tree_arrow_color" value="0, 0, 130" />
<parameter name="dependency_tree_highlight_arrow_color" value="0, 0, 255" />
<parameter name="dependency_tree_select_arrow_color" value="255, 0, 0" />
<!-- Dimension presentation properties -->
<parameter name="dimensions_color" value="#ffffff" />

View File

@ -50,7 +50,7 @@ ENDIF()
##
IF(SALOME_BUILD_GUI)
SET(SUBDIRS_GUI
OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI
DependencyTree OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI
GEOMBase GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI
EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI
RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI ImportExportGUI

View File

@ -0,0 +1,114 @@
# Copyright (C) 2012-2014 CEA/DEN, EDF R&D
#
# 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(UseQt4Ext)
INCLUDE(${QT_USE_FILE})
# --- options ---
# additional include directories
INCLUDE_DIRECTORIES(
${QT_INCLUDES}
${GUI_INCLUDE_DIRS}
${CAS_INCLUDE_DIRS}
${OMNIORB_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/GEOMGUI
${PROJECT_SOURCE_DIR}/src/GEOMBase
${PROJECT_SOURCE_DIR}/src/GEOM
${PROJECT_BINARY_DIR}/idl
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/src/OBJECT
${PROJECT_SOURCE_DIR}/src/GEOMClient
${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/DlgRef
${PROJECT_BINARY_DIR}/src/DlgRef
)
# additional preprocessor / compiler flags
ADD_DEFINITIONS(
${QT_DEFINITIONS}
${GUI_DEFINITIONS}
${CAS_DEFINITIONS}
${OMNIORB_DEFINITIONS}
)
# libraries to link to
SET(_link_LIBRARIES
${QT_LIBRARIES}
${GUI_SalomeApp}
${GUI_suit}
${GUI_qtx}
${GUI_QxScene}
${GUI_GraphicsView}
${GUI_SalomeObject}
GEOMUtils
)
# --- headers ---
SET(DependencyTree_HEADERS
DependencyTree.h
DependencyTree_Object.h
DependencyTree_Arrow.h
DependencyTree_ViewModel.h
)
# header files / to be processed by moc
SET(_moc_HEADERS
DependencyTree_View.h
)
# --- sources ---
# sources / moc wrappings
QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
SET(DependencyTree_SOURCES
DependencyTree.cxx
DependencyTree_View.cxx
DependencyTree_Object.cxx
DependencyTree_Arrow.cxx
#arrow.cxx
DependencyTree_ViewModel.cxx
${_moc_SOURCES}
)
# --- resources ---
# resource files / to be processed by lrelease
SET(_res_files
resources/DependencyTree_msg_en.ts
resources/DependencyTree_msg_fr.ts
resources/DependencyTree_msg_ja.ts
)
# --- rules ---
ADD_LIBRARY(DependencyTree ${DependencyTree_SOURCES})
TARGET_LINK_LIBRARIES(DependencyTree ${_link_LIBRARIES})
INSTALL(TARGETS DependencyTree EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
#INSTALL(FILES ${_res_files} DESTINATION ${SALOME_GEOM_INSTALL_RES_DATA})
QT4_INSTALL_TS_RESOURCES("${_res_files}" "${SALOME_GEOM_INSTALL_RES_DATA}")
INSTALL(FILES ${DependencyTree_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})

View File

@ -0,0 +1,114 @@
// 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 <GraphicsView_Object.h>
#include "DependencyTree.h"
#include "DependencyTree_ViewModel.h"
#include <QGraphicsItem>
#include <QPolygonF>
#include <QPointF>
#include <QMenu>
#include <QPen>
#include <QFont>
#include <QString>
#include <QGraphicsPolygonItem>
#include <QGraphicsSimpleTextItem>
#include <QWidgetAction>
#include <QSpinBox>
#include <QLabel>
#include <QCheckBox>
#include <QtxActionToolMgr.h>
#include "DependencyTree_View.h"
#include <GraphicsView_Viewer.h>
#include <GraphicsView_ViewFrame.h>
#include <GraphicsView_Scene.h>
#include <SUIT_Session.h>
#include <SUIT_ViewManager.h>
#include <SalomeApp_Application.h>
#include <QList>
#include <QGraphicsView>
#include <iostream>
DependencyTree::DependencyTree()
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;
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 );
SUIT_ViewWindow* svw = svm->getActiveView();
GraphicsView_ViewFrame* aViewFrame = 0;
if (!svw) svw = svm->createViewWindow();
if (svw) aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>(svw);
myView->init( aViewFrame );
svm->setTitle("DEPENDENCY_TREE");
}
else {
svm->getActiveView()->setFocus();
}
}
DependencyTree::~DependencyTree()
{
}
//void DependencyTree::setBackgroundColor( const QColor& theColor )
//{
// //myView->setBackgroundColor( theColor );
// myBackgroundColor = theColor;
//}
//void DependencyTree::setNodeColor( const QColor& theColor )
//{
// myView->setNodeColor( theColor );
//}
//void DependencyTree::setMainNodeColor( const QColor& theColor )
//{
// myView->setMainNodeColor( theColor );
//}
//void DependencyTree::setSelectNodeColor( const QColor& theColor )
//{
// myView->setSelectNodeColor( theColor );
//}
//void DependencyTree::setArrowColor( const QColor& theColor )
//{
// myView->setArrowColor( theColor );
//}
//void DependencyTree::setHighlightArrowColor( const QColor& theColor )
//{
// myView->setHighlightArrowColor( theColor );
//}
//void DependencyTree::setSelectArrowColor( const QColor& theColor )
//{
// myView->setSelectArrowColor( theColor );
//}

View File

@ -0,0 +1,44 @@
// 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 <GraphicsView_Object.h>
#include <QGraphicsPolygonItem>
#include "DependencyTree_View.h"
class DependencyTree
{
public:
DependencyTree();
~DependencyTree();
// static void setBackgroundColor( const QColor& );
// static void setNodeColor( const QColor& );
// static void setMainNodeColor( const QColor& );
// static void setSelectNodeColor( const QColor& );
// static void setArrowColor( const QColor& );
// static void setHighlightArrowColor( const QColor& );
// static void setSelectArrowColor( const QColor& );
private:
DependencyTree_View* myView;
QColor* myBackgroundColor;
};

View File

@ -0,0 +1,258 @@
// 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_Arrow.h"
#include "DependencyTree_Object.h"
// GUI includes
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
// Qt includes
#include <QPainter>
#include <math.h>
const qreal arrowSize = 20;
DependencyTree_Arrow::DependencyTree_Arrow( DependencyTree_Object* theStartItem,
DependencyTree_Object* theEndItem,
QGraphicsItem* parent, QGraphicsScene* scene )
:QGraphicsLineItem( parent, scene ),
myIsBiLink( false ),
myStartItem( theStartItem ),
myEndItem( theEndItem )
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
myColor = resMgr->colorValue( "Geometry", "dependency_tree_arrow_color", QColor( 0, 0, 130 ) );
myHighlightColor = resMgr->colorValue( "Geometry", "dependency_tree_highlight_arrow_color", QColor( 0, 0, 255 ) );
mySelectColor = resMgr->colorValue( "Geometry", "dependency_tree_select_arrow_color", QColor( 255, 0, 0 ) );
myStartItem = theStartItem;
myEndItem = theEndItem;
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
mySelfDependencyArrow = QRectF();
setPen( QPen( myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
setColor( myColor );
setFlag( QGraphicsItem::ItemIsSelectable, true );
setZValue( -1000.0 );
}
DependencyTree_Arrow::~DependencyTree_Arrow()
{
}
//=================================================================================
// function : boundingRect()
// purpose : return the outer bounds of the item as a rectangle.
// QGraphicsView uses this to determine whether the item requires redrawing
//=================================================================================
QRectF DependencyTree_Arrow::boundingRect() const
{
qreal extra;
QRectF boundingRect;
if( myStartItem == myEndItem ) {
extra = arrowSize / 2.0;
boundingRect = mySelfDependencyArrow;
}
else {
extra = ( pen().width() + 20 ) / 2.0;
boundingRect = QRectF( line().p1(), QSizeF( line().p2().x() - line().p1().x(),
line().p2().y() - line().p1().y() ) );
}
return boundingRect.normalized().adjusted( -extra, -extra, extra, extra );
}
//=================================================================================
// function : shape()
// purpose : return the shape of this item to define an area of preselection
//=================================================================================
QPainterPath DependencyTree_Arrow::shape() const
{
QPainterPath path;
if( myStartItem == myEndItem ) {
qreal extra = 5;
QPolygonF aPolygonBigger( mySelfDependencyArrow.normalized()
.adjusted( -extra, -extra, extra, extra ) );
QPolygonF aPolygonSmaller( mySelfDependencyArrow.normalized()
.adjusted( extra, extra, -extra, -extra ) );
path.addPolygon( aPolygonBigger.subtracted( aPolygonSmaller ) );
path.addPolygon(myArrowHead);
}
else {
QPolygonF aShapePolygon;
QPolygon anArrowHead = myArrowHead.toPolygon();
QPolygon anReverseArrowHead = myReverseArrowHead.toPolygon();
aShapePolygon << anArrowHead.point(1) << anArrowHead.point(0) << anArrowHead.point(2) <<
anReverseArrowHead.point(1) << anReverseArrowHead.point(0) << anReverseArrowHead.point(2);
path.addPolygon( aShapePolygon );
}
return path;
}
//=================================================================================
// function : setColor()
// purpose : set default color for arrow
//=================================================================================
void DependencyTree_Arrow::setColor( const QColor& theColor )
{
myColor = theColor;
}
//=================================================================================
// function : setHighlightColor()
// purpose : set color for highlighted arrow
//=================================================================================
void DependencyTree_Arrow::setHighlightColor( const QColor& theColor )
{
myHighlightColor = theColor;
}
//=================================================================================
// function : setSelectColor()
// purpose : set color for selected arrow
//=================================================================================
void DependencyTree_Arrow::setSelectColor( const QColor& theColor )
{
mySelectColor = theColor;
}
//=================================================================================
// function : getStartItem()
// purpose : get start item of arrow
//=================================================================================
DependencyTree_Object* DependencyTree_Arrow::getStartItem() const
{
return myStartItem;
}
//=================================================================================
// function : getEndItem()
// purpose : get end item of arrow
//=================================================================================
DependencyTree_Object* DependencyTree_Arrow::getEndItem() const
{
return myEndItem;
}
//=================================================================================
// function : setIsBiLink()
// purpose : set true if current arrow is bi-directional link, else set false
//=================================================================================
void DependencyTree_Arrow::setIsBiLink( bool theIsBiLink )
{
myIsBiLink = theIsBiLink;
}
//=================================================================================
// function : paint()
// purpose : paint the contents of an item in local coordinates (called by QGraphicsView)
//=================================================================================
void DependencyTree_Arrow::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* )
{
if( isSelected() ) {
painter->setBrush( mySelectColor );
painter->setPen( QPen( mySelectColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
}
else if( isUnderMouse() ) {
painter->setBrush( myHighlightColor );
painter->setPen( QPen( myHighlightColor, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
}
else {
painter->setBrush( myColor );
painter->setPen( QPen( myColor, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
}
if( myStartItem == myEndItem ) {
int lineSize = 60;
QPointF p1( myStartItem->pos().x() - myStartItem->boundingRect().width()/2,
myStartItem->pos().y() );
QPointF p2( p1.x() - lineSize + myStartItem->boundingRect().height()/2, p1.y() );
QPointF p3( p2.x(), p2.y() - lineSize );
QPointF p4( p3.x() + lineSize, p3.y() );
QPointF p5( p4.x(), p4.y() + lineSize - myStartItem->boundingRect().height()/2 );
mySelfDependencyArrow = QRectF( p3.x(), p3.y(), lineSize, lineSize );
myArrowHead = createArrowHead( p4, p5, false );
QVector<QPointF> pointVector;
pointVector << p1 << p2 << p2 << p3 << p3 << p4 << p4 << p5;
painter->drawLines( pointVector);
painter->drawPolygon(myArrowHead);
}
else {
if (myStartItem->collidesWithItem(myEndItem))
return;
myArrowHead = createArrowHead( myStartItem->pos(), myEndItem->pos() );
myReverseArrowHead = createArrowHead( myEndItem->pos(), myStartItem->pos() );
painter->drawLine( line() );
painter->drawPolygon( myArrowHead );
if( myIsBiLink )
painter->drawPolygon( myReverseArrowHead );
}
}
//=================================================================================
// function : createArrowHead()
// purpose : create a head of arrow from start point to end point
//=================================================================================
QPolygonF DependencyTree_Arrow::createArrowHead( QPointF theStartPoint, QPointF theEndPoint,
bool theIsDynamic )
{
if( theIsDynamic ) {
QLineF centerLine( theStartPoint, theEndPoint );
QPolygonF endPolygon = QPolygonF( myEndItem->boundingRect() );
QPointF p1 = endPolygon.first() + theEndPoint;
QPointF p2;
QPointF intersectPoint;
QLineF polyLine;
for( int i = 1; i < endPolygon.count(); ++i ) {
p2 = endPolygon.at(i) + theEndPoint;
polyLine = QLineF( p1, p2 );
QLineF::IntersectType intersectType = polyLine.intersect( centerLine, &intersectPoint );
if( intersectType == QLineF::BoundedIntersection )
break;
p1 = p2;
}
setLine( QLineF( intersectPoint, theStartPoint ) );
}
else
setLine( QLineF( theEndPoint, theStartPoint ) );
double angle = acos(line().dx() / line().length());
if( line().dy() >= 0 )
angle = ( M_PI * 2 ) - angle;
QPointF arrowP1 = line().p1() + QPointF( sin( angle + M_PI / 3 ) * arrowSize,
cos( angle + M_PI / 3 ) * arrowSize );
QPointF arrowP2 = line().p1() + QPointF( sin( angle + M_PI - M_PI / 3 ) * arrowSize,
cos( angle + M_PI - M_PI / 3 ) * arrowSize );
QPolygonF anArrowHead;
anArrowHead << line().p1() << arrowP1 << arrowP2;
return anArrowHead;
}

View File

@ -0,0 +1,71 @@
// 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_ARROW_H
#define DEPENDENCYTREE_ARROW_H
#include <QGraphicsLineItem>
class DependencyTree_Object;
class DependencyTree_Arrow : public QGraphicsLineItem
{
public:
DependencyTree_Arrow( DependencyTree_Object* startItem, DependencyTree_Object* endItem,
QGraphicsItem* parent = 0, QGraphicsScene* scene = 0 );
~DependencyTree_Arrow();
virtual QRectF boundingRect() const;
virtual QPainterPath shape() const;
void setColor(const QColor& );
void setHighlightColor(const QColor& );
void setSelectColor(const QColor& );
DependencyTree_Object* getStartItem() const;
DependencyTree_Object* getEndItem() const;
void setIsBiLink( bool );
protected:
void paint( QPainter*, const QStyleOptionGraphicsItem*, QWidget* = 0 );
private:
QPolygonF createArrowHead( QPointF , QPointF, bool = true );
DependencyTree_Object* myStartItem;
DependencyTree_Object* myEndItem;
QColor myColor;
QColor mySelectColor;
QColor myHighlightColor;
QPolygonF myArrowHead;
QPolygonF myReverseArrowHead;
bool myIsBiLink;
QRectF mySelfDependencyArrow;
};
#endif

View File

@ -0,0 +1,224 @@
// 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_Object.h"
// GUI includes
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
// Qt includes
#include <QFont>
const int itemH = 20;
const int itemW = 90;
DependencyTree_Object::DependencyTree_Object( const QString& theEntry, QGraphicsItem* theParent )
:GraphicsView_Object( theParent ),
myIsMainObject( false ),
myIsLongName( false )
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
myColor = resMgr->colorValue( "Geometry", "dependency_tree_node_color", QColor( 62, 180, 238 ) );
mySelectColor = resMgr->colorValue( "Geometry", "dependency_tree_select_node_color", QColor( 237, 243, 58 ) );
myMainObjectColor = resMgr->colorValue( "Geometry", "dependency_tree_main_node_color", QColor( 238, 90, 125 ) );
myPolygonItem = new QGraphicsPolygonItem();
QPolygonF myPolygon;
myPolygon << QPointF( -itemW, -itemH ) << QPointF( itemW, -itemH ) << QPointF( itemW, itemH )
<< QPointF( -itemW, itemH ) << QPointF( -itemW, -itemH );
myPolygonItem->setPolygon( myPolygon );
myPolygonItem->setBrush( myColor );
myPolygonItem->setPen( getPen( myColor ) );
myTextItem = new QGraphicsSimpleTextItem();
QFont textFont;
textFont.setPointSize( itemH );
myTextItem->setFont( textFont );
myEntry = theEntry;
updateName();
addToGroup( myPolygonItem );
addToGroup( myTextItem );
}
DependencyTree_Object::~DependencyTree_Object()
{
}
//=================================================================================
// function : highlight()
// purpose : highlight current item
//=================================================================================
bool DependencyTree_Object::highlight( double theX, double theY )
{
if( !isHighlighted() ) {
QColor color = myPolygonItem->brush().color();
int saturation = ( color.saturation() - 100 ) > 10 ? color.saturation() - 100 : 10;
color.setHsv( color.hsvHue(), saturation, color.value() );
myPolygonItem->setBrush( color );
myPolygonItem->setPen( getPen( color ) );
if( myIsLongName )
myPolygonItem->setToolTip( getName() );
}
return GraphicsView_Object::highlight( theX, theY );
}
//=================================================================================
// function : unhighlight()
// purpose : set properties for unhighlighted item
//=================================================================================
void DependencyTree_Object::unhighlight()
{
if( isSelected() )
myPolygonItem->setBrush( mySelectColor );
else if( myIsMainObject )
myPolygonItem->setBrush( myMainObjectColor );
else
myPolygonItem->setBrush( myColor );
myPolygonItem->setPen( getPen( myPolygonItem->brush().color() ) );
GraphicsView_Object::unhighlight();
}
//=================================================================================
// function : select()
// purpose : select current item
//=================================================================================
bool DependencyTree_Object::select( double theX, double theY, const QRectF& theRect )
{
myPolygonItem->setBrush( mySelectColor );
myPolygonItem->setPen( getPen( mySelectColor ) );
return GraphicsView_Object::select( theX, theY, theRect );
}
//=================================================================================
// function : unselect()
// purpose : set properties for unselected item
//=================================================================================
void DependencyTree_Object::unselect()
{
if( myIsMainObject )
myPolygonItem->setBrush( myMainObjectColor );
else
myPolygonItem->setBrush( myColor );
myPolygonItem->setPen( getPen( myPolygonItem->brush().color() ) );
GraphicsView_Object::unselect();
}
//=================================================================================
// function : getEntry()
// purpose : get entry of current item
//=================================================================================
QString DependencyTree_Object::getEntry() const
{
return myEntry;
}
//=================================================================================
// function : updateName()
// purpose : update name of current item using its entry
//=================================================================================
void DependencyTree_Object::updateName()
{
QString name = myEntry;
setName( myEntry );
myTextItem->setText( name );
double textWidth = myTextItem->sceneBoundingRect().width();
double textHeight = myTextItem->sceneBoundingRect().height();
double polygonWidth = myPolygonItem->sceneBoundingRect().width();
double polygonHeight = myPolygonItem->sceneBoundingRect().height();
if( ( textWidth - 4 ) > polygonWidth ) {
myIsLongName = true;
int numberSymbol = int( polygonWidth * name.length() / textWidth );
QString newName = name.left( numberSymbol - 3 ) + "...";
myTextItem->setText( newName );
textWidth = myTextItem->sceneBoundingRect().width();
}
myTextItem->setPos( ( polygonWidth - textWidth ) / 2 - itemW,
( polygonHeight - textHeight ) / 2 - itemH );
}
//=================================================================================
// function : setColor()
// purpose : set default color of current item
//=================================================================================
void DependencyTree_Object::setColor( const QColor& theColor )
{
myColor = theColor;
}
//=================================================================================
// function : setSelectColor()
// purpose : set color of selected item
//=================================================================================
void DependencyTree_Object::setSelectColor( const QColor& theColor )
{
mySelectColor = theColor;
}
//=================================================================================
// function : setMainObjectColor()
// purpose : set color if current item is main object of dependency tree
//=================================================================================
void DependencyTree_Object::setMainObjectColor( const QColor& theColor )
{
myMainObjectColor = theColor;
}
//=================================================================================
// function : setIsMainObject()
// purpose : set true if current item is main object of dependency tree
//=================================================================================
void DependencyTree_Object::setIsMainObject( bool theIsMainObject )
{
myIsMainObject = theIsMainObject;
if( myIsMainObject )
myPolygonItem->setBrush( myMainObjectColor );
else
myPolygonItem->setBrush( myColor );
myPolygonItem->setPen( getPen( myPolygonItem->brush().color() ) );
}
//=================================================================================
// function : getPen()
// purpose : get pen which is dependent of current color
//=================================================================================
QPen DependencyTree_Object::getPen( const QColor& theColor )
{
int value = ( theColor.value() - 100 ) > 10 ? theColor.value() - 100 : 10;
QColor penColor;
penColor.setHsv( theColor.hsvHue(), theColor.saturation(), value );
return QPen( QBrush( penColor ), 4 );
}

View File

@ -0,0 +1,70 @@
// 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_OBJECT_H
#define DEPENDENCYTREE_OBJECT_H
#include <GraphicsView_Object.h>
#include <QPen>
class DependencyTree_Object: public GraphicsView_Object
{
public:
DependencyTree_Object( const QString&, QGraphicsItem* = 0 );
~DependencyTree_Object();
virtual void compute() {};
virtual bool highlight( double, double );
virtual void unhighlight();
virtual bool select( double, double, const QRectF& );
virtual void unselect();
QString getEntry() const;
void updateName();
void setColor(const QColor& );
void setSelectColor(const QColor& );
void setMainObjectColor(const QColor& );
void setIsMainObject( bool );
private:
QPen getPen( const QColor& );
QColor myColor;
QColor mySelectColor;
QColor myMainObjectColor;
QGraphicsPolygonItem* myPolygonItem;
QGraphicsSimpleTextItem* myTextItem;
QString myEntry;
bool myIsMainObject;
bool myIsLongName;
};
#endif

View File

@ -0,0 +1,782 @@
// 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 <GraphicsView_ViewPort.h>
#include <GraphicsView_Scene.h>
#include <GraphicsView_ViewFrame.h>
#include "DependencyTree_View.h"
#include "DependencyTree_Object.h"
#include "DependencyTree_Arrow.h"
#include <QMenu>
#include <QList>
#include <QString>
#include <QGraphicsView>
#include <QSpinBox>
#include <QWidgetAction>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>
#include <QGridLayout>
#include <QCloseEvent>
#include <QTimerEvent>
#include <QtxActionToolMgr.h>
// GUI includes
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <iostream>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <LightApp_SelectionMgr.h>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <GEOM_InteractiveObject.hxx>
#include <GeometryGUI.h>
#include <GEOMBase.h>
int iter = 0;
DependencyTree_View::DependencyTree_View( QWidget* theParent )
:GraphicsView_ViewPort(theParent),
myMaxDownwardLevelsNumber(0),
myMaxUpwardLevelsNumber(0),
myLevelsNumber(0),
myIsCompute(true),
myIsUpdate( true )
{
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) return;
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
_PTR(Study) aStudy = study->studyDS();
if ( !aStudy )
return;
SALOMEDS::Study_var aStudyDS = GeometryGUI::ClientStudyToStudy(aStudy);
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr ) return;
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
GEOM::string_array_var ObjectIORs = new GEOM::string_array();
ObjectIORs->length( aSelList.Extent());
int aaa=0;
for ( SALOME_ListIteratorOfListIO It( aSelList ); It.More(); It.Next() ) {
Handle( SALOME_InteractiveObject ) io = It.Value();
// if ( io->IsKind(STANDARD_TYPE(GEOM_InteractiveObject))) {
// Handle(GEOM_InteractiveObject) objectGEOM = Handle(GEOM_InteractiveObject)::DownCast( io );
// const char* ior = objectGEOM->getIOR();
// objectGEOM.getEntry();
// objectGEOM.getName();
// std::cout << "\n\n\n !!!!! IOR = " << ior << std::endl;
// }
GEOM::GEOM_Object_var myObject = GEOM::GEOM_Object::_nil();
myObject = GEOMBase::ConvertIOinGEOMObject( io );
QString ior = GEOMBase::GetIORFromObject(myObject);
ObjectIORs[aaa] = ior.toLatin1().constData();
aaa++;
std::cout << "\n\n IOR = " << ior.toStdString() << std::endl;
// if ( !CORBA::is_nil( myObject ) )
// myGrp->LineEdit1->setText( GEOMBase::GetName( myObject ) );
}
//
// SALOME_ListIO selected;
// aSelMgr->selectedObjects( selected );
// if ( selected.IsEmpty() ) return;
//
// GEOM::string_array ObjectIORs;
// ObjectIORs.lenght( selected.Extent())
// for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
// Handle( SALOME_InteractiveObject ) io = It.Value();
// const char* entry = io->getEntry();
// ObjectIORs.push_back( entry );
// //CORBA::String_var IOR = app->orb()->object_to_string( io );
// //if ( strcmp(IOR.in(), "") != 0 )
// //{
//// QString objIOR = GEOMBase::GetIORFromObject( io );
// //char* GetStringFromIOR(GEOM::GEOM_Object_ptr theObject)
//
// }
SALOMEDS::TMPFile_var SeqFile =
GeometryGUI::GetGeomGen()->GetDependencyTree( aStudyDS, ObjectIORs );
char* buf;
buf = (char*) &SeqFile[0];
std::cout << "\n\n\n\n\n TREE = " << buf << std::endl;
}
DependencyTree_View::~DependencyTree_View()
{
}
void DependencyTree_View::drawArrows()
{
QMap<QString,QPair<LevelsList,LevelsList> >::iterator i;
for (i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) {
DependencyTree_Object* Main_object = myTreeMap[i.key()];
LevelInfo Levelup = i.value().first.at(0);
if( myDisplayAscendants ->isChecked() ) {
QMap<QString, NodeLinks>::iterator node;
for (node = Levelup.begin(); node != Levelup.end(); node++ ) {
DependencyTree_Object* object = myTreeMap[node.key()];
addArrow(Main_object, object);
}
}
if( myDisplayAscendants ->isChecked() )
drawWardArrows( i.value().first );
if( myDisplayDescendants->isChecked() )
drawWardArrows( i.value().second );
}
}
void DependencyTree_View::drawWardArrows( LevelsList theWard )
{
for(int j = 0; j < theWard.size(); j++ ) {
if( j >= myLevelsNumber )
break;
LevelInfo Level = theWard.at(j);
QMap<QString, NodeLinks>::iterator node;
for (node = Level.begin(); node != Level.end(); node++ ) {
DependencyTree_Object* object = myTreeMap[node.key()];
QList<QString> Links = node.value();
for( int link = 0; link < Links.size(); link++ ) {
DependencyTree_Object* LinkObject = myTreeMap[Links[link]];
if( isItemAdded( object ) && isItemAdded( LinkObject ) ) {
addArrow(object, LinkObject);
}
}
}
}
}
void DependencyTree_View::parseData( QString& theData )
{
int cursor = 0;
while( theData.indexOf('-',cursor) != -1 ) //find next selected object
{
int objectIndex = theData.indexOf( '-', cursor );
QString objectEntry = theData.mid( cursor, objectIndex - cursor );
addNode( objectEntry );
std::cout<<"\n\nMainObject = " << objectEntry.toStdString() <<std::endl;
cursor = objectIndex;
int upwardIndexBegin = theData.indexOf("{",cursor) + 1;
int upwardIndexFinish = theData.indexOf("}",upwardIndexBegin);
std::cout<<" Upward:" << std::endl;
LevelsList upwardList = parseWard( theData, cursor );
if( upwardList.size() > myMaxUpwardLevelsNumber )
myMaxUpwardLevelsNumber = upwardList.size();
std::cout<<" Downward:" << std::endl;
LevelsList downwardList = parseWard( theData, cursor );
if( downwardList.size() > myMaxDownwardLevelsNumber )
myMaxDownwardLevelsNumber = downwardList.size();
myTreeModel[objectEntry] = QPair<LevelsList,LevelsList>( upwardList, downwardList );
}
}
void DependencyTree_View::addNode( const QString& theEntry )
{
if( !myTreeMap[theEntry] )
myTreeMap[theEntry] = new DependencyTree_Object( theEntry );
}
void DependencyTree_View::addArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem )
{
bool isFind = false;
std::cout << " " << startItem->getEntry().toStdString() << " " << endItem->getEntry().toStdString() << std::endl;
for( int i = 0; i < Arrows.size(); i++ ) {
DependencyTree_Arrow* arrow = Arrows.at(i);
if( arrow->getStartItem() == startItem && arrow->getEndItem() == endItem ) {
isFind = true;
std::cout<<" theSame " << std::endl;
}
else if( arrow->getStartItem() == endItem && arrow->getEndItem() == startItem ) {
arrow->setIsBiLink( true );
std::cout<<" Bilink " << std::endl;
isFind = true;
}
}
if( !isFind ) {
DependencyTree_Arrow *arrow = new DependencyTree_Arrow(startItem, endItem);
Arrows.append( arrow );
addItem(arrow);
std::cout<<" addArrow " << std::endl;
}
}
DependencyTree_View::LevelsList DependencyTree_View::parseWard( const QString& theData, int& theCursor )
{
int indexStart = theData.indexOf( "{", theCursor ) + 1;
int indexEnd = theData.indexOf( "}", indexStart );
QString ward = theData.mid( indexStart, indexEnd - indexStart );
QStringList levelsListStr = ward.split( ';' );
LevelsList levelsListData;
for( int level = 0; level < levelsListStr.size(); level++ ) {
std::cout<<" Level" << level + 1 << ":" << std::endl;
QStringList namesListStr = levelsListStr[level].split( ',' );
LevelInfo levelInfoData;
for( int node = 0; node < namesListStr.size(); node++ ) {
QStringList linksListStr = namesListStr[node].split( '_' );
QString nodeItem = linksListStr[0];
if( !nodeItem.isEmpty() ) {
addNode( nodeItem );
NodeLinks linksListData;
std::cout<<" " << nodeItem.toStdString() << " - ";
for( int link = 1; link < linksListStr.size(); link++ ) {
QString linkItem = linksListStr[link];
addNode( linkItem );
linksListData.append( linkItem );
std::cout << linkItem.toStdString() << ", ";
}// Links
levelInfoData[nodeItem] = linksListData;
std::cout << std::endl;
}
}// Level's objects
levelsListData.append(levelInfoData);
}// Levels
theCursor = indexEnd + 1;
return levelsListData;
}
void DependencyTree_View::drawTree()
{
int horDistance, verDistance;
myCurrentLevel = 0;
std::cout<<"\n\n\n\n MY TREE MODEL SIZE = " << myTreeModel.size() << std::endl;
std::cout<<"\n\n\n\n MY TREE MAP SIZE = " << myTreeMap.size() << std::endl;
for( int j = 0; j < myTreeModel.keys().size(); j++ )
std::cout<< " STRING = " << myTreeModel.keys().at(j).toStdString() << std::endl;
QMap<QString,QPair<LevelsList,LevelsList> >::iterator i;
for (i = myTreeModel.begin(); i != myTreeModel.end(); i++ ) {
myCurrentLevel = 0;
QString objectEntry = i.key();
std::cout<< " NAME = " << objectEntry.toStdString() << std::endl;
DependencyTree_Object* objectItem = myTreeMap[ objectEntry ];
objectItem->setEnabled(true);
if( objectItem->isEnabled() )
std::cout<<"OK!!! "<< std::endl;
horDistance = 100 + int( objectItem->boundingRect().width() );
verDistance = 3 * int( objectItem->boundingRect().height() );
if( isItemAdded( objectItem ) ) {
myCurrentLevel = myLevelMap[ objectEntry ];
}
else {
addItem( objectItem );
std::cout<<"\nLevel = " << myCurrentLevel << " Object = " << objectEntry.toStdString() << std::endl;
myLevelMap[ objectEntry ] = myCurrentLevel;
myLevelsObject[ myCurrentLevel ].append( objectEntry );
}
objectItem->setIsMainObject( true );
int levelposition = myCurrentLevel;
if( myDisplayAscendants ->isChecked() ){
drawWard( i.value().first, -1 );
myCurrentLevel = levelposition;
}
if( myDisplayDescendants->isChecked() )
drawWard( i.value().second, 1 );
//centerOn( objectItem );
}
QMap< int, QList<QString> >::iterator j;
for (j = myLevelsObject.begin(); j != myLevelsObject.end(); j++ ) {
int step = -horDistance*( j.value().size() - 1 )/2;
std::cout<<"\n\n LEVEL = " << j.key() << std::endl;
for( int object = 0; object < j.value().size(); object++ ) {
if( myIsCompute ) {
std::cout << j.value().at( object ).toStdString() << ", ";
DependencyTree_Object* anObject = myTreeMap[ j.value().at( object ) ];
anObject->setPos( step, verDistance*j.key() );
step += horDistance;
//sleep(1);
}
}
}
}
void DependencyTree_View::drawWard( const DependencyTree_View::LevelsList theWard, const int theLevelStep )
{
int levelsNumber = theWard.size();
for( int level = 0; level < levelsNumber; level++ ) {
if( level >= myLevelsNumber )
return;
myCurrentLevel += theLevelStep;
LevelInfo levelInfo = theWard.at( level );
QMap<QString, NodeLinks>::iterator node;
for (node = levelInfo.begin(); node != levelInfo.end(); node++ ) {
DependencyTree_Object* object = myTreeMap[ node.key() ];
if( !isItemAdded( object ) ) {
addItem( object );
myLevelMap[ node.key() ] = myCurrentLevel;
myLevelsObject[ myCurrentLevel ].append( node.key() );
}
}
}
}
void DependencyTree_View::onUpdateTree()
{
myLevelMap.clear();
myLevelsObject.clear();
QMap<QString,DependencyTree_Object*>::iterator i;
for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) {
DependencyTree_Object* object = myTreeMap[ i.key() ];
if( isItemAdded( object ) && object )
removeItem( object );
}
std::cout<<"\n\n\n\n ARROWS = " << Arrows.size() << std::endl;
for(int j = 0; j<Arrows.size();j++)
if( isItemAdded( Arrows[j]) )
removeItem( Arrows[j] );
Arrows.clear();
drawTree();
drawArrows();
}
int DependencyTree_View::checkMaxLevelsNumber()
{
if( myDisplayAscendants ->isChecked() && myDisplayDescendants->isChecked() )
return myMaxUpwardLevelsNumber>myMaxDownwardLevelsNumber?myMaxUpwardLevelsNumber:myMaxDownwardLevelsNumber;
else if( myDisplayAscendants ->isChecked() )
return myMaxUpwardLevelsNumber;
else if( myDisplayDescendants->isChecked() )
return myMaxDownwardLevelsNumber;
}
void DependencyTree_View::init( GraphicsView_ViewFrame* theViewFrame )
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QString Data = "MainObject1-upward{up11_up21_up22,up12_up23,up13_up24;up21_up11,up22_up21_up12,up23_up23,up24}"
"downward{down11_MainObject1,down12_MainObject1;down21_down11,down22_down12,down23_down12,down24_down24_down11,down25_down12;down31_down11_down23,down32_down25}"
"down23-upward{down12_MainObject1;MainObject1_up11_up12_up13;up11_up21_up22,up12_up23,up13_up24;up21,up22_up21_up12,up23,up24}"
"downward{down31_down11_down23}"
"MainObject2-upward{up21,newup11_newup31,newup12_newup21;newup21_newup31LongName;newup31LongName}downward{newdown11_MainObject2,newdown12_MainObject2,newdown13_MainObject2;newdown21_newdown13,down21;newdown31_newdown11}";
parseData( Data );
myNodesMovable = new QCheckBox( tr( "MOVE_NODES" ) );
QWidgetAction* moveNodesAction = new QWidgetAction( theViewFrame );
moveNodesAction->setDefaultWidget( myNodesMovable );
myDisplayAscendants = new QCheckBox( tr( "DISPLAY_ASCENDANTS" ));
myDisplayAscendants ->setChecked( true );
QWidgetAction* ShowParentsAction = new QWidgetAction(theViewFrame);
ShowParentsAction->setDefaultWidget( myDisplayAscendants );
myDisplayDescendants = new QCheckBox(tr("DISPLAY_DESCENDANTS"));
QWidgetAction* ShowChildrenAction = new QWidgetAction(theViewFrame);
ShowChildrenAction->setDefaultWidget( myDisplayDescendants );
myLevelsNumber = checkMaxLevelsNumber();
myHierarchyDepth = new QSpinBox();
myHierarchyDepth->setRange( 0, checkMaxLevelsNumber() );
myHierarchyDepth->setValue( 0 );
myHierarchyDepth->setSpecialValueText( "All" );
QWidgetAction* LevelsAction = new QWidgetAction(theViewFrame);
LevelsAction->setDefaultWidget( myHierarchyDepth );
QLabel* LevelsLabel = new QLabel( tr("HIERARCHY_DEPTH") );
QWidgetAction* LevelsLebelAction = new QWidgetAction(theViewFrame);
LevelsLebelAction->setDefaultWidget( LevelsLabel );
QPushButton* UpdateButton = new QPushButton(tr("Update"));
QWidgetAction* UpdateAction = new QWidgetAction(theViewFrame);
UpdateAction->setDefaultWidget( UpdateButton );
cancelButton = new QPushButton(tr("CANCEL"));
cancelButton->setCheckable(true);
cancelButton->setVisible( false );
cancelAction = new QWidgetAction(theViewFrame);
cancelAction->setDefaultWidget( cancelButton );
cancelAction->setVisible(false);
progressBar = new QProgressBar(this);
progressBar->setMinimum( 0 );
progressBar->setMaximum( 1000 );
progressBar->setFixedWidth(100);
progressAction = new QWidgetAction(theViewFrame);
progressAction->setDefaultWidget( progressBar );
progressAction->setVisible(false);
QAction* separator = theViewFrame->toolMgr()->separator(false);
theViewFrame->toolMgr()->append( separator, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( moveNodesAction, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( LevelsLebelAction, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( LevelsAction, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( ShowParentsAction, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( ShowChildrenAction, theViewFrame->getToolBarId() );
QAction* separator2 = theViewFrame->toolMgr()->separator(false);
theViewFrame->toolMgr()->append( separator2, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( UpdateAction, theViewFrame->getToolBarId() );
std::cout<<"\n\n\n\n ToolBarId = " << theViewFrame->getToolBarId() << std::endl;
theViewFrame->toolMgr()->append( progressAction, theViewFrame->getToolBarId() );
theViewFrame->toolMgr()->append( cancelAction, theViewFrame->getToolBarId() );
connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
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( updateView() ) );
connect( myNodesMovable, SIGNAL( toggled(bool) ), this, SLOT( onMoveNodes( bool ) ) );
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 ) );
}
void DependencyTree_View::onMoveNodes( bool theIsMoveNodes )
{
QMap<QString,DependencyTree_Object*>::iterator i;
for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) {
DependencyTree_Object* object = myTreeMap[ i.key() ];
object->setMovable( theIsMoveNodes );
}
}
void DependencyTree_View::onHierarchyType()
{
myHierarchyDepth->setRange( 0, checkMaxLevelsNumber() );
if( myHierarchyDepth->value() > checkMaxLevelsNumber() )
myHierarchyDepth->setValue( checkMaxLevelsNumber() );
if( myHierarchyDepth->value() == 0 )
myLevelsNumber = myHierarchyDepth->maximum();
else
myLevelsNumber = myHierarchyDepth->value();
updateView();
}
void DependencyTree_View::updateView()
{
if( !myIsUpdate )
return;
myLevelMap.clear();
myLevelsObject.clear();
QMap<QString,DependencyTree_Object*>::iterator i;
for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) {
DependencyTree_Object* object = myTreeMap[ i.key() ];
if( isItemAdded( object ) && object )
removeItem( object );
}
std::cout<<"\n\n\n\n ARROWS = " << Arrows.size() << std::endl;
for(int j = 0; j<Arrows.size();j++)
if( isItemAdded( Arrows[j]) )
removeItem( Arrows[j] );
Arrows.clear();
iter = 0;
qthread = new DependencyTree_ComputeDlg_QThread(this);// = DependencyTree_ComputeDlg_QThread(this);// const_cast<DependencyTree_View*>(this) );
cancelAction->setVisible( true );
progressAction->setVisible(true);
startTimer(100); // millisecs
qthread->start();
}
void DependencyTree_View::onRedrawTree()
{
drawTree();
drawArrows();
}
void DependencyTree_View::onCancel()
{
qthread->cancel();
cancelButton->setText( tr("CANCELING"));
cancelButton->setEnabled(false);
}
void DependencyTree_View::timerEvent(QTimerEvent *event)
{
if ( !cancelButton->isChecked() ) // not yet cancelled
// progressBar->setValue( progressBar->maximum() * qthread.getMesh()->GetComputeProgress() );
progressBar->setValue( iter++ );
if(!myIsCompute || qthread->isFinished())
{
cancelAction->setVisible( false );
progressAction->setVisible(false);
cancelButton->setText( tr("CANCEL"));
cancelButton->setEnabled(true);
}
event->accept();
}
void DependencyTree_View::closeEvent(QCloseEvent *event)
{
if(qthread->isRunning())
{
event->ignore();
return;
}
event->accept();
}
void DependencyTree_View::setIsCompute( bool theIsCompute )
{
myIsCompute = theIsCompute;
}
void DependencyTree_View::setHierarchyType( const int theType )
{
myIsUpdate = false;
switch( theType ) {
case 0:
myDisplayAscendants->setChecked( true );
myDisplayDescendants->setChecked( true );
break;
case 1:
myDisplayAscendants->setChecked( true );
myDisplayDescendants->setChecked( false );
break;
case 2:
myDisplayAscendants->setChecked( false );
myDisplayDescendants->setChecked( true );
break;
}
myIsUpdate = true;
onHierarchyType();
}
void DependencyTree_View::setNodesMovable( const bool theIsMovable )
{
myNodesMovable->setChecked( theIsMovable );
}
void DependencyTree_View::setPrefBackgroundColor( const QColor& theColor )
{
if( isForegroundEnabled() )
{
setForegroundColor( theColor );
updateForeground();
}
else
setBackgroundColor( theColor );
}
void DependencyTree_View::setNodeColor( const QColor& theColor )
{
QMap<QString,DependencyTree_Object*>::iterator i;
for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) {
DependencyTree_Object* object = myTreeMap[ i.key() ];
object->setColor( theColor );
}
}
void DependencyTree_View::setMainNodeColor( const QColor& theColor )
{
QMap<QString,DependencyTree_Object*>::iterator i;
for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) {
DependencyTree_Object* object = myTreeMap[ i.key() ];
object->setMainObjectColor( theColor );
}
}
void DependencyTree_View::setSelectNodeColor( const QColor& theColor )
{
QMap<QString,DependencyTree_Object*>::iterator i;
for (i = myTreeMap.begin(); i != myTreeMap.end(); i++ ) {
DependencyTree_Object* object = myTreeMap[ i.key() ];
object->setSelectColor( theColor );
}
}
void DependencyTree_View::setArrowColor( const QColor& theColor )
{
for( int i = 0; i < Arrows.size(); i++ ) {
DependencyTree_Arrow* arrow = Arrows[i];
arrow->setColor( theColor );
}
}
void DependencyTree_View::setHighlightArrowColor( const QColor& theColor )
{
for( int i = 0; i < Arrows.size(); i++ ) {
DependencyTree_Arrow* arrow = Arrows[i];
arrow->setHighlightColor( theColor );
}
}
void DependencyTree_View::setSelectArrowColor( const QColor& theColor )
{
for( int i = 0; i < Arrows.size(); i++ ) {
DependencyTree_Arrow* arrow = Arrows[i];
arrow->setSelectColor( theColor );
}
}
//================================================================================
//================================================================================
DependencyTree_ComputeDlg_QThread::DependencyTree_ComputeDlg_QThread(DependencyTree_View* theView)
{
myView = theView;
}
void DependencyTree_ComputeDlg_QThread::run()
{
myView->setIsCompute( true );
myView->onRedrawTree();
}
bool DependencyTree_ComputeDlg_QThread::result()
{
}
void DependencyTree_ComputeDlg_QThread::cancel()
{
myView->setIsCompute( false );
}
////================================================================================
////================================================================================
//
//DependencyTree_ComputeDlg_QThreadQDialog::DependencyTree_ComputeDlg_QThreadQDialog(QWidget* parent,
// DependencyTree_View* theView)
// : QDialog(parent,
// Qt::WindowSystemMenuHint |
// Qt::WindowCloseButtonHint |
// Qt::Dialog |
// Qt::WindowMaximizeButtonHint),
// qthread( theView )
//{
// // --
// setWindowTitle(tr("TITLE"));
// setMinimumWidth( 200 );
//
// cancelButton = new QPushButton(tr("CANCEL"));
// cancelButton->setDefault(true);
// cancelButton->setCheckable(true);
//
// progressBar = new QProgressBar(this);
// progressBar->setMinimum( 0 );
// progressBar->setMaximum( 1000 );
//
// QGridLayout* layout = new QGridLayout(this);
// layout->setMargin( 11 );
// layout->setSpacing( 6 );
// int row = 0;
// layout->addWidget(progressBar, row++, 0, 1, 2);
// layout->addWidget(cancelButton, row++, 0, 1, 2);
// adjustSize();
// update();
//
// connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
// // --
// startTimer(300); // millisecs
// qthread.start();
//}
//
//bool DependencyTree_ComputeDlg_QThreadQDialog::result()
//{
// return qthread.result();
//}
//
//void DependencyTree_ComputeDlg_QThreadQDialog::onCancel()
//{
// qthread.cancel();
// cancelButton->setText( tr("CANCELING"));
// cancelButton->setEnabled(false);
//}
//
//void DependencyTree_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
//{
// if ( !cancelButton->isChecked() ) // not yet cancelled
// // progressBar->setValue( progressBar->maximum() * qthread.getMesh()->GetComputeProgress() );
// progressBar->setValue( 10 );
//
// if(qthread.isFinished())
// {
// close();
// }
//
// event->accept();
//}
//
//void DependencyTree_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
//{
// if(qthread.isRunning())
// {
// event->ignore();
// return;
// }
// event->accept();
//}
//

View File

@ -0,0 +1,178 @@
// 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_VIEW_H
#define DEPENDENCYTREE_VIEW_H
#include <GraphicsView_ViewPort.h>
#include <GraphicsView_ViewFrame.h>
#include <QGraphicsView>
#include <QList>
#include <QMap>
#include <QString>
#include <QPair>
#include <QWidgetAction>
#include <QSpinBox>
#include <QCheckBox>
#include <QProgressBar>
#include <QThread>
#include <QDialog>
#include "DependencyTree_Arrow.h"
class DependencyTree_Object;
class DependencyTree_View;
class DependencyTree_ComputeDlg_QThread : public QThread
{
Q_OBJECT
public:
DependencyTree_ComputeDlg_QThread(DependencyTree_View*);
bool result();
void cancel();
DependencyTree_View* getView() { return myView; };
protected:
void run();
private:
DependencyTree_View* myView;
};
class DependencyTree_View: public GraphicsView_ViewPort
{
Q_OBJECT
public:
DependencyTree_View( QWidget* theParent=0 );
~DependencyTree_View();
void setHierarchyType( const int );
void setNodesMovable( const bool );
void setPrefBackgroundColor( const QColor& );
void setNodeColor( const QColor& );
void setMainNodeColor( const QColor& );
void setSelectNodeColor( const QColor& );
void setArrowColor( const QColor& );
void setHighlightArrowColor( const QColor& );
void setSelectArrowColor( const QColor& );
typedef QList<QString> NodeLinks;
typedef QMap<QString, NodeLinks> LevelInfo;
typedef QList<LevelInfo> LevelsList;
typedef QMap<QString,QPair<LevelsList,LevelsList> > TreeModel;
TreeModel myTreeModel;
QMap<QString,DependencyTree_Object*> myTreeMap;
QList<DependencyTree_Arrow*> Arrows;
QMap<QString,int> myLevelMap;
QMap< int, QList<QString> > myLevelsObject;
int myCurrentLevel;
void init( GraphicsView_ViewFrame* );
void onRedrawTree();
void setIsCompute( bool theIsCompute );
bool getIsCompute() { return myIsCompute; };
private slots:
void onUpdateTree();
void updateView();
void onMoveNodes( bool );
void onHierarchyType();
protected:
void timerEvent(QTimerEvent *timer);
void closeEvent(QCloseEvent *event);
private slots:
void onCancel();
private:
void parseData( QString& data );
void addNode( const QString& entry );
void addArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
void findArrow( DependencyTree_Object *startItem, DependencyTree_Object *endItem );
DependencyTree_View::LevelsList parseWard( const QString& data, int& cursor );
void drawTree();
void drawWard( DependencyTree_View::LevelsList ward, const int levelStep );
void drawArrows();
void drawWardArrows( LevelsList );
int checkMaxLevelsNumber();
int myLevelsNumber;
int myMaxDownwardLevelsNumber;
int myMaxUpwardLevelsNumber;
QCheckBox* myNodesMovable;
QSpinBox* myHierarchyDepth;
QCheckBox* myDisplayAscendants;
QCheckBox* myDisplayDescendants;
QString myData;
bool myIsUpdate;
GraphicsView_ViewFrame* myViewFrame;
bool myIsCompute;
DependencyTree_ComputeDlg_QThread* qthread;
QPushButton * cancelButton;
QProgressBar* progressBar;
QWidgetAction* cancelAction;
QWidgetAction* progressAction;
};
///*!
// * \brief Dialog to display Cancel button
// */
//
//class DependencyTree_ComputeDlg_QThreadQDialog : public QDialog
//{
// Q_OBJECT
//
//public:
// DependencyTree_ComputeDlg_QThreadQDialog(QWidget* parent, DependencyTree_View*);
// bool result();
//
//protected:
// void timerEvent(QTimerEvent *timer);
// void closeEvent(QCloseEvent *event);
//
//private slots:
// void onCancel();
//
//private:
//
// DependencyTree_ComputeDlg_QThread qthread;
// QPushButton * cancelButton;
// QProgressBar* progressBar;
//};
#endif

View File

@ -0,0 +1,88 @@
// 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 <GraphicsView_Viewer.h>
#include "DependencyTree_ViewModel.h"
#include "DependencyTree_View.h"
#include <GraphicsView_ViewPort.h>
#include <QWidget>
#include <iostream>
DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title )
: GraphicsView_Viewer( title )
{
}
DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title, QWidget* w )
: GraphicsView_Viewer( title, w )
{
}
DependencyTree_ViewModel::~DependencyTree_ViewModel()
{
}
void DependencyTree_ViewModel::contextMenuPopup( QMenu* theMenu )
{
GraphicsView_Viewer::contextMenuPopup( theMenu );
std::cout<<"\n\n\n\n *****contextMenuPopup " << std::endl;
if( DependencyTree_View* aViewPort = dynamic_cast<DependencyTree_View*>(getActiveViewPort()) )
{
int aNbSelected = aViewPort->nbSelected();
std::cout<<"\n aNbSelected " << aNbSelected << std::endl;
}
}
//SUIT_ViewWindow* DependencyTree_ViewModel::createView( SUIT_Desktop* theDesktop )
//{
// DependencyTree_ViewWindow* aViewFrame;
//if( myWidget )
// aViewFrame = new DependencyTree_ViewWindow( theDesktop, this, myWidget );
//else
// aViewFrame = new DependencyTree_ViewWindow( theDesktop, this );
//
//connect( aViewFrame, SIGNAL( keyPressed( QKeyEvent* ) ),
// this, SLOT( onKeyEvent( QKeyEvent* ) ) );
//
//connect( aViewFrame, SIGNAL( keyReleased( QKeyEvent* ) ),
// this, SLOT( onKeyEvent( QKeyEvent* ) ) );
//
//connect( aViewFrame, SIGNAL( mousePressed( QGraphicsSceneMouseEvent* ) ),
// this, SLOT( onMouseEvent( QGraphicsSceneMouseEvent* ) ) );
//
//connect( aViewFrame, SIGNAL( mouseMoving( QGraphicsSceneMouseEvent* ) ),
// this, SLOT( onMouseEvent( QGraphicsSceneMouseEvent* ) ) );
//
//connect( aViewFrame, SIGNAL( mouseReleased( QGraphicsSceneMouseEvent* ) ),
// this, SLOT( onMouseEvent( QGraphicsSceneMouseEvent* ) ) );
//
//connect( aViewFrame, SIGNAL( wheeling( QGraphicsSceneWheelEvent* ) ),
// this, SLOT( onWheelEvent( QGraphicsSceneWheelEvent* ) ) );
//
//return aViewFrame;
//}

View File

@ -0,0 +1,39 @@
// 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 <GraphicsView_Viewer.h>
#include <QWidget>
class DependencyTree_ViewModel: public GraphicsView_Viewer
{
public:
DependencyTree_ViewModel( const QString& title );
DependencyTree_ViewModel( const QString& title, QWidget* w );
~DependencyTree_ViewModel();
public:
virtual void contextMenuPopup( QMenu* );
// virtual SUIT_ViewWindow* createView( SUIT_Desktop* );
// static QString Type() { return "DependencyTree"; }
};

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="en_US">
<context>
<name>DependencyTree_View</name>
<message>
<source>DEPENDENCY_TREE</source>
<translation>Dependency Tree</translation>
</message>
<message>
<source>MOVE_NODES</source>
<translation>Move nodes</translation>
</message>
<message>
<source>HIERARCHY_DEPTH</source>
<translation>Hierarchy depth</translation>
</message>
<message>
<source>DISPLAY_ASCENDANTS</source>
<translation>Display ascendants</translation>
</message>
<message>
<source>DISPLAY_DESCENDANTS</source>
<translation>Display descendants</translation>
</message>
<message>
<source>CANCEL</source>
<translation>Cancel</translation>
</message>
<message>
<source>CANCELING</source>
<translation>Canceling...</translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR">
<context>
<name>@default</name>
<message>
<source>MEN_TEXTURE</source>
<translation>Texture</translation>
</message>
</context>
</TS>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS>
<context>
<name>@default</name>
<message>
<source>MEN_TEXTURE</source>
<translation type="unfinished">Texture</translation>
</message>
</context>
</TS>

View File

@ -39,6 +39,7 @@ INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/src/GEOMClient
${PROJECT_SOURCE_DIR}/src/GEOMImpl
${PROJECT_SOURCE_DIR}/src/GEOMUtils
${PROJECT_SOURCE_DIR}/src/DependencyTree
${CMAKE_CURRENT_SOURCE_DIR}
)
@ -58,6 +59,7 @@ SET(_link_LIBRARIES
Material
GEOMImpl
GEOMUtils
DependencyTree
${KERNEL_SALOMELocalTrace}
${KERNEL_SalomeDS}
${KERNEL_SalomeDSClient}

View File

@ -5024,6 +5024,62 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_PREVIEW</source>
<translation>Preview</translation>
</message>
<message>
<source>PREF_TAB_DEPENDENCY_VIEW</source>
<translation>Dependency Tree</translation>
</message>
<message>
<source>PREF_HIERARCHY_TYPE</source>
<translation>Hierarchy type</translation>
</message>
<message>
<source>MEN_ONLY_ASCENDANTS</source>
<translation>Display only ascendants tree</translation>
</message>
<message>
<source>MEN_ONLY_DESCENDANTS</source>
<translation>Display only descendants tree</translation>
</message>
<message>
<source>MEN_BOTH_ASCENDANTS_DESCENDANTS</source>
<translation>Display both ascendants and descendants trees</translation>
</message>
<message>
<source>GEOM_MOVE_POSSIBILITY</source>
<translation>Possibility to move nodes</translation>
</message>
<message>
<source>PREF_GROUP_DEPENDENCY_VIEW_COLOR</source>
<translation>Color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR</source>
<translation>Background color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_NODE_COLOR</source>
<translation>Default node color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR</source>
<translation>Main node color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR</source>
<translation>Selected node color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_ARROW_COLOR</source>
<translation>Arrow color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR</source>
<translation>Highlighted arrow color</translation>
</message>
<message>
<source>PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR</source>
<translation>Selected arrow color</translation>
</message>
<message>
<source>GEOM_ALL_IMPORT_FILES</source>
<translation>All supported formats ( %1 )</translation>

View File

@ -75,6 +75,10 @@
#include <LightApp_DataObject.h>
#include <LightApp_Preferences.h>
#include <GraphicsView_Viewer.h>
#include <DependencyTree_View.h>
#include <DependencyTree_ViewModel.h>
#include <SALOME_LifeCycleCORBA.hxx>
// #include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
@ -502,6 +506,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
case GEOMOp::OpClsBringToFront: //
case GEOMOp::OpCreateFolder: // POPUP MENU - CREATE FOLDER
case GEOMOp::OpSortChildren: // POPUP MENU - SORT CHILD ITEMS
case GEOMOp::OpShowDependencyTree: // POPUP MENU - SHOW DEPENDENCY TREE
libName = "GEOMToolsGUI";
break;
case GEOMOp::OpDMWireframe: // MENU VIEW - WIREFRAME
@ -1077,6 +1082,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpPredefMaterCustom, "POP_PREDEF_MATER_CUSTOM" );
createGeomAction( GEOMOp::OpCreateFolder, "POP_CREATE_FOLDER" );
createGeomAction( GEOMOp::OpSortChildren, "POP_SORT_CHILD_ITEMS" );
createGeomAction( GEOMOp::OpShowDependencyTree, "POP_SHOW_DEPENDENCY_TREE" );
createGeomAction( GEOMOp::OpShowAllDimensions, "POP_SHOW_ALL_DIMENSIONS" );
createGeomAction( GEOMOp::OpHideAllDimensions, "POP_HIDE_ALL_DIMENSIONS" );
@ -1622,6 +1628,10 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->insert( action( GEOMOp::OpSortChildren ), -1, -1 ); // Sort child items
mgr->setRule( action( GEOMOp::OpSortChildren ), QString("client='ObjectBrowser' and $component={'GEOM'} and nbChildren>1"), QtxPopupMgr::VisibleRule );
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->hide( mgr->actionId( action( myEraseAll ) ) );
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
@ -2617,6 +2627,50 @@ void GeometryGUI::createPreferences()
addPreference( tr( "GEOM_PREVIEW" ), operationsGroup,
LightApp_Preferences::Bool, "Geometry", "geom_preview" );
int DependencyViewId = addPreference( tr( "PREF_TAB_DEPENDENCY_VIEW" ) );
int hierarchy_type = addPreference( tr( "PREF_HIERARCHY_TYPE" ), DependencyViewId,
LightApp_Preferences::Selector, "Geometry", "dependency_tree_hierarchy_type" );
QStringList aHierarchyTypeList;
aHierarchyTypeList.append( tr("MEN_BOTH_ASCENDANTS_DESCENDANTS") );
aHierarchyTypeList.append( tr("MEN_ONLY_ASCENDANTS") );
aHierarchyTypeList.append( tr("MEN_ONLY_DESCENDANTS") );
QList<QVariant> aHierarchyTypeIndexesList;
aHierarchyTypeIndexesList.append(0);
aHierarchyTypeIndexesList.append(1);
aHierarchyTypeIndexesList.append(2);
setPreferenceProperty( hierarchy_type, "strings", aHierarchyTypeList );
setPreferenceProperty( hierarchy_type, "indexes", aHierarchyTypeIndexesList );
addPreference( tr( "GEOM_MOVE_POSSIBILITY" ), DependencyViewId,
LightApp_Preferences::Bool, "Geometry", "dependency_tree_move_nodes" );
int treeColorGroup = addPreference( tr( "PREF_GROUP_DEPENDENCY_VIEW_COLOR" ), DependencyViewId );
addPreference( tr( "PREF_DEPENDENCY_VIEW_BACKGROUND_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_background_color" );
addPreference( tr( "PREF_DEPENDENCY_VIEW_NODE_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_node_color" );
addPreference( tr( "PREF_DEPENDENCY_VIEW_MAIN_NODE_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_main_node_color" );
addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_NODE_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_select_node_color" );
addPreference( tr( "PREF_DEPENDENCY_VIEW_ARROW_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_arrow_color" );
addPreference( tr( "PREF_DEPENDENCY_VIEW_HIGHLIGHT_ARROW_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_highlight_arrow_color" );
addPreference( tr( "PREF_DEPENDENCY_VIEW_SELECT_ARROW_COLOR"), treeColorGroup,
LightApp_Preferences::Color, "Geometry", "dependency_tree_select_arrow_color" );
}
void GeometryGUI::preferencesChanged( const QString& section, const QString& param )
@ -2687,6 +2741,55 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
aDisplayer.UpdateViewer();
}
else if ( param.startsWith( "dependency_tree") )
{
SalomeApp_Application* app = getApp();
if ( !app ) return;
SUIT_ViewManager *svm = app->getViewManager( GraphicsView_Viewer::Type(), false );
if( !svm ) return;
if( DependencyTree_ViewModel* viewModel = dynamic_cast<DependencyTree_ViewModel*>( svm->getViewModel() ) )
if( DependencyTree_View* view = dynamic_cast<DependencyTree_View*>( viewModel->getActiveViewPort() ) ) {
if( param == QString("dependency_tree_hierarchy_type") ) {
int hierarchyType = aResourceMgr->integerValue( section, param, 0);
view->setHierarchyType( hierarchyType );
}
else if( param == QString("dependency_tree_move_nodes") ) {
bool isNodesMovable = aResourceMgr->booleanValue( section, param, true);
view->setNodesMovable( isNodesMovable );
}
else if( param == QString("dependency_tree_background_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 255, 255, 255 ) );
view->setPrefBackgroundColor( c );
}
else if( param == QString("dependency_tree_node_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 62, 180, 238 ) );
view->setNodeColor( c );
}
else if( param == QString("dependency_tree_main_node_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 238, 90, 125 ) );
view->setMainNodeColor( c );
}
else if( param == QString("dependency_tree_select_node_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 237, 243, 58 ) );
view->setSelectNodeColor( c );
}
else if( param == QString("dependency_tree_arrow_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 0, 0, 130 ) );
view->setArrowColor( c );
}
else if( param == QString("dependency_tree_highlight_arrow_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 0, 0, 255 ) );
view->setHighlightArrowColor( c );
}
else if( param == QString("dependency_tree_select_arrow_color") ) {
QColor c = aResourceMgr->colorValue( section, param, QColor( 255, 0, 0 ) );
view->setSelectArrowColor( c );
}
}
}
}
}

View File

@ -61,6 +61,7 @@ namespace GEOMOp {
OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH
OpCreateFolder = 1262, // POPUP MENU - CREATE FOLDER
OpSortChildren = 1263, // POPUP MENU - SORT CHILD ITEMS
OpShowDependencyTree = 1264, // POPUP MENU - SHOW DEPENDENCY TREE
// DisplayGUI ------------------//--------------------------------
OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION
OpShowAll = 2002, // MENU VIEW - SHOW ALL

View File

@ -38,6 +38,7 @@ INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/src/GEOMGUI
${PROJECT_SOURCE_DIR}/src/GEOMBase
${PROJECT_SOURCE_DIR}/src/Material
${PROJECT_SOURCE_DIR}/src/DependencyTree
${CMAKE_CURRENT_SOURCE_DIR}
)
@ -56,6 +57,7 @@ SET(_link_LIBRARIES
GEOM
GEOMBase
Material
DependencyTree
)
# --- headers ---

View File

@ -422,6 +422,8 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
break;
case GEOMOp::OpSortChildren:
OnSortChildren();
case GEOMOp::OpShowDependencyTree:
OnShowDependencyTree();
break;
default:
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));

View File

@ -90,6 +90,7 @@ private:
void OnClsBringToFront();
void OnCreateFolder();
void OnSortChildren();
void OnShowDependencyTree();
// Shortcut commands
void OnChangeTransparency( bool );

View File

@ -46,6 +46,8 @@
#include <GEOMBase.h>
#include <GEOM_Actor.h>
#include <DependencyTree.h>
#include <Basics_OCCTVersion.hxx>
#include <SALOME_ListIO.hxx>
@ -862,3 +864,8 @@ void GEOMToolsGUI::OnSortChildren()
app->updateObjectBrowser( true );
}
void GEOMToolsGUI::OnShowDependencyTree()
{
DependencyTree();
}