mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-15 12:43:08 +05:00
Update of text tree widget integration to new class
of shape annotation attributes
This commit is contained in:
parent
96407303b7
commit
c11f35e20d
@ -75,7 +75,6 @@ SET(GEOMGUI_HEADERS
|
||||
GEOM_GEOMGUI.hxx
|
||||
GEOMGUI_CreationInfoWdg.h
|
||||
GEOMGUI_TextTreeWdg.h
|
||||
GEOMGUI_VisualProperties.h
|
||||
GEOMGUI_DimensionProperty.h
|
||||
GEOMGUI_AnnotationAttrs.h
|
||||
)
|
||||
|
@ -147,12 +147,12 @@ void GEOMGUI_AnnotationAttrs::Remove( const _PTR(SObject)& theObject )
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetCount
|
||||
// function : SetNbAnnotation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::SetCount( const int theCount ) const
|
||||
void GEOMGUI_AnnotationAttrs::SetNbAnnotation( const int theCount ) const
|
||||
{
|
||||
const int aCount = this->GetCount();
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
|
||||
if ( aCount < theCount )
|
||||
{
|
||||
@ -187,10 +187,10 @@ void GEOMGUI_AnnotationAttrs::SetCount( const int theCount ) const
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetCount
|
||||
// function : GetNbAnnotation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
int GEOMGUI_AnnotationAttrs::GetCount() const
|
||||
int GEOMGUI_AnnotationAttrs::GetNbAnnotation() const
|
||||
{
|
||||
return myParameterMap->GetInt( PARAMETER_COUNT );
|
||||
}
|
||||
@ -354,8 +354,8 @@ void GEOMGUI_AnnotationAttrs::GetShapeSel( const int theIndex, int& theShapeType
|
||||
//=================================================================================
|
||||
void GEOMGUI_AnnotationAttrs::Append( const Properties& theProps )
|
||||
{
|
||||
const int aCount = this->GetCount();
|
||||
this->SetCount( aCount + 1 );
|
||||
const int aCount = this->GetNbAnnotation();
|
||||
this->SetNbAnnotation( aCount + 1 );
|
||||
this->SetProperties( aCount, theProps );
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#define GEOMGUI_ANNOTATIONATTRS_H
|
||||
|
||||
// SALOME GUI includes
|
||||
#include <GEOMGUI.h>
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
// OCCT includes
|
||||
@ -50,14 +51,14 @@ public:
|
||||
DEFINE_STANDARD_RTTIEXT( GEOMGUI_AnnotationAttrs, Standard_Transient )
|
||||
|
||||
//! Find annotation data defined for an object.
|
||||
Standard_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject );
|
||||
GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindAttributes( const _PTR(SObject)& theObject );
|
||||
|
||||
//! Find or create annotation data fields for an object.
|
||||
Standard_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject,
|
||||
GEOMGUI_EXPORT static Handle(GEOMGUI_AnnotationAttrs) FindOrCreateAttributes( const _PTR(SObject)& theObject,
|
||||
SalomeApp_Study* theStudy );
|
||||
|
||||
//! Remove annotation data fields for an object.
|
||||
Standard_EXPORT static void Remove( const _PTR(SObject)& theObject );
|
||||
GEOMGUI_EXPORT static void Remove( const _PTR(SObject)& theObject );
|
||||
|
||||
public:
|
||||
|
||||
@ -80,7 +81,7 @@ public:
|
||||
//! @param thePresentation [in] the presentation to setup.
|
||||
//! @param theProps [in] the set of properties.
|
||||
//! @param theLCS [in] the local coordinate system of the shape.
|
||||
Standard_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
GEOMGUI_EXPORT static void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const Properties& theProps,
|
||||
const gp_Ax3& theLCS );
|
||||
|
||||
@ -88,7 +89,7 @@ public:
|
||||
//! @param thePresentation [in] the presentation to setup.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theLCS [in] the local coordinate system of the shape.
|
||||
Standard_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
GEOMGUI_EXPORT void SetupPresentation( const Handle(GEOM_Annotation)& thePresentation,
|
||||
const int theIndex,
|
||||
const gp_Ax3& theLCS );
|
||||
|
||||
@ -98,84 +99,84 @@ public:
|
||||
//! If the count is decreased the extra annotation definitions are
|
||||
//! cleared out from the attribute.
|
||||
//! @param theNumber [in] the new number of annotation definitions.
|
||||
Standard_EXPORT void SetCount( const int theCount ) const;
|
||||
GEOMGUI_EXPORT void SetNbAnnotation( const int theCount ) const;
|
||||
|
||||
//! Returns number of annotation definitions stored on the object.
|
||||
Standard_EXPORT int GetCount() const;
|
||||
GEOMGUI_EXPORT int GetNbAnnotation() const;
|
||||
|
||||
//! Sets application name property of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theName [in] the new application name.
|
||||
Standard_EXPORT void SetName( const int theIndex, const QString& theName );
|
||||
GEOMGUI_EXPORT void SetName( const int theIndex, const QString& theName );
|
||||
|
||||
//! Returns application name of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
Standard_EXPORT QString GetName( const int theIndex ) const;
|
||||
GEOMGUI_EXPORT QString GetName( const int theIndex ) const;
|
||||
|
||||
//! Sets application visibility state of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theIsVisible [in] the visibility state.
|
||||
Standard_EXPORT void SetIsVisible( const int theIndex, const bool theIsVisible );
|
||||
GEOMGUI_EXPORT void SetIsVisible( const int theIndex, const bool theIsVisible );
|
||||
|
||||
//! Returns applicationb visibility state of an annotaion definition.
|
||||
Standard_EXPORT bool GetIsVisible( const int theIndex ) const;
|
||||
GEOMGUI_EXPORT bool GetIsVisible( const int theIndex ) const;
|
||||
|
||||
//! Sets annotation label's text.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theText [in] the text string.
|
||||
Standard_EXPORT void SetText( const int theIndex, const QString& theText );
|
||||
GEOMGUI_EXPORT void SetText( const int theIndex, const QString& theText );
|
||||
|
||||
//! Returns annotation label's text.
|
||||
Standard_EXPORT QString GetText( const int theIndex ) const;
|
||||
GEOMGUI_EXPORT QString GetText( const int theIndex ) const;
|
||||
|
||||
//! Sets screen fixed flag of the annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theIsScreenFixed [in] the presentation flag.
|
||||
Standard_EXPORT void SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed );
|
||||
GEOMGUI_EXPORT void SetIsScreenFixed( const int theIndex, const bool theIsScreenFixed );
|
||||
|
||||
//! Returns screen fixed flag of the annotation definition.
|
||||
Standard_EXPORT bool GetIsScreenFixed( const int theIndex ) const;
|
||||
GEOMGUI_EXPORT bool GetIsScreenFixed( const int theIndex ) const;
|
||||
|
||||
//! Sets position of the annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param thePosition [in] the position of the annotation label.
|
||||
Standard_EXPORT void SetPosition( const int theIndex, const gp_Pnt& thePosition );
|
||||
GEOMGUI_EXPORT void SetPosition( const int theIndex, const gp_Pnt& thePosition );
|
||||
|
||||
//! Returns position of the annotation definition.
|
||||
Standard_EXPORT gp_Pnt GetPosition( const int theIndex ) const;
|
||||
GEOMGUI_EXPORT gp_Pnt GetPosition( const int theIndex ) const;
|
||||
|
||||
//! Sets attach point of the annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theAttach [in] the attach point of the annotation.
|
||||
Standard_EXPORT void SetAttach( const int theIndex, const gp_Pnt& theAttach );
|
||||
GEOMGUI_EXPORT void SetAttach( const int theIndex, const gp_Pnt& theAttach );
|
||||
|
||||
//! Returns attach point of the annotation definition.
|
||||
Standard_EXPORT gp_Pnt GetAttach( const int theIndex ) const;
|
||||
GEOMGUI_EXPORT gp_Pnt GetAttach( const int theIndex ) const;
|
||||
|
||||
//! Sets shape selection arguments.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theShapeType, theSubIdx [in] the type of the selected shape and the sub-shape index.
|
||||
Standard_EXPORT void SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx );
|
||||
GEOMGUI_EXPORT void SetShapeSel( const int theIndex, const int theShapeType, const int theSubIdx );
|
||||
|
||||
//! Returns shape selection arguments.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theShapeType, theSubIdx [out] the type of the selected shape and the sub-shape index.
|
||||
Standard_EXPORT void GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const;
|
||||
GEOMGUI_EXPORT void GetShapeSel( const int theIndex, int& theShapeType, int& theSubIdx ) const;
|
||||
|
||||
public:
|
||||
|
||||
//! Appends new annotation definition with the given properties.
|
||||
Standard_EXPORT void Append( const Properties& theProps );
|
||||
GEOMGUI_EXPORT void Append( const Properties& theProps );
|
||||
|
||||
//! Sets complete properties of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [in] the structure containing the properties.
|
||||
Standard_EXPORT void SetProperties( const int theIndex, const Properties& theProps );
|
||||
GEOMGUI_EXPORT void SetProperties( const int theIndex, const Properties& theProps );
|
||||
|
||||
//! Returns complete properties of an annotation definition.
|
||||
//! @param theIndex [in] the index of the annotation definition.
|
||||
//! @param theProps [out] the structure containing the properties.
|
||||
Standard_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const;
|
||||
GEOMGUI_EXPORT void GetProperties( const int theIndex, Properties& theProps ) const;
|
||||
|
||||
private:
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
#define GEOMGUI_DIMENSIONPROPERTY_H
|
||||
|
||||
// OCCT includes
|
||||
#include <GEOMGUI_VisualProperties.h>
|
||||
|
||||
#include <AIS_DiameterDimension.hxx>
|
||||
#include <AIS_LengthDimension.hxx>
|
||||
#include <AIS_AngleDimension.hxx>
|
||||
@ -62,7 +60,7 @@ typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
|
||||
* Diam: (plane)[0-3] (flyout)[4] (text flags)[5-6] (arrow flag)[7] (circle loc, xdir, ydir, rad)[8-17]
|
||||
* Angle: (flyout)[0] (text flags)[1-2] (arrow flag)[3] (p1)[4-6] (p2)[7-9] (center)[10-12]
|
||||
*/
|
||||
class Standard_EXPORT GEOMGUI_DimensionProperty : public GEOMGUI_VisualProperties
|
||||
class Standard_EXPORT GEOMGUI_DimensionProperty
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "GEOMGUI_TextTreeWdg.h"
|
||||
|
||||
#include "GEOMGUI_DimensionProperty.h"
|
||||
//#include "GEOMGUI_ShapeAnnotations.h"
|
||||
#include "GEOMGUI_AnnotationAttrs.h"
|
||||
#include "GeometryGUI.h"
|
||||
#include "GeometryGUI_Operations.h"
|
||||
#include <GEOM_Constants.h>
|
||||
@ -50,6 +50,80 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QHash>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Common style interface for managing dimension and annotation properties
|
||||
// ----------------------------------------------------------------------------
|
||||
namespace
|
||||
{
|
||||
//! Access interface implementation for shape dimension attribute/property.
|
||||
class DimensionsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
|
||||
{
|
||||
public:
|
||||
|
||||
DimensionsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) :
|
||||
myStudy( theStudy ), myEntry( theEntry ) {
|
||||
myAttr.LoadFromAttribute( theStudy, theEntry );
|
||||
}
|
||||
virtual int GetNumber() Standard_OVERRIDE {
|
||||
return myAttr.GetNumber();
|
||||
}
|
||||
virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
|
||||
return myAttr.GetName( theIndex );
|
||||
}
|
||||
virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
|
||||
return myAttr.IsVisible( theIndex );
|
||||
}
|
||||
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
|
||||
myAttr.SetVisible( theIndex, theIsVisible );
|
||||
}
|
||||
virtual void Save() Standard_OVERRIDE {
|
||||
myAttr.SaveToAttribute( myStudy, myEntry );
|
||||
}
|
||||
GEOMGUI_DimensionProperty& Attr() { return myAttr; }
|
||||
|
||||
private:
|
||||
GEOMGUI_DimensionProperty myAttr;
|
||||
SalomeApp_Study* myStudy;
|
||||
std::string myEntry;
|
||||
};
|
||||
|
||||
//! Access interface implementation for shape annotation attribute.
|
||||
class AnnotationsProperty : public GEOMGUI_TextTreeWdg::VisualProperty
|
||||
{
|
||||
public:
|
||||
|
||||
AnnotationsProperty( SalomeApp_Study* theStudy, const std::string& theEntry ) {
|
||||
_PTR(SObject) aSObj = theStudy->studyDS()->FindObjectID( theEntry );
|
||||
myAttr = GEOMGUI_AnnotationAttrs::FindAttributes( aSObj );
|
||||
}
|
||||
virtual int GetNumber() Standard_OVERRIDE {
|
||||
return !myAttr.IsNull() ? myAttr->GetNbAnnotation() : 0;
|
||||
}
|
||||
virtual QString GetName( const int theIndex ) Standard_OVERRIDE {
|
||||
return !myAttr.IsNull() ? myAttr->GetName( theIndex ) : QString();
|
||||
}
|
||||
virtual bool GetIsVisible( const int theIndex ) Standard_OVERRIDE {
|
||||
return !myAttr.IsNull() ? myAttr->GetIsVisible( theIndex ) : false;
|
||||
}
|
||||
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) Standard_OVERRIDE {
|
||||
if ( !myAttr.IsNull() ) {
|
||||
myAttr->SetIsVisible( theIndex, theIsVisible );
|
||||
}
|
||||
}
|
||||
virtual void Save() Standard_OVERRIDE {
|
||||
/* every change is automatically saved */
|
||||
}
|
||||
Handle(GEOMGUI_AnnotationAttrs) Attr() { return myAttr; }
|
||||
|
||||
private:
|
||||
|
||||
Handle(GEOMGUI_AnnotationAttrs) myAttr;
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Text tree widget implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
||||
: myDisplayer(NULL)
|
||||
{
|
||||
@ -105,6 +179,7 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
||||
connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
|
||||
this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
|
||||
connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
|
||||
|
||||
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
|
||||
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
|
||||
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
|
||||
@ -145,7 +220,7 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
||||
if ( SC ) {
|
||||
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
|
||||
anIter->InitEx( true );
|
||||
QList<QString> aGeomObjEntries = getObjects( Geometry ).keys();
|
||||
QList<QString> aDimensionObjEntries = getObjects( DimensionShape ).keys();
|
||||
QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
|
||||
while( anIter->More() ) {
|
||||
_PTR(SObject) valSO ( anIter->Value() );
|
||||
@ -154,13 +229,13 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
||||
// update tree of object's dimensions
|
||||
QString anEntry = valSO->GetID().c_str();
|
||||
updateBranch( anEntry );
|
||||
aGeomObjEntries.removeAll( anEntry );
|
||||
aDimensionObjEntries.removeAll( anEntry );
|
||||
anAnnotationObjEntries.removeAll( anEntry );
|
||||
}
|
||||
anIter->Next();
|
||||
}
|
||||
foreach (QString entry, aGeomObjEntries) {
|
||||
removeBranch( Geometry, entry, true );
|
||||
foreach ( QString entry, aDimensionObjEntries ) {
|
||||
removeBranch( DimensionShape, entry, true );
|
||||
}
|
||||
foreach ( QString entry, anAnnotationObjEntries ) {
|
||||
removeBranch( AnnotationShape, entry, true );
|
||||
@ -175,33 +250,33 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
|
||||
{
|
||||
/// dimension property branch
|
||||
fillBranch( Geometry, theEntry );
|
||||
// dimension property branch
|
||||
fillBranch( DimensionShape, theEntry );
|
||||
|
||||
// annotation property branch
|
||||
// fillBranch(AnnotationShape, theEntry);
|
||||
fillBranch( AnnotationShape, theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : fillBranch
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
|
||||
{
|
||||
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||
|
||||
if ( myStudy && !theEntry.isEmpty() ) {
|
||||
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
|
||||
int aNumber = aProp->GetNumber();
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
const std::string anEntry = theEntry.toStdString();
|
||||
|
||||
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||
|
||||
if (!aProp)
|
||||
if ( !aProp ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_PTR(Study) aStudyDS = myStudy->studyDS();
|
||||
if ( aStudyDS ) {
|
||||
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
|
||||
QString aName = obj->GetName().c_str();
|
||||
|
||||
int nbProps = aProp->GetNumber();
|
||||
const QString aName = obj->GetName().c_str();
|
||||
const int nbProps = aProp->GetNumber();
|
||||
|
||||
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
|
||||
if ( objectItem ) {
|
||||
@ -221,15 +296,11 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
|
||||
if ( aPropRootItem->childCount() == 1 )
|
||||
aPropRootItem->setExpanded( true );
|
||||
}
|
||||
bool isDisplayed = myDisplayer.IsDisplayed( theEntry );
|
||||
// read dimension records from property
|
||||
for ( int anIt = 0; anIt < aProp->GetNumber(); ++anIt ) {
|
||||
QString aName = aProp->GetName( anIt );
|
||||
bool isVisible = aProp->IsVisible( anIt );
|
||||
|
||||
for ( int anIt = 0; anIt < nbProps; ++anIt ) {
|
||||
const QString aPropName = aProp->GetName( anIt );
|
||||
const bool isVisible = aProp->GetIsVisible( anIt );
|
||||
QTreeWidgetItem* anItem = new QTreeWidgetItem;
|
||||
anItem->setText( 0, aName );
|
||||
// if ( isDisplayed )
|
||||
anItem->setText( 0, aPropName );
|
||||
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
|
||||
anItem->setData( 0, Qt::UserRole, anIt );
|
||||
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||
@ -244,18 +315,18 @@ void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QSt
|
||||
// function : getVisualProperty
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
VisualPropertiesPtr GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType )
|
||||
QSharedPointer<GEOMGUI_TextTreeWdg::VisualProperty>
|
||||
GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType,
|
||||
SalomeApp_Study* theStudy,
|
||||
const std::string& theEntry )
|
||||
{
|
||||
VisualPropertiesPtr aProp;
|
||||
|
||||
if ( theBranchType == Geometry ) {
|
||||
aProp = QSharedPointer<GEOMGUI_DimensionProperty>( new GEOMGUI_DimensionProperty() );
|
||||
switch ( theBranchType )
|
||||
{
|
||||
case DimensionShape : return QSharedPointer<VisualProperty>( new DimensionsProperty( theStudy, theEntry ) );
|
||||
case AnnotationShape : return QSharedPointer<VisualProperty>( new AnnotationsProperty( theStudy, theEntry ) );
|
||||
default: break;
|
||||
}
|
||||
else {
|
||||
//aProp = QSharedPointer<GEOMGUI_ShapeAnnotations>( new GEOMGUI_ShapeAnnotations() );
|
||||
}
|
||||
|
||||
return aProp;
|
||||
return QSharedPointer<VisualProperty>();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -290,16 +361,16 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
|
||||
|
||||
int aDimIndex = idFromItem( theItem );
|
||||
|
||||
VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
|
||||
aProp->LoadFromAttribute( myStudy, anEntry );
|
||||
if ( aProp->IsVisible( aDimIndex ) ) {
|
||||
aProp->SetVisible( aDimIndex, false );
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( aBranchType, myStudy, anEntry );
|
||||
|
||||
if ( aProp->GetIsVisible( aDimIndex ) ) {
|
||||
aProp->SetIsVisible( aDimIndex, false );
|
||||
theItem->setIcon( 1, myInvisibleIcon );
|
||||
} else {
|
||||
aProp->SetVisible( aDimIndex, true );
|
||||
aProp->SetIsVisible( aDimIndex, true );
|
||||
theItem->setIcon( 1, myVisibleIcon );
|
||||
}
|
||||
aProp->SaveToAttribute( myStudy, anEntry );
|
||||
aProp->Save();
|
||||
|
||||
redisplay( anEntry.c_str() );
|
||||
}
|
||||
@ -349,8 +420,10 @@ QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranch
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
|
||||
{
|
||||
//BranchType theBranchType,
|
||||
updateVisibilityColumn( Geometry, theEntry, theState );
|
||||
// dimension property branch
|
||||
updateVisibilityColumn( DimensionShape, theEntry, theState );
|
||||
|
||||
// annotation property branch
|
||||
updateVisibilityColumn( AnnotationShape, theEntry, theState );
|
||||
}
|
||||
|
||||
@ -367,15 +440,14 @@ void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchTyp
|
||||
anItem->setDisabled( theState != Qtx::ShownState );
|
||||
QTreeWidgetItem* aChildItem;
|
||||
|
||||
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
|
||||
QSharedPointer<VisualProperty> aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
|
||||
for ( int i=0; i < anItem->childCount(); i++ ) {
|
||||
aChildItem = anItem->child( i );
|
||||
if ( theState == Qtx::ShownState ) {
|
||||
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||
if ( aProp->GetNumber() == 0 )
|
||||
continue;
|
||||
aChildItem->setIcon( 1, aProp->IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
|
||||
aChildItem->setIcon( 1, aProp->GetIsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
|
||||
: myInvisibleIcon );
|
||||
aChildItem->setDisabled( false );
|
||||
} else {
|
||||
@ -402,13 +474,13 @@ void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
|
||||
QString anEntry = entryFromItem( anItem->parent() );
|
||||
if ( !anEntry.isEmpty() ) {
|
||||
BranchType aBranchType = branchTypeFromItem( anItem );
|
||||
VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
|
||||
QSharedPointer<VisualProperty>
|
||||
aProp = getVisualProperty( aBranchType, myStudy, anEntry.toStdString() );
|
||||
|
||||
aProp->LoadFromAttribute( myStudy, anEntry.toStdString() );
|
||||
if ( aProp->GetNumber() == 0 )
|
||||
return;
|
||||
aMenu.clear();
|
||||
if ( aProp->IsVisible( idFromItem( anItem ) ) )
|
||||
if ( aProp->GetIsVisible( idFromItem( anItem ) ) )
|
||||
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
||||
else
|
||||
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
||||
@ -434,12 +506,12 @@ void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisib
|
||||
BranchType aBranchType = branchTypeFromItem( theItem );
|
||||
if ( theItem == myDimensionsItem ||
|
||||
theItem == myAnnotationsItem ) {
|
||||
// set visibility for all dimensions
|
||||
|
||||
QTreeWidgetItem* anItem;
|
||||
foreach ( QString entry, getObjects( aBranchType ).keys() ) {
|
||||
anItem = itemFromEntry( aBranchType, entry );
|
||||
if ( !anItem->isDisabled() )
|
||||
setShapeDimensionsVisibility( aBranchType, entry, theVisibility );
|
||||
setAllShapeItemsVisibility( aBranchType, entry, theVisibility );
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -448,51 +520,76 @@ void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisib
|
||||
QString anEntry = entryFromItem( theItem );
|
||||
if ( !anEntry.isEmpty() ) {
|
||||
// it is a shape item
|
||||
setShapeDimensionsVisibility( aBranchType, anEntry, theVisibility );
|
||||
setAllShapeItemsVisibility( aBranchType, anEntry, theVisibility );
|
||||
} else {
|
||||
// it is a dimension item
|
||||
anEntry = entryFromItem( theItem->parent() );
|
||||
setDimensionVisibility( aBranchType, anEntry, theItem, theVisibility );
|
||||
setShapeItemVisibility( aBranchType, anEntry, theItem, theVisibility );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setShapeDimensionsVisibility
|
||||
// function : setAllShapeItemsVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( const BranchType& theBranchType,
|
||||
QString theEntry, bool theVisibility )
|
||||
void GEOMGUI_TextTreeWdg::setAllShapeItemsVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
const bool theVisibility )
|
||||
{
|
||||
QSharedPointer<VisualProperty>
|
||||
aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
|
||||
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
|
||||
QTreeWidgetItem* aChildItem;
|
||||
for ( int i=0; i < anItem->childCount(); i++ ) {
|
||||
aChildItem = anItem->child( i );
|
||||
setDimensionVisibility( theBranchType, theEntry, aChildItem, theVisibility );
|
||||
setShapeItemVisibility( aProp, aChildItem, theVisibility );
|
||||
}
|
||||
|
||||
aProp->Save();
|
||||
|
||||
redisplay( theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setDimensionVisibility
|
||||
// function : setShapeItemVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_TextTreeWdg::setDimensionVisibility( const BranchType& theBranchType, QString theEntry,
|
||||
QTreeWidgetItem* theDimItem, bool theVisibility )
|
||||
void GEOMGUI_TextTreeWdg::setShapeItemVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility )
|
||||
{
|
||||
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
|
||||
QSharedPointer<VisualProperty>
|
||||
aProp = getVisualProperty( theBranchType, myStudy, theEntry.toStdString() );
|
||||
|
||||
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||
int aDimIndex = idFromItem( theDimItem );
|
||||
if ( aProp->GetNumber() == 0 || aProp->IsVisible( aDimIndex ) == theVisibility )
|
||||
return;;
|
||||
aProp->SetVisible( aDimIndex, theVisibility );
|
||||
aProp->SaveToAttribute( myStudy, theEntry.toStdString() );
|
||||
|
||||
theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
|
||||
if ( setShapeItemVisibility( aProp, theWidgetItem, theVisibility ) ) {
|
||||
aProp->Save();
|
||||
redisplay( theEntry );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : setShapeItemVisibility
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool GEOMGUI_TextTreeWdg::setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility )
|
||||
{
|
||||
int aDimIndex = idFromItem( theWidgetItem );
|
||||
if ( theProps->GetNumber() == 0
|
||||
|| theProps->GetIsVisible( aDimIndex ) == theVisibility ) {
|
||||
return false;
|
||||
}
|
||||
theProps->SetIsVisible( aDimIndex, theVisibility );
|
||||
|
||||
theWidgetItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : redisplay
|
||||
@ -510,7 +607,7 @@ void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
|
||||
//=================================================================================
|
||||
QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType )
|
||||
{
|
||||
return theBranchType == Geometry ? myDimensionsItem : myAnnotationsItem;
|
||||
return (theBranchType == DimensionShape) ? myDimensionsItem : myAnnotationsItem;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -519,7 +616,7 @@ QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& the
|
||||
//=================================================================================
|
||||
QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType )
|
||||
{
|
||||
return theBranchType == Geometry ? myObjects : myAnnotationObjects;
|
||||
return (theBranchType == DimensionShape) ? myDimensionObjects : myAnnotationObjects;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -528,7 +625,7 @@ QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchT
|
||||
//=================================================================================
|
||||
GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem )
|
||||
{
|
||||
BranchType aBranchType = Geometry;
|
||||
BranchType aBranchType = DimensionShape;
|
||||
|
||||
bool aBranchTypeFound = false;
|
||||
QTreeWidgetItem* anItem = theItem;
|
||||
@ -536,7 +633,7 @@ GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWi
|
||||
if ( anItem == myDimensionsItem ||
|
||||
anItem == myAnnotationsItem) {
|
||||
aBranchTypeFound = true;
|
||||
aBranchType = anItem == myDimensionsItem ? Geometry : AnnotationShape;
|
||||
aBranchType = (anItem == myDimensionsItem) ? DimensionShape : AnnotationShape;
|
||||
}
|
||||
else {
|
||||
anItem = anItem->parent();
|
||||
|
51
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
Normal file → Executable file
51
src/GEOMGUI/GEOMGUI_TextTreeWdg.h
Normal file → Executable file
@ -22,10 +22,10 @@
|
||||
|
||||
#include "GEOM_GEOMGUI.hxx"
|
||||
#include "GEOM_Displayer.h"
|
||||
#include "GEOMGUI_VisualProperties.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QHash>
|
||||
#include <QSharedPointer>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include <SALOMEDSClient.hxx>
|
||||
|
||||
@ -36,7 +36,6 @@ class QTreeWidgetItem;
|
||||
class SalomeApp_Application;
|
||||
class SalomeApp_Study;
|
||||
|
||||
|
||||
/*!
|
||||
* \brief Tree view contains Dimension and Annotation text items:
|
||||
* - text visibility in OCC viewer
|
||||
@ -47,8 +46,7 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum BranchType { Geometry, AnnotationShape };
|
||||
|
||||
enum BranchType { DimensionShape, AnnotationShape };
|
||||
|
||||
public:
|
||||
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
|
||||
@ -61,11 +59,13 @@ public:
|
||||
int idFromItem( QTreeWidgetItem* theItem );
|
||||
QString entryFromItem( QTreeWidgetItem* theShapeItem );
|
||||
QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
|
||||
void setShapeDimensionsVisibility( const BranchType& theBranchType,
|
||||
QString theEntry, bool theVisibility );
|
||||
void setDimensionVisibility( const BranchType& theBranchType,
|
||||
QString theEntry, QTreeWidgetItem* theDimItem,
|
||||
bool theVisibility );
|
||||
void setAllShapeItemsVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
const bool theVisibility );
|
||||
void setShapeItemVisibility( const BranchType& theBranchType,
|
||||
const QString& theEntry,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility );
|
||||
protected:
|
||||
void createActions();
|
||||
void redisplay( QString theEntry );
|
||||
@ -80,9 +80,29 @@ private slots:
|
||||
void setVisibility( QTreeWidgetItem* theItem, bool visibility );
|
||||
void showContextMenu( const QPoint& pos );
|
||||
|
||||
private:
|
||||
VisualPropertiesPtr getVisualProperty( const BranchType& theBranchType );
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Common interface for working with shape dimension and annotation properties
|
||||
* of object in a unified way irrespectively of the implementation.
|
||||
*/
|
||||
class VisualProperty
|
||||
{
|
||||
public:
|
||||
virtual int GetNumber() = 0;
|
||||
virtual QString GetName( const int theIndex ) = 0;
|
||||
virtual bool GetIsVisible( const int theIndex ) = 0;
|
||||
virtual void SetIsVisible( const int theIndex, const bool theIsVisible ) = 0;
|
||||
virtual void Save() = 0;
|
||||
};
|
||||
|
||||
private:
|
||||
bool setShapeItemVisibility( QSharedPointer<VisualProperty>& theProps,
|
||||
QTreeWidgetItem* theWidgetItem,
|
||||
const bool theVisibility );
|
||||
QSharedPointer<VisualProperty> getVisualProperty( const BranchType& theBranchType,
|
||||
SalomeApp_Study* theStudy,
|
||||
const std::string& theEntry );
|
||||
void fillBranch( const BranchType& theBranchType,
|
||||
const QString& theEntry );
|
||||
void updateVisibilityColumn( const BranchType& theBranchType,
|
||||
@ -93,18 +113,17 @@ private:
|
||||
BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
|
||||
|
||||
private:
|
||||
int myWindowID;
|
||||
|
||||
int myWindowID;
|
||||
QIcon myVisibleIcon;
|
||||
QIcon myInvisibleIcon;
|
||||
QHash<QString, QTreeWidgetItem*> myObjects;
|
||||
QHash<QString, QTreeWidgetItem*> myDimensionObjects;
|
||||
QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
|
||||
SalomeApp_Study* myStudy;
|
||||
QTreeWidgetItem* myDimensionsItem;
|
||||
QTreeWidgetItem* myAnnotationsItem;
|
||||
GEOM_Displayer myDisplayer;
|
||||
|
||||
QMap<int, QAction*> myActions; //!< menu actions list
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,122 +0,0 @@
|
||||
// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
||||
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
// File : GEOMGUI_VisualProperties.h
|
||||
// Author : Anton POLETAEV, Open CASCADE S.A.S.
|
||||
//
|
||||
|
||||
#ifndef GEOMGUI_VisualProperties_H
|
||||
#define GEOMGUI_VisualProperties_H
|
||||
|
||||
// OCCT includes
|
||||
#include <Standard_Macro.hxx>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class GEOMGUI_VisualProperties;
|
||||
typedef QSharedPointer<GEOMGUI_VisualProperties> VisualPropertiesPtr;
|
||||
|
||||
class SalomeApp_Study;
|
||||
|
||||
/*!
|
||||
* \brief Utility class to presentations as object property of study.
|
||||
*
|
||||
* This is an abstract class with interface to manipulate with a property object
|
||||
* Methods should be implemented in inherited classes.
|
||||
*/
|
||||
class Standard_EXPORT GEOMGUI_VisualProperties
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Constructor. Inits empty property.
|
||||
*/
|
||||
GEOMGUI_VisualProperties() {}
|
||||
|
||||
/*!
|
||||
* \brief Destructor.
|
||||
*/
|
||||
~GEOMGUI_VisualProperties() {}
|
||||
|
||||
/*!
|
||||
* \brief Returns number of dimension records.
|
||||
*/
|
||||
virtual int GetNumber() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Removes record by its index.
|
||||
* \param theIndex [in] the index of dimension record.
|
||||
*/
|
||||
//virtual void RemoveRecord( const int theIndex ) = 0;
|
||||
/*!
|
||||
* \brief Clears property data.
|
||||
*/
|
||||
//virtual void Clear() = 0;
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Returns visibility state of dimension record by its index.
|
||||
*
|
||||
* \param theIndex [in] the index of the dimension record.
|
||||
*/
|
||||
virtual bool IsVisible( const int theIndex ) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Changes visibility state of the dimension record.
|
||||
*
|
||||
* \param theIndex [in] the index of the dimension record.
|
||||
* \param theIsVisible [in] the new visibility state.
|
||||
*/
|
||||
virtual void SetVisible( const int theIndex, const bool theIsVisible ) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Returns name of dimension record by its index.
|
||||
*
|
||||
* \param theIndex [in] the index of the dimension record.
|
||||
*/
|
||||
virtual QString GetName( const int theIndex ) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief Changes name of dimension record.
|
||||
*
|
||||
* \param theIndex [in] the index of the dimension record.
|
||||
* \param theName [in] the new name.
|
||||
*/
|
||||
virtual void SetName( const int theIndex, const QString& theName ) = 0;
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief Loads properties data from attribute "AttributeTableOfReal".
|
||||
* \param theStudy [in] the study.
|
||||
* \param theEntry [in] the entry of GEOM object to operate with.
|
||||
*/
|
||||
virtual void LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry ) = 0;
|
||||
|
||||
/*!
|
||||
* \brief Saves properties data to attribute "AttributeTableOfReal".
|
||||
* \param theStudy [in] the study.
|
||||
* \param theEntry [in] the entry of GEOM object to operate with.
|
||||
*/
|
||||
virtual void SaveToAttribute( SalomeApp_Study* theStudy, const std::string& theEntry ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
@ -1420,7 +1420,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje
|
||||
gp_Trsf aToLCS;
|
||||
aToLCS.SetTransformation( theShapeLCS, gp_Ax3() );
|
||||
|
||||
for ( int anI = 0; anI < aShapeAnnotations->GetCount(); ++anI )
|
||||
for ( int anI = 0; anI < aShapeAnnotations->GetNbAnnotation(); ++anI )
|
||||
{
|
||||
if ( !aShapeAnnotations->GetIsVisible( anI ) )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user