mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-15 10:50:35 +05:00
Annotation's visualization in tree
This commit is contained in:
parent
d95aebd2b3
commit
f88158f329
@ -75,6 +75,7 @@ SET(GEOMGUI_HEADERS
|
|||||||
GEOM_GEOMGUI.hxx
|
GEOM_GEOMGUI.hxx
|
||||||
GEOMGUI_CreationInfoWdg.h
|
GEOMGUI_CreationInfoWdg.h
|
||||||
GEOMGUI_TextTreeWdg.h
|
GEOMGUI_TextTreeWdg.h
|
||||||
|
GEOMGUI_VisualProperties.h
|
||||||
GEOMGUI_DimensionProperty.h
|
GEOMGUI_DimensionProperty.h
|
||||||
GEOMGUI_ShapeAnnotations.h
|
GEOMGUI_ShapeAnnotations.h
|
||||||
)
|
)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#define GEOMGUI_DIMENSIONPROPERTY_H
|
#define GEOMGUI_DIMENSIONPROPERTY_H
|
||||||
|
|
||||||
// OCCT includes
|
// OCCT includes
|
||||||
|
#include <GEOMGUI_VisualProperties.h>
|
||||||
|
|
||||||
#include <AIS_DiameterDimension.hxx>
|
#include <AIS_DiameterDimension.hxx>
|
||||||
#include <AIS_LengthDimension.hxx>
|
#include <AIS_LengthDimension.hxx>
|
||||||
#include <AIS_AngleDimension.hxx>
|
#include <AIS_AngleDimension.hxx>
|
||||||
@ -42,6 +44,9 @@
|
|||||||
|
|
||||||
class SalomeApp_Study;
|
class SalomeApp_Study;
|
||||||
|
|
||||||
|
class GEOMGUI_DimensionProperty;
|
||||||
|
typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Utility class to unpack/pack dimension presentations as object property of study.
|
* \brief Utility class to unpack/pack dimension presentations as object property of study.
|
||||||
*
|
*
|
||||||
@ -57,7 +62,7 @@ class SalomeApp_Study;
|
|||||||
* Diam: (plane)[0-3] (flyout)[4] (text flags)[5-6] (arrow flag)[7] (circle loc, xdir, ydir, rad)[8-17]
|
* 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]
|
* Angle: (flyout)[0] (text flags)[1-2] (arrow flag)[3] (p1)[4-6] (p2)[7-9] (center)[10-12]
|
||||||
*/
|
*/
|
||||||
class Standard_EXPORT GEOMGUI_DimensionProperty
|
class Standard_EXPORT GEOMGUI_DimensionProperty : public GEOMGUI_VisualProperties
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -232,17 +232,6 @@ bool GEOMGUI_ShapeAnnotations::operator == (const GEOMGUI_ShapeAnnotations& theO
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
|
||||||
// function : Add
|
|
||||||
// purpose :
|
|
||||||
//=================================================================================
|
|
||||||
void GEOMGUI_ShapeAnnotations::Add( const Handle(GEOM_Annotation)& theShapeAnnotation, const gp_Ax3& theLCS )
|
|
||||||
{
|
|
||||||
Add( ShapeAnnotation() );
|
|
||||||
//
|
|
||||||
FromPresentation( Count() - 1, theShapeAnnotation, theLCS );
|
|
||||||
}
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : FromPresentation
|
// function : FromPresentation
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -285,6 +274,26 @@ void GEOMGUI_ShapeAnnotations::ToPresentation( const int theIndex,
|
|||||||
//theShapeAnnotation->SetAttachPoint( aEntry.Attach.Transformed( aToLCS ) );
|
//theShapeAnnotation->SetAttachPoint( aEntry.Attach.Transformed( aToLCS ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GEOMGUI_ShapeAnnotations::IsVisible( const int theIndex ) const
|
||||||
|
{
|
||||||
|
return myAnnotations[theIndex].IsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMGUI_ShapeAnnotations::SetVisible( const int theIndex, const bool theIsVisible )
|
||||||
|
{
|
||||||
|
ShapeAnnotation& aChangeEntry = myAnnotations[theIndex];
|
||||||
|
aChangeEntry.IsVisible = theIsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GEOMGUI_ShapeAnnotations::GetName( const int theIndex ) const
|
||||||
|
{
|
||||||
|
return "Name";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMGUI_ShapeAnnotations::SetName( const int theIndex, const QString& theName )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : LoadFromAttribute
|
// function : LoadFromAttribute
|
||||||
// purpose :
|
// purpose :
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#ifndef GEOMGUI_SHAPEANNOTATIONS_H
|
#ifndef GEOMGUI_SHAPEANNOTATIONS_H
|
||||||
#define GEOMGUI_SHAPEANNOTATIONS_H
|
#define GEOMGUI_SHAPEANNOTATIONS_H
|
||||||
|
|
||||||
|
#include <GEOMGUI_VisualProperties.h>
|
||||||
|
|
||||||
// OCCT includes
|
// OCCT includes
|
||||||
#include <gp_Ax3.hxx>
|
#include <gp_Ax3.hxx>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -40,6 +42,9 @@
|
|||||||
class SalomeApp_Study;
|
class SalomeApp_Study;
|
||||||
class GEOM_Annotation;
|
class GEOM_Annotation;
|
||||||
|
|
||||||
|
class GEOMGUI_ShapeAnnotations;
|
||||||
|
typedef QSharedPointer<GEOMGUI_ShapeAnnotations> ShapeAnnotationsPtr;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Algorithms to translate and manitain list of shape annotation properties.
|
* \brief Algorithms to translate and manitain list of shape annotation properties.
|
||||||
*
|
*
|
||||||
@ -47,7 +52,7 @@ class GEOM_Annotation;
|
|||||||
* To ensure that dimension is bound to the equal shape irrespectively of its location
|
* To ensure that dimension is bound to the equal shape irrespectively of its location
|
||||||
* transformation.
|
* transformation.
|
||||||
*/
|
*/
|
||||||
class Standard_EXPORT GEOMGUI_ShapeAnnotations
|
class Standard_EXPORT GEOMGUI_ShapeAnnotations : public GEOMGUI_VisualProperties
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -143,19 +148,13 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Adds new shape annotation entry using explicit definition.
|
* \brief Adds new shape annotation entry using explicit definition.
|
||||||
* \param theShapeAnnotation [in] the explicit definition of the annotation.
|
* \param theShapeAnnotation [in] the explicit definition of the annotation.
|
||||||
|
* \param theLCS [in] the local coordinate system of parent object.
|
||||||
*/
|
*/
|
||||||
void Add( const ShapeAnnotation& theShapeAnnotation )
|
void Add( const ShapeAnnotation& theShapeAnnotation )
|
||||||
{
|
{
|
||||||
myAnnotations.append( theShapeAnnotation );
|
myAnnotations.append( theShapeAnnotation );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Adds new entry using data of the interactive presentation given.
|
|
||||||
* \param theShapeAnnotation [in] the interactive shape annotation holding properties.
|
|
||||||
* \param theLCS [in] the local coordinate system of parent object.
|
|
||||||
*/
|
|
||||||
void Add( const Handle(GEOM_Annotation)& theShapeAnnotation, const gp_Ax3& theLCS );
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Update entry data using the explicit definition.
|
* \brief Update entry data using the explicit definition.
|
||||||
* \param theIndex [in] the index of the dimension record.
|
* \param theIndex [in] the index of the dimension record.
|
||||||
@ -211,7 +210,37 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Returns number of shape annotation records.
|
* \brief Returns number of shape annotation records.
|
||||||
*/
|
*/
|
||||||
int Count() const { return myAnnotations.size(); }
|
virtual int GetNumber() const { return myAnnotations.size(); };
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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 );
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \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 );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -220,14 +249,14 @@ public:
|
|||||||
* \param theStudy [in] the study.
|
* \param theStudy [in] the study.
|
||||||
* \param theEntry [in] the entry of GEOM object to operate with.
|
* \param theEntry [in] the entry of GEOM object to operate with.
|
||||||
*/
|
*/
|
||||||
void LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
|
virtual void LoadFromAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Saves properties data to attribute.
|
* \brief Saves properties data to attribute.
|
||||||
* \param theStudy [in] the study.
|
* \param theStudy [in] the study.
|
||||||
* \param theEntry [in] the entry of GEOM object to operate with.
|
* \param theEntry [in] the entry of GEOM object to operate with.
|
||||||
*/
|
*/
|
||||||
void SaveToAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
|
virtual void SaveToAttribute( SalomeApp_Study* theStudy, const std::string& theEntry );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "GEOMGUI_TextTreeWdg.h"
|
#include "GEOMGUI_TextTreeWdg.h"
|
||||||
|
|
||||||
#include "GEOMGUI_DimensionProperty.h"
|
#include "GEOMGUI_DimensionProperty.h"
|
||||||
|
#include "GEOMGUI_ShapeAnnotations.h"
|
||||||
#include "GeometryGUI.h"
|
#include "GeometryGUI.h"
|
||||||
#include "GeometryGUI_Operations.h"
|
#include "GeometryGUI_Operations.h"
|
||||||
#include <GEOM_Constants.h>
|
#include <GEOM_Constants.h>
|
||||||
@ -99,15 +100,15 @@ GEOMGUI_TextTreeWdg::GEOMGUI_TextTreeWdg( SalomeApp_Application* app )
|
|||||||
createActions();
|
createActions();
|
||||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||||
connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
|
connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
|
||||||
this, SLOT( showContextMenu(const QPoint&) ) );
|
this, SLOT( showContextMenu(const QPoint&) ) );
|
||||||
|
|
||||||
connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
|
connect( myStudy, SIGNAL( objVisibilityChanged( QString, Qtx::VisibilityState ) ),
|
||||||
this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
|
this, SLOT( updateVisibilityColumn( QString, Qtx::VisibilityState ) ) );
|
||||||
connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
|
connect( app->objectBrowser(), SIGNAL( updated() ), this, SLOT( updateTree() ) );
|
||||||
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
|
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
|
||||||
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
|
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
|
||||||
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
|
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
|
||||||
this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
|
this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,20 +145,25 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
|||||||
if ( SC ) {
|
if ( SC ) {
|
||||||
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
|
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
|
||||||
anIter->InitEx( true );
|
anIter->InitEx( true );
|
||||||
QList<QString> objEntries = myObjects.keys();
|
QList<QString> aGeomObjEntries = getObjects( Geometry ).keys();
|
||||||
|
QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
|
||||||
while( anIter->More() ) {
|
while( anIter->More() ) {
|
||||||
_PTR(SObject) valSO ( anIter->Value() );
|
_PTR(SObject) valSO ( anIter->Value() );
|
||||||
_PTR(SObject) refSO;
|
_PTR(SObject) refSO;
|
||||||
if ( !valSO->ReferencedObject( refSO ) ) {
|
if ( !valSO->ReferencedObject( refSO ) ) {
|
||||||
// update tree of object's dimensions
|
// update tree of object's dimensions
|
||||||
QString anEntry = valSO->GetID().c_str();
|
QString anEntry = valSO->GetID().c_str();
|
||||||
updateBranch( anEntry );
|
updateBranch( anEntry );
|
||||||
objEntries.removeAll( anEntry );
|
aGeomObjEntries.removeAll( anEntry );
|
||||||
}
|
anAnnotationObjEntries.removeAll( anEntry );
|
||||||
anIter->Next();
|
}
|
||||||
|
anIter->Next();
|
||||||
}
|
}
|
||||||
foreach (QString entry, objEntries) {
|
foreach (QString entry, aGeomObjEntries) {
|
||||||
removeBranch( entry, true );
|
removeBranch( Geometry, entry, true );
|
||||||
|
}
|
||||||
|
foreach (QString entry, anAnnotationObjEntries) {
|
||||||
|
removeBranch( AnnotationShape, entry, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,67 +174,105 @@ void GEOMGUI_TextTreeWdg::updateTree()
|
|||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
|
void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
|
||||||
|
{
|
||||||
|
/// dimension property branch
|
||||||
|
fillBranch( Geometry, theEntry );
|
||||||
|
|
||||||
|
// annotation property branch
|
||||||
|
fillBranch(AnnotationShape, theEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GEOMGUI_TextTreeWdg::fillBranch( const BranchType& theBranchType, const QString& theEntry )
|
||||||
{
|
{
|
||||||
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
myStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
||||||
if ( myStudy ) {
|
|
||||||
|
if ( myStudy && !theEntry.isEmpty() ) {
|
||||||
|
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
|
||||||
|
int aNumber = aProp->GetNumber();
|
||||||
|
const std::string anEntry = theEntry.toStdString();
|
||||||
|
|
||||||
|
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||||
|
|
||||||
|
if (!aProp)
|
||||||
|
return;
|
||||||
|
|
||||||
_PTR(Study) aStudyDS = myStudy->studyDS();
|
_PTR(Study) aStudyDS = myStudy->studyDS();
|
||||||
if ( aStudyDS ) {
|
if ( aStudyDS ) {
|
||||||
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
|
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
|
||||||
QString aName = obj->GetName().c_str();
|
QString aName = obj->GetName().c_str();
|
||||||
|
|
||||||
GEOMGUI_DimensionProperty aProp;
|
int nbProps = aProp->GetNumber();
|
||||||
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
|
|
||||||
int nbProps = aProp.GetNumber();
|
|
||||||
|
|
||||||
QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
|
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
|
||||||
if ( objectItem ) {
|
if ( objectItem ) {
|
||||||
removeBranch( theEntry, nbProps > 0 ? false : true );
|
removeBranch( theBranchType, theEntry, nbProps > 0 ? false : true );
|
||||||
}
|
}
|
||||||
QStringList itemName;
|
QStringList itemName;
|
||||||
if ( nbProps > 0 ) {
|
if ( nbProps > 0 ) {
|
||||||
itemName << aName << "";
|
itemName << aName << "";
|
||||||
if ( !objectItem ) {
|
if ( !objectItem ) {
|
||||||
objectItem = new QTreeWidgetItem( myDimensionsItem, itemName );
|
QTreeWidgetItem* aPropRootItem = getPropertyRootItem(theBranchType);
|
||||||
objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
|
||||||
objectItem->setData( 1, Qt::UserRole, theEntry );
|
|
||||||
myDimensionsItem->addChild( objectItem );
|
|
||||||
myObjects.insert( theEntry, objectItem );
|
|
||||||
if ( myDimensionsItem->childCount() == 1 )
|
|
||||||
myDimensionsItem->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 );
|
|
||||||
|
|
||||||
QTreeWidgetItem* anItem = new QTreeWidgetItem;
|
objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
|
||||||
anItem->setText( 0, aName );
|
objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||||
// if ( isDisplayed )
|
objectItem->setData( 1, Qt::UserRole, theEntry );
|
||||||
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
|
aPropRootItem->addChild( objectItem );
|
||||||
anItem->setData( 0, Qt::UserRole, anIt );
|
getObjects( theBranchType ).insert( theEntry, objectItem );
|
||||||
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
if ( aPropRootItem->childCount() == 1 )
|
||||||
objectItem->addChild( anItem );
|
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 );
|
||||||
|
|
||||||
|
QTreeWidgetItem* anItem = new QTreeWidgetItem;
|
||||||
|
anItem->setText( 0, aName );
|
||||||
|
// if ( isDisplayed )
|
||||||
|
anItem->setIcon( 1, isVisible ? myVisibleIcon : myInvisibleIcon );
|
||||||
|
anItem->setData( 0, Qt::UserRole, anIt );
|
||||||
|
anItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
||||||
|
objectItem->addChild( anItem );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getVisualProperty
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
VisualPropertiesPtr GEOMGUI_TextTreeWdg::getVisualProperty( const BranchType& theBranchType )
|
||||||
|
{
|
||||||
|
VisualPropertiesPtr aProp;
|
||||||
|
|
||||||
|
if ( theBranchType == Geometry ) {
|
||||||
|
aProp = QSharedPointer<GEOMGUI_DimensionProperty>( new GEOMGUI_DimensionProperty() );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aProp = QSharedPointer<GEOMGUI_ShapeAnnotations>( new GEOMGUI_ShapeAnnotations() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return aProp;
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : removeBranch
|
// function : removeBranch
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void GEOMGUI_TextTreeWdg::removeBranch( const QString& theEntry, bool force )
|
void GEOMGUI_TextTreeWdg::removeBranch( const BranchType& theBranchType, const QString& theEntry,
|
||||||
|
bool force )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
|
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
|
||||||
if ( !objectItem )
|
if ( !objectItem )
|
||||||
return;
|
return;
|
||||||
qDeleteAll( objectItem->takeChildren() );
|
qDeleteAll( objectItem->takeChildren() );
|
||||||
if ( force ) {
|
if ( force ) {
|
||||||
myDimensionsItem->removeChild( objectItem );
|
QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
|
||||||
myObjects.remove( theEntry );
|
aPropRootItem->removeChild( objectItem );
|
||||||
|
getObjects( theBranchType ).remove( theEntry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,17 +286,21 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
std::string anEntry = entryFromItem( theItem->parent() ).toStdString();
|
std::string anEntry = entryFromItem( theItem->parent() ).toStdString();
|
||||||
|
BranchType aBranchType = branchTypeFromItem( theItem );
|
||||||
|
|
||||||
int aDimIndex = idFromItem( theItem );
|
int aDimIndex = idFromItem( theItem );
|
||||||
GEOMGUI_DimensionProperty aProp;
|
|
||||||
aProp.LoadFromAttribute( myStudy, anEntry );
|
VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
|
||||||
if ( aProp.IsVisible( aDimIndex ) ) {
|
aProp->LoadFromAttribute( myStudy, anEntry );
|
||||||
aProp.SetVisible( aDimIndex, false );
|
if ( aProp->IsVisible( aDimIndex ) ) {
|
||||||
|
aProp->SetVisible( aDimIndex, false );
|
||||||
theItem->setIcon( 1, myInvisibleIcon );
|
theItem->setIcon( 1, myInvisibleIcon );
|
||||||
} else {
|
} else {
|
||||||
aProp.SetVisible( aDimIndex, true );
|
aProp->SetVisible( aDimIndex, true );
|
||||||
theItem->setIcon( 1, myVisibleIcon );
|
theItem->setIcon( 1, myVisibleIcon );
|
||||||
}
|
}
|
||||||
aProp.SaveToAttribute( myStudy, anEntry );
|
aProp->SaveToAttribute( myStudy, anEntry );
|
||||||
|
|
||||||
redisplay( anEntry.c_str() );
|
redisplay( anEntry.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,33 +335,48 @@ QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
|
|||||||
// function : itemFromEntry
|
// function : itemFromEntry
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( QString theEntry )
|
QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranchType, QString theEntry )
|
||||||
{
|
{
|
||||||
if ( theEntry.isEmpty() )
|
if ( theEntry.isEmpty() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return myObjects.value( theEntry, 0 );
|
return getObjects(theBranchType).value( theEntry, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : updateVisibilityColumn
|
||||||
|
// purpose : Update visible state of icons of entry items.
|
||||||
|
//=================================================================================
|
||||||
|
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
|
||||||
|
{
|
||||||
|
//BranchType theBranchType,
|
||||||
|
updateVisibilityColumn( Geometry, theEntry, theState );
|
||||||
|
updateVisibilityColumn( AnnotationShape, theEntry, theState );
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : updateVisibilityColumn
|
// function : updateVisibilityColumn
|
||||||
// purpose : Update icons of dimension items.
|
// purpose : Update icons of dimension items.
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
|
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchType, QString theEntry,
|
||||||
|
Qtx::VisibilityState theState )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* anItem = itemFromEntry( theEntry );
|
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
|
||||||
if ( !anItem )
|
if ( !anItem )
|
||||||
return;
|
return;
|
||||||
anItem->setDisabled( theState != Qtx::ShownState );
|
anItem->setDisabled( theState != Qtx::ShownState );
|
||||||
QTreeWidgetItem* aChildItem;
|
QTreeWidgetItem* aChildItem;
|
||||||
GEOMGUI_DimensionProperty aProp;
|
|
||||||
|
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
|
||||||
|
|
||||||
for ( int i=0; i < anItem->childCount(); i++ ) {
|
for ( int i=0; i < anItem->childCount(); i++ ) {
|
||||||
aChildItem = anItem->child( i );
|
aChildItem = anItem->child( i );
|
||||||
if ( theState == Qtx::ShownState ) {
|
if ( theState == Qtx::ShownState ) {
|
||||||
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
|
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||||
if ( aProp.GetNumber() == 0 )
|
if ( aProp->GetNumber() == 0 )
|
||||||
continue;
|
continue;
|
||||||
aChildItem->setIcon( 1, aProp.IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon : myInvisibleIcon );
|
aChildItem->setIcon( 1, aProp->IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
|
||||||
|
: myInvisibleIcon );
|
||||||
aChildItem->setDisabled( false );
|
aChildItem->setDisabled( false );
|
||||||
} else {
|
} else {
|
||||||
aChildItem->setIcon( 1, QIcon() );
|
aChildItem->setIcon( 1, QIcon() );
|
||||||
@ -333,56 +396,65 @@ void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
|
|||||||
QMenu aMenu;
|
QMenu aMenu;
|
||||||
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
||||||
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
||||||
|
|
||||||
if ( selectedItems().count() == 1 ) {
|
if ( selectedItems().count() == 1 ) {
|
||||||
QTreeWidgetItem* anItem = selectedItems().first();
|
QTreeWidgetItem* anItem = selectedItems().first();
|
||||||
QString anEntry = entryFromItem( anItem->parent() );
|
QString anEntry = entryFromItem( anItem->parent() );
|
||||||
if ( !anEntry.isEmpty() ) {
|
if ( !anEntry.isEmpty() ) {
|
||||||
GEOMGUI_DimensionProperty aProp;
|
BranchType aBranchType = branchTypeFromItem( anItem );
|
||||||
aProp.LoadFromAttribute( myStudy, anEntry.toStdString() );
|
VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
|
||||||
if ( aProp.GetNumber() == 0 )
|
|
||||||
return;
|
aProp->LoadFromAttribute( myStudy, anEntry.toStdString() );
|
||||||
|
if ( aProp->GetNumber() == 0 )
|
||||||
|
return;
|
||||||
aMenu.clear();
|
aMenu.clear();
|
||||||
if ( aProp.IsVisible( idFromItem( anItem ) ) )
|
if ( aProp->IsVisible( idFromItem( anItem ) ) )
|
||||||
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
aMenu.addAction( myActions[GEOMOp::OpHide] );
|
||||||
else
|
else
|
||||||
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
aMenu.addAction( myActions[GEOMOp::OpShow] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
|
QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
|
||||||
if ( selPopupItem == myActions[GEOMOp::OpShow] )
|
|
||||||
setVisibility( true );
|
if ( selPopupItem == myActions[GEOMOp::OpShow] ||
|
||||||
else if ( selPopupItem == myActions[GEOMOp::OpHide] )
|
selPopupItem == myActions[GEOMOp::OpHide] ) {
|
||||||
setVisibility( false );
|
bool isVisible = selPopupItem == myActions[GEOMOp::OpShow];
|
||||||
|
foreach ( QTreeWidgetItem* anItem, selectedItems() ) {
|
||||||
|
setVisibility( anItem, isVisible );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : setVisibility
|
// function : setVisibility
|
||||||
// purpose :
|
// purpose : set item visible
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void GEOMGUI_TextTreeWdg::setVisibility( bool theVisibility )
|
void GEOMGUI_TextTreeWdg::setVisibility( QTreeWidgetItem* theItem, bool theVisibility )
|
||||||
{
|
{
|
||||||
if ( myDimensionsItem->isSelected() ) {
|
BranchType aBranchType = branchTypeFromItem( theItem );
|
||||||
|
if ( theItem == myDimensionsItem ||
|
||||||
|
theItem == myAnnotationsItem ) {
|
||||||
// set visibility for all dimensions
|
// set visibility for all dimensions
|
||||||
QTreeWidgetItem* anItem;
|
QTreeWidgetItem* anItem;
|
||||||
foreach ( QString entry, myObjects.keys() ) {
|
foreach ( QString entry, getObjects( aBranchType ).keys() ) {
|
||||||
anItem = itemFromEntry( entry );
|
anItem = itemFromEntry( aBranchType, entry );
|
||||||
if ( !anItem->isDisabled() )
|
if ( !anItem->isDisabled() )
|
||||||
setShapeDimensionsVisibility( entry, theVisibility );
|
setShapeDimensionsVisibility( aBranchType, entry, theVisibility );
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach ( QTreeWidgetItem* item, selectedItems() ) {
|
else {
|
||||||
if ( item->isDisabled() || item->parent()->isSelected() )
|
if ( !theItem->isDisabled() && !theItem->parent()->isSelected() ) {
|
||||||
continue;
|
QString anEntry = entryFromItem( theItem );
|
||||||
QString anEntry = entryFromItem( item );
|
if ( !anEntry.isEmpty() ) {
|
||||||
if ( !anEntry.isEmpty() ) {
|
// it is a shape item
|
||||||
// it is a shape item
|
setShapeDimensionsVisibility( aBranchType, anEntry, theVisibility );
|
||||||
setShapeDimensionsVisibility( anEntry, theVisibility );
|
} else {
|
||||||
} else {
|
// it is a dimension item
|
||||||
// it is a dimension item
|
anEntry = entryFromItem( theItem->parent() );
|
||||||
anEntry = entryFromItem( item->parent() );
|
setDimensionVisibility( aBranchType, anEntry, theItem, theVisibility );
|
||||||
setDimensionVisibility( anEntry, item, theVisibility );
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,13 +462,14 @@ void GEOMGUI_TextTreeWdg::setVisibility( bool theVisibility )
|
|||||||
// function : setShapeDimensionsVisibility
|
// function : setShapeDimensionsVisibility
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( QString theEntry, bool theVisibility )
|
void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( const BranchType& theBranchType,
|
||||||
|
QString theEntry, bool theVisibility )
|
||||||
{
|
{
|
||||||
QTreeWidgetItem* anItem = itemFromEntry( theEntry );
|
QTreeWidgetItem* anItem = itemFromEntry( theBranchType, theEntry );
|
||||||
QTreeWidgetItem* aChildItem;
|
QTreeWidgetItem* aChildItem;
|
||||||
for ( int i=0; i < anItem->childCount(); i++ ) {
|
for ( int i=0; i < anItem->childCount(); i++ ) {
|
||||||
aChildItem = anItem->child( i );
|
aChildItem = anItem->child( i );
|
||||||
setDimensionVisibility( theEntry, aChildItem, theVisibility );
|
setDimensionVisibility( theBranchType, theEntry, aChildItem, theVisibility );
|
||||||
}
|
}
|
||||||
redisplay( theEntry );
|
redisplay( theEntry );
|
||||||
}
|
}
|
||||||
@ -405,15 +478,17 @@ void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( QString theEntry, bool t
|
|||||||
// function : setDimensionVisibility
|
// function : setDimensionVisibility
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void GEOMGUI_TextTreeWdg::setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility )
|
void GEOMGUI_TextTreeWdg::setDimensionVisibility( const BranchType& theBranchType, QString theEntry,
|
||||||
|
QTreeWidgetItem* theDimItem, bool theVisibility )
|
||||||
{
|
{
|
||||||
GEOMGUI_DimensionProperty aProp;
|
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
|
||||||
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
|
|
||||||
|
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
|
||||||
int aDimIndex = idFromItem( theDimItem );
|
int aDimIndex = idFromItem( theDimItem );
|
||||||
if ( aProp.GetNumber() == 0 || aProp.IsVisible( aDimIndex ) == theVisibility )
|
if ( aProp->GetNumber() == 0 || aProp->IsVisible( aDimIndex ) == theVisibility )
|
||||||
return;;
|
return;;
|
||||||
aProp.SetVisible( aDimIndex, theVisibility );
|
aProp->SetVisible( aDimIndex, theVisibility );
|
||||||
aProp.SaveToAttribute( myStudy, theEntry.toStdString() );
|
aProp->SaveToAttribute( myStudy, theEntry.toStdString() );
|
||||||
|
|
||||||
theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
|
theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
|
||||||
redisplay( theEntry );
|
redisplay( theEntry );
|
||||||
@ -428,3 +503,46 @@ void GEOMGUI_TextTreeWdg::redisplay( QString theEntry )
|
|||||||
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toLatin1().constData(), "GEOM", "TEMP_IO" );
|
Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject( theEntry.toLatin1().constData(), "GEOM", "TEMP_IO" );
|
||||||
myDisplayer.Redisplay( io );
|
myDisplayer.Redisplay( io );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getPropertyRootItem
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
QTreeWidgetItem* GEOMGUI_TextTreeWdg::getPropertyRootItem( const BranchType& theBranchType )
|
||||||
|
{
|
||||||
|
return theBranchType == Geometry ? myDimensionsItem : myAnnotationsItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getObjects
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
QHash<QString, QTreeWidgetItem*>& GEOMGUI_TextTreeWdg::getObjects( const BranchType& theBranchType )
|
||||||
|
{
|
||||||
|
return theBranchType == Geometry ? myObjects : myAnnotationObjects;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : branchTypeFromItem
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
GEOMGUI_TextTreeWdg::BranchType GEOMGUI_TextTreeWdg::branchTypeFromItem( QTreeWidgetItem* theItem )
|
||||||
|
{
|
||||||
|
BranchType aBranchType = Geometry;
|
||||||
|
|
||||||
|
bool aBranchTypeFound = false;
|
||||||
|
QTreeWidgetItem* anItem = theItem;
|
||||||
|
while( !aBranchTypeFound && anItem ) {
|
||||||
|
if ( anItem == myDimensionsItem ||
|
||||||
|
anItem == myAnnotationsItem) {
|
||||||
|
aBranchTypeFound = true;
|
||||||
|
aBranchType = anItem == myDimensionsItem ? Geometry : AnnotationShape;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
anItem = anItem->parent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aBranchType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "GEOM_GEOMGUI.hxx"
|
#include "GEOM_GEOMGUI.hxx"
|
||||||
#include "GEOM_Displayer.h"
|
#include "GEOM_Displayer.h"
|
||||||
|
#include "GEOMGUI_VisualProperties.h"
|
||||||
|
|
||||||
#include <QTreeWidget>
|
#include <QTreeWidget>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
@ -35,6 +36,7 @@ class QTreeWidgetItem;
|
|||||||
class SalomeApp_Application;
|
class SalomeApp_Application;
|
||||||
class SalomeApp_Study;
|
class SalomeApp_Study;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Tree view contains Dimension and Annotation text items:
|
* \brief Tree view contains Dimension and Annotation text items:
|
||||||
* - text visibility in OCC viewer
|
* - text visibility in OCC viewer
|
||||||
@ -44,41 +46,59 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum BranchType { Geometry, AnnotationShape };
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
|
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
|
||||||
~GEOMGUI_TextTreeWdg();
|
~GEOMGUI_TextTreeWdg();
|
||||||
|
|
||||||
int getWinID() { return myWindowID; }
|
int getWinID() { return myWindowID; }
|
||||||
|
|
||||||
void removeBranch( const QString& theEntry,
|
void removeBranch( const BranchType& theBranchType, const QString& theEntry,
|
||||||
bool force = true );
|
bool force = true );
|
||||||
int idFromItem( QTreeWidgetItem* theItem );
|
int idFromItem( QTreeWidgetItem* theItem );
|
||||||
QString entryFromItem( QTreeWidgetItem* theShapeItem );
|
QString entryFromItem( QTreeWidgetItem* theShapeItem );
|
||||||
QTreeWidgetItem* itemFromEntry( QString theEntry );
|
QTreeWidgetItem* itemFromEntry( const BranchType& theBranchType, QString theEntry );
|
||||||
void setShapeDimensionsVisibility( QString theEntry, bool theVisibility );
|
void setShapeDimensionsVisibility( const BranchType& theBranchType,
|
||||||
void setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility );
|
QString theEntry, bool theVisibility );
|
||||||
|
void setDimensionVisibility( const BranchType& theBranchType,
|
||||||
|
QString theEntry, QTreeWidgetItem* theDimItem,
|
||||||
|
bool theVisibility );
|
||||||
protected:
|
protected:
|
||||||
void createActions();
|
void createActions();
|
||||||
void redisplay( QString theEntry );
|
void redisplay( QString theEntry );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateTree();
|
void updateTree();
|
||||||
void updateBranch( const QString& theEntry );
|
void updateBranch( const QString& theEntry );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onItemClicked(QTreeWidgetItem*, int );
|
void onItemClicked(QTreeWidgetItem*, int );
|
||||||
void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
|
void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
|
||||||
void setVisibility( bool visibility );
|
void setVisibility( QTreeWidgetItem* theItem, bool visibility );
|
||||||
void showContextMenu( const QPoint& pos );
|
void showContextMenu( const QPoint& pos );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
VisualPropertiesPtr getVisualProperty( const BranchType& theBranchType );
|
||||||
|
|
||||||
|
void fillBranch( const BranchType& theBranchType,
|
||||||
|
const QString& theEntry );
|
||||||
|
void updateVisibilityColumn( const BranchType& theBranchType,
|
||||||
|
QString theEntry,
|
||||||
|
Qtx::VisibilityState theState );
|
||||||
|
QTreeWidgetItem* getPropertyRootItem( const BranchType& theBranchType );
|
||||||
|
QHash<QString, QTreeWidgetItem*>& getObjects( const BranchType& theBranchType );
|
||||||
|
BranchType branchTypeFromItem( QTreeWidgetItem* theItem );
|
||||||
|
|
||||||
|
private:
|
||||||
int myWindowID;
|
int myWindowID;
|
||||||
|
|
||||||
QIcon myVisibleIcon;
|
QIcon myVisibleIcon;
|
||||||
QIcon myInvisibleIcon;
|
QIcon myInvisibleIcon;
|
||||||
QHash<QString, QTreeWidgetItem*> myObjects;
|
QHash<QString, QTreeWidgetItem*> myObjects;
|
||||||
|
QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
|
||||||
SalomeApp_Study* myStudy;
|
SalomeApp_Study* myStudy;
|
||||||
QTreeWidgetItem* myDimensionsItem;
|
QTreeWidgetItem* myDimensionsItem;
|
||||||
QTreeWidgetItem* myAnnotationsItem;
|
QTreeWidgetItem* myAnnotationsItem;
|
||||||
|
122
src/GEOMGUI/GEOMGUI_VisualProperties.h
Normal file
122
src/GEOMGUI/GEOMGUI_VisualProperties.h
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
// 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
|
@ -1422,7 +1422,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje
|
|||||||
{
|
{
|
||||||
aAnnotationList = aProperty.value<GEOMGUI_ShapeAnnotations>();
|
aAnnotationList = aProperty.value<GEOMGUI_ShapeAnnotations>();
|
||||||
|
|
||||||
for ( int anI = 0; anI < aAnnotationList.Count(); ++anI )
|
for ( int anI = 0; anI < aAnnotationList.GetNumber(); ++anI )
|
||||||
{
|
{
|
||||||
if ( !aAnnotationList.Get( anI ).IsVisible )
|
if ( !aAnnotationList.Get( anI ).IsVisible )
|
||||||
{
|
{
|
||||||
|
343
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
Executable file → Normal file
343
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx
Executable file → Normal file
@ -93,19 +93,17 @@
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI, const bool theIsCreate,
|
||||||
const bool theIsCreate, QWidget* parent, bool modal, Qt::WindowFlags fl)
|
QWidget* parent, bool modal, Qt::WindowFlags fl )
|
||||||
: GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
|
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
|
||||||
myIsCreation(theIsCreate)
|
myIsCreation( theIsCreate )
|
||||||
{
|
{
|
||||||
myEditCurrentArgument = 0;
|
myEditCurrentArgument = 0;
|
||||||
|
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
|
QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
|
||||||
|
|
||||||
setWindowTitle(myIsCreation ?
|
setWindowTitle( myIsCreation ? tr("CREATE_ANNOTATION_TITLE") : tr("EDIT_ANNOTATION_TITLE"));
|
||||||
tr("CREATE_ANNOTATION_TITLE") :
|
|
||||||
tr("EDIT_ANNOTATION_TITLE"));
|
|
||||||
|
|
||||||
// Shape type button group
|
// Shape type button group
|
||||||
mainFrame()->GroupConstructors->hide();
|
mainFrame()->GroupConstructors->hide();
|
||||||
@ -138,13 +136,13 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
|||||||
myTypeCombo = new QComboBox(propGroup);
|
myTypeCombo = new QComboBox(propGroup);
|
||||||
myTypeCombo->insertItem(0, tr("3D"));
|
myTypeCombo->insertItem(0, tr("3D"));
|
||||||
myTypeCombo->insertItem(1, tr("2D"));
|
myTypeCombo->insertItem(1, tr("2D"));
|
||||||
myTypeCombo->setCurrentIndex(0); // double
|
myTypeCombo->setCurrentIndex(0); // 3D, not fixed
|
||||||
|
|
||||||
propLayout->addWidget(shapeLabel, 1, 0);
|
propLayout->addWidget(shapeLabel, 1, 0);
|
||||||
propLayout->addWidget(myShapeSelBtn, 1, 1);
|
propLayout->addWidget(myShapeSelBtn, 1, 1);
|
||||||
propLayout->addWidget(myShapeName, 1, 2);
|
propLayout->addWidget(myShapeName, 1, 2);
|
||||||
propLayout->addWidget(typeLabel, 2, 0, 1, 2);
|
propLayout->addWidget(typeLabel, 2, 0, 1, 2);
|
||||||
propLayout->addWidget(myTypeCombo, 2, 2);
|
propLayout->addWidget(myTypeCombo, 2, 2);
|
||||||
propLayout->setColumnStretch(2, 5);
|
propLayout->setColumnStretch(2, 5);
|
||||||
|
|
||||||
QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
|
QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
|
||||||
@ -154,7 +152,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
|||||||
mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE);
|
mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE);
|
||||||
mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE);
|
mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE);
|
||||||
mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID);
|
mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID);
|
||||||
mySubShapeTypeCombo->setCurrentIndex(0); // VERTEX
|
mySubShapeTypeCombo->setCurrentIndex(0); // SHAPE
|
||||||
|
|
||||||
propLayout->addWidget(shapeTypeLabel, 3, 0);
|
propLayout->addWidget(shapeTypeLabel, 3, 0);
|
||||||
propLayout->addWidget(mySubShapeTypeCombo, 3, 1, 1, 2);
|
propLayout->addWidget(mySubShapeTypeCombo, 3, 1, 1, 2);
|
||||||
@ -171,7 +169,8 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
|||||||
propLayout->addWidget(mySubShapeName, 4, 2);
|
propLayout->addWidget(mySubShapeName, 4, 2);
|
||||||
|
|
||||||
// Field properties
|
// Field properties
|
||||||
QGroupBox* styleGroup = new QGroupBox(tr("ANNOTATION_STYLE"), centralWidget());
|
QGroupBox* styleGroup = new QGroupBox(tr("ANNOTATION_STYLE"),
|
||||||
|
centralWidget());
|
||||||
QGridLayout* styleLayout = new QGridLayout(styleGroup);
|
QGridLayout* styleLayout = new QGridLayout(styleGroup);
|
||||||
styleLayout->setMargin(9);
|
styleLayout->setMargin(9);
|
||||||
styleLayout->setSpacing(6);
|
styleLayout->setSpacing(6);
|
||||||
@ -189,7 +188,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
|||||||
|
|
||||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||||
connect(aSelMgr, SIGNAL(currentSelectionChanged()), this,
|
connect(aSelMgr, SIGNAL(currentSelectionChanged()), this,
|
||||||
SLOT(SelectionIntoArgument()));
|
SLOT(SelectionIntoArgument()));
|
||||||
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
||||||
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
||||||
|
|
||||||
@ -205,8 +204,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg()
|
MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -214,13 +212,10 @@ MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg()
|
|||||||
// purpose : fills annotation properties with default values(in create mode) or
|
// purpose : fills annotation properties with default values(in create mode) or
|
||||||
// the values of modified object
|
// the values of modified object
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::Init()
|
void MeasureGUI_AnnotationDlg::Init() {
|
||||||
{
|
|
||||||
if (myIsCreation) {
|
if (myIsCreation) {
|
||||||
initName(tr("ANNOTATION_PREFIX"));
|
initName(tr("ANNOTATION_PREFIX"));
|
||||||
|
|
||||||
myEditCurrentArgument = myShapeName;
|
|
||||||
|
|
||||||
// default presentation values
|
// default presentation values
|
||||||
myAnnotationProperties.Position = gp_Pnt(250, 250, 250);
|
myAnnotationProperties.Position = gp_Pnt(250, 250, 250);
|
||||||
myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
|
myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
|
||||||
@ -228,23 +223,39 @@ void MeasureGUI_AnnotationDlg::Init()
|
|||||||
myAnnotationProperties.IsScreenFixed = false;
|
myAnnotationProperties.IsScreenFixed = false;
|
||||||
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
|
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
|
||||||
myAnnotationProperties.ShapeIndex = -1;
|
myAnnotationProperties.ShapeIndex = -1;
|
||||||
myAnnotationProperties.ShapeType = (int)TopAbs_SHAPE;
|
myAnnotationProperties.ShapeType = (int) TopAbs_SHAPE;
|
||||||
|
|
||||||
|
// update internal controls and fields following to default values
|
||||||
|
activateSelectionArgument(myShapeSelBtn);
|
||||||
|
myTextEdit->setText(myAnnotationProperties.Text);
|
||||||
|
myTypeCombo->setCurrentIndex(!myAnnotationProperties.IsScreenFixed);
|
||||||
|
|
||||||
|
int aSubShapeTypeIndex = -1;
|
||||||
|
int aTypesCount = aTypesCount = mySubShapeTypeCombo->count();
|
||||||
|
for (int i = 0; i < aTypesCount && aSubShapeTypeIndex < 0; i++) {
|
||||||
|
int aType = mySubShapeTypeCombo->itemData(i).toInt();
|
||||||
|
if (aType == myAnnotationProperties.ShapeType)
|
||||||
|
aSubShapeTypeIndex = i;
|
||||||
|
}
|
||||||
|
mySubShapeTypeCombo->setCurrentIndex(aSubShapeTypeIndex);
|
||||||
|
|
||||||
|
mySelectionMode = (TopAbs_ShapeEnum) myAnnotationProperties.ShapeType;
|
||||||
SelectionIntoArgument();
|
SelectionIntoArgument();
|
||||||
|
updateSubShapeEnableState();
|
||||||
|
|
||||||
mySelectionMode = TopAbs_SHAPE;
|
// connect controls
|
||||||
|
connect(myShapeSelBtn, SIGNAL(clicked()), this,
|
||||||
|
SLOT(SetEditCurrentArgument()));
|
||||||
|
connect(mySubShapeSelBtn, SIGNAL(clicked()), this,
|
||||||
|
SLOT(SetEditCurrentArgument()));
|
||||||
|
|
||||||
connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
connect(myTextEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChange()));
|
||||||
connect(mySubShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange()));
|
||||||
|
connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)),
|
||||||
connect(myTextEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChange()));
|
this, SLOT(onSubShapeTypeChange()));
|
||||||
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange()));
|
|
||||||
connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)),
|
|
||||||
this, SLOT(onSubShapeTypeChange()));
|
|
||||||
|
|
||||||
//SelectionIntoArgument();
|
//SelectionIntoArgument();
|
||||||
}
|
} else { // edition
|
||||||
else { // edition
|
|
||||||
|
|
||||||
}
|
}
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
@ -254,8 +265,7 @@ void MeasureGUI_AnnotationDlg::Init()
|
|||||||
// function : activateSelection
|
// function : activateSelection
|
||||||
// purpose : Activate local selection
|
// purpose : Activate local selection
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::activateSelection()
|
void MeasureGUI_AnnotationDlg::activateSelection() {
|
||||||
{
|
|
||||||
//globalSelection(GEOM_ALLSHAPES);
|
//globalSelection(GEOM_ALLSHAPES);
|
||||||
//if (!myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE) {
|
//if (!myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE) {
|
||||||
// localSelection(myShape.get(), mySelectionMode);
|
// localSelection(myShape.get(), mySelectionMode);
|
||||||
@ -266,103 +276,104 @@ void MeasureGUI_AnnotationDlg::activateSelection()
|
|||||||
// function : getShapeType()
|
// function : getShapeType()
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const
|
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
|
||||||
{
|
return (TopAbs_ShapeEnum) mySubShapeTypeCombo->itemData(
|
||||||
return (TopAbs_ShapeEnum)mySubShapeTypeCombo->itemData(mySubShapeTypeCombo->currentIndex()).toInt();
|
mySubShapeTypeCombo->currentIndex()).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : ClickOnOk()
|
// function : ClickOnOk()
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::ClickOnOk()
|
void MeasureGUI_AnnotationDlg::ClickOnOk() {
|
||||||
{
|
setIsApplyAndClose(true);
|
||||||
setIsApplyAndClose(true);
|
if (ClickOnApply())
|
||||||
if (ClickOnApply())
|
ClickOnCancel();
|
||||||
ClickOnCancel();
|
setIsApplyAndClose(false);
|
||||||
setIsApplyAndClose(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : ClickOnApply()
|
// function : ClickOnApply()
|
||||||
// purpose :
|
// purpose :
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
bool MeasureGUI_AnnotationDlg::ClickOnApply()
|
bool MeasureGUI_AnnotationDlg::ClickOnApply() {
|
||||||
{
|
if (!isApplyAndClose()) {
|
||||||
if(!isApplyAndClose()) {
|
setIsDisableBrowsing(true);
|
||||||
setIsDisableBrowsing(true);
|
setIsDisplayResult(false);
|
||||||
setIsDisplayResult(false);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
QString msg;
|
QString msg;
|
||||||
if (!isValid(msg)) {
|
if (!isValid(msg)) {
|
||||||
showError(msg);
|
showError(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SUIT_OverrideCursor wc;
|
SUIT_OverrideCursor wc;
|
||||||
SUIT_Session::session()->activeApplication()->putInfo("");
|
SUIT_Session::session()->activeApplication()->putInfo("");
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
if (openCommand())
|
||||||
if (openCommand())
|
if (!execute(/*isApplyAndClose()*/)) {
|
||||||
if (!execute (/*isApplyAndClose()*/))
|
|
||||||
{
|
|
||||||
abortCommand();
|
|
||||||
showError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(const SALOME::SALOME_Exception& e) {
|
|
||||||
SalomeApp_Tools::QtCatchCorbaException(e);
|
|
||||||
abortCommand();
|
abortCommand();
|
||||||
|
showError();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
commitCommand();
|
} catch (const SALOME::SALOME_Exception& e) {
|
||||||
|
SalomeApp_Tools::QtCatchCorbaException(e);
|
||||||
|
abortCommand();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
commitCommand();
|
||||||
|
|
||||||
if(!isApplyAndClose()) {
|
if (!isApplyAndClose()) {
|
||||||
setIsDisableBrowsing(false);
|
setIsDisableBrowsing(false);
|
||||||
setIsDisplayResult(true);
|
setIsDisplayResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (myIsCreation)
|
/*if (myIsCreation)
|
||||||
{
|
{
|
||||||
myAnnotation = GEOM::GEOM_Field::_nil();
|
myAnnotation = GEOM::GEOM_Field::_nil();
|
||||||
if (!isApplyAndClose())
|
if (!isApplyAndClose())
|
||||||
Init();
|
Init();
|
||||||
}*/
|
}*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : SetEditCurrentArgument()
|
// function : SetEditCurrentArgument()
|
||||||
// purpose : process click on shape/sub-shape button. It stores as current edit argument
|
// purpose : process click on shape/sub-shape button. It stores as current edit argument
|
||||||
// the corresponded line edit, set focus in it and unpress other button if it was pressed
|
// the corresponded line edit, set focus in it and unpress other button if it was pressed
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
|
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() {
|
||||||
{
|
QPushButton* aSelectButton = (QPushButton*) sender();
|
||||||
QPushButton* aSelectButton = (QPushButton*)sender();
|
|
||||||
|
activateSelectionArgument(aSelectButton);
|
||||||
|
|
||||||
|
SelectionIntoArgument();
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : activateSelectionArgument()
|
||||||
|
// purpose : it stores as current edit argument the corresponded line edit,
|
||||||
|
// sets the focus on it and unpresses other button if it was pressed
|
||||||
|
//=================================================================================
|
||||||
|
void MeasureGUI_AnnotationDlg::activateSelectionArgument(
|
||||||
|
QPushButton* theSelectionButton) {
|
||||||
QPushButton* anOtherButton = 0;
|
QPushButton* anOtherButton = 0;
|
||||||
if (aSelectButton == myShapeSelBtn) {
|
if (theSelectionButton == myShapeSelBtn) {
|
||||||
myEditCurrentArgument = myShapeName;
|
myEditCurrentArgument = myShapeName;
|
||||||
anOtherButton = mySubShapeSelBtn;
|
anOtherButton = mySubShapeSelBtn;
|
||||||
}
|
} else if (theSelectionButton == mySubShapeSelBtn) {
|
||||||
else if (aSelectButton == mySubShapeSelBtn) {
|
|
||||||
myEditCurrentArgument = mySubShapeName;
|
myEditCurrentArgument = mySubShapeName;
|
||||||
anOtherButton = myShapeSelBtn;
|
anOtherButton = myShapeSelBtn;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
myEditCurrentArgument = 0;
|
myEditCurrentArgument = 0;
|
||||||
|
|
||||||
if (myEditCurrentArgument)
|
if (myEditCurrentArgument)
|
||||||
myEditCurrentArgument->setFocus();
|
myEditCurrentArgument->setFocus();
|
||||||
|
|
||||||
aSelectButton->setDown(true);
|
theSelectionButton->setDown(true);
|
||||||
|
anOtherButton->setDown(false);
|
||||||
if (aSelectButton->isChecked())
|
|
||||||
anOtherButton->setDown(false);
|
|
||||||
|
|
||||||
SelectionIntoArgument();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
@ -370,40 +381,37 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
|
|||||||
// purpose : Called when selection has changed. Sets the current selection in the
|
// purpose : Called when selection has changed. Sets the current selection in the
|
||||||
// annotation property and redisplays presentation
|
// annotation property and redisplays presentation
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
|
||||||
{
|
|
||||||
if (myIsCreation && myEditCurrentArgument) {
|
if (myIsCreation && myEditCurrentArgument) {
|
||||||
GEOM::GeomObjPtr anObj = getSelected(mySelectionMode);
|
myEditCurrentArgument->setText("");
|
||||||
|
|
||||||
QString aName = GEOMBase::GetName(anObj.get());
|
GEOM::GeomObjPtr anObj = getSelected(mySelectionMode);
|
||||||
|
|
||||||
gp_Pnt anAttachPoint(0, 0, 0);
|
gp_Pnt anAttachPoint(0, 0, 0);
|
||||||
int aSubShapeIndex = -1;
|
int aSubShapeIndex = -1;
|
||||||
if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active
|
if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active
|
||||||
if (mySelectionMode == TopAbs_SHAPE) {
|
if (anObj->_is_nil() || mySelectionMode != TopAbs_SHAPE) {
|
||||||
|
myShape = GEOM::GEOM_Object::_nil();
|
||||||
|
} else {
|
||||||
|
myShape = anObj;
|
||||||
|
QString aName = GEOMBase::GetName(anObj.get());
|
||||||
myEditCurrentArgument->setText(aName);
|
myEditCurrentArgument->setText(aName);
|
||||||
|
|
||||||
if (anObj->_is_nil())
|
|
||||||
myShape = GEOM::GEOM_Object::_nil();
|
|
||||||
else
|
|
||||||
myShape = anObj;
|
|
||||||
|
|
||||||
bool aNullShape = myShape->_is_nil();
|
|
||||||
mySubShapeTypeCombo->setEnabled(!aNullShape);
|
|
||||||
mySubShapeSelBtn->setEnabled(!aNullShape);
|
|
||||||
mySubShapeName->setEnabled(!aNullShape);
|
|
||||||
activateSelection();
|
|
||||||
|
|
||||||
|
|
||||||
if (!myShape->_is_nil()) {
|
|
||||||
TopoDS_Shape aShape;
|
|
||||||
GEOMBase::GetShape(myShape.get(), aShape);
|
|
||||||
anAttachPoint = getAttachPoint(aShape);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (myEditCurrentArgument == mySubShapeName) {
|
bool aNullShape = myShape->_is_nil();
|
||||||
|
mySubShapeTypeCombo->setEnabled(!aNullShape);
|
||||||
|
updateSubShapeEnableState();
|
||||||
|
|
||||||
|
activateSelection();
|
||||||
|
|
||||||
if (!myShape->_is_nil()) {
|
if (!myShape->_is_nil()) {
|
||||||
|
TopoDS_Shape aShape;
|
||||||
|
GEOMBase::GetShape(myShape.get(), aShape);
|
||||||
|
anAttachPoint = getAttachPoint(aShape);
|
||||||
|
}
|
||||||
|
} else if (myEditCurrentArgument == mySubShapeName) {
|
||||||
|
if (!myShape->_is_nil()) {
|
||||||
|
QString aName = GEOMBase::GetName(anObj.get());
|
||||||
myEditCurrentArgument->setText(aName);
|
myEditCurrentArgument->setText(aName);
|
||||||
|
|
||||||
TopTools_IndexedMapOfShape aMainMap;
|
TopTools_IndexedMapOfShape aMainMap;
|
||||||
@ -411,7 +419,7 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
|||||||
GEOMBase::GetShape(myShape.get(), aMainShape);
|
GEOMBase::GetShape(myShape.get(), aMainShape);
|
||||||
TopExp::MapShapes(aMainShape, aMainMap);
|
TopExp::MapShapes(aMainShape, aMainMap);
|
||||||
|
|
||||||
TopExp_Explorer anExp (aMainShape, getShapeType());
|
TopExp_Explorer anExp(aMainShape, getShapeType());
|
||||||
bool isShowWarning = true;
|
bool isShowWarning = true;
|
||||||
|
|
||||||
TopoDS_Shape aSubShape;
|
TopoDS_Shape aSubShape;
|
||||||
@ -424,18 +432,19 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
anAttachPoint = getAttachPoint(aSubShape);
|
anAttachPoint = getAttachPoint(aSubShape);
|
||||||
|
myAnnotationProperties.ShapeIndex = aSubShapeIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
myAnnotationProperties.Attach = anAttachPoint;
|
myAnnotationProperties.Attach = anAttachPoint;
|
||||||
}
|
}
|
||||||
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : onTextChange
|
//function : onTextChange
|
||||||
//purpose : change annotation text
|
//purpose : change annotation text
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeasureGUI_AnnotationDlg::onTextChange()
|
void MeasureGUI_AnnotationDlg::onTextChange() {
|
||||||
{
|
|
||||||
myAnnotationProperties.Text = myTextEdit->text();
|
myAnnotationProperties.Text = myTextEdit->text();
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
@ -444,8 +453,7 @@ void MeasureGUI_AnnotationDlg::onTextChange()
|
|||||||
//function : onTypeChange
|
//function : onTypeChange
|
||||||
//purpose : change annotation type: 2D or 3D
|
//purpose : change annotation type: 2D or 3D
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeasureGUI_AnnotationDlg::onTypeChange()
|
void MeasureGUI_AnnotationDlg::onTypeChange() {
|
||||||
{
|
|
||||||
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
|
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
@ -454,12 +462,19 @@ void MeasureGUI_AnnotationDlg::onTypeChange()
|
|||||||
//function : onSubShapeTypeChange
|
//function : onSubShapeTypeChange
|
||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
|
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
|
||||||
{
|
activateSelectionArgument(mySubShapeSelBtn);
|
||||||
|
|
||||||
TopAbs_ShapeEnum aShapeType = getShapeType();
|
TopAbs_ShapeEnum aShapeType = getShapeType();
|
||||||
myAnnotationProperties.ShapeType = aShapeType;
|
myAnnotationProperties.ShapeType = aShapeType;
|
||||||
|
if (aShapeType != mySelectionMode) {
|
||||||
|
mySubShapeName->setText("");
|
||||||
|
myAnnotationProperties.ShapeIndex = -1;
|
||||||
|
mySelectionMode = aShapeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSubShapeEnableState();
|
||||||
|
|
||||||
mySelectionMode = getShapeType();
|
|
||||||
activateSelection();
|
activateSelection();
|
||||||
redisplayPreview();
|
redisplayPreview();
|
||||||
}
|
}
|
||||||
@ -474,25 +489,22 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
|
|||||||
// function : isValid()
|
// function : isValid()
|
||||||
// purpose : Verify validity of input data
|
// purpose : Verify validity of input data
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage)
|
bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) {
|
||||||
{
|
|
||||||
SalomeApp_Study* study = getStudy();
|
SalomeApp_Study* study = getStudy();
|
||||||
RETURN_WITH_MSG(!study, tr("GEOM_NO_STUDY"))
|
RETURN_WITH_MSG(!study, tr("GEOM_NO_STUDY"))
|
||||||
RETURN_WITH_MSG(study->studyDS()->GetProperties()->IsLocked(),
|
RETURN_WITH_MSG(study->studyDS()->GetProperties()->IsLocked(),
|
||||||
tr("GEOM_STUDY_LOCKED"))
|
tr("GEOM_STUDY_LOCKED"))
|
||||||
|
|
||||||
if (myIsCreation) {
|
if (myIsCreation) {
|
||||||
RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE"))
|
RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE"))
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
|
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getShapeType() != TopAbs_SHAPE) {
|
if (getShapeType() != TopAbs_SHAPE) {
|
||||||
if (myIsCreation) {
|
if (myIsCreation) {
|
||||||
RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE"))
|
RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE"))
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
|
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -510,7 +522,35 @@ bool MeasureGUI_AnnotationDlg::execute()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (myIsCreation) {
|
if (myIsCreation) {
|
||||||
|
QString aName = getNewObjectName();
|
||||||
|
|
||||||
|
SalomeApp_Study* aStudy = getStudy();
|
||||||
|
GEOMGUI_ShapeAnnotations aProp =
|
||||||
|
aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
|
||||||
|
myShape->GetStudyEntry(),
|
||||||
|
GEOM::propertyName( GEOM::ShapeAnnotations ),
|
||||||
|
QVariant() )
|
||||||
|
.value<GEOMGUI_ShapeAnnotations>();
|
||||||
|
|
||||||
|
// append new dimension record to data
|
||||||
|
aProp.Add( myAnnotationProperties );
|
||||||
|
aProp.SetName( aProp.GetNumber() - 1, aName );
|
||||||
|
aProp.SetVisible( aProp.GetNumber() - 1, true );
|
||||||
|
|
||||||
|
// store modified property data
|
||||||
|
aStudy->setObjectProperty( GEOM::sharedPropertiesId(),
|
||||||
|
myShape->GetStudyEntry(), GEOM::propertyName(GEOM::ShapeAnnotations),
|
||||||
|
aProp);
|
||||||
|
myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/*SalomeApp_Study* aStudy = getStudy();
|
||||||
|
myAnnotationProperties = aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
|
||||||
|
myShape->GetStudyEntry(),
|
||||||
|
GEOM::propertyName( GEOM::ShapeAnnotations ),
|
||||||
|
QVariant() )
|
||||||
|
.value<GEOMGUI_ShapeAnnotations>();
|
||||||
|
mySavedPropertyState.SaveToAttribute( aStudy, myEditObject->GetStudyEntry() );*/
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -519,9 +559,9 @@ bool MeasureGUI_AnnotationDlg::execute()
|
|||||||
// function : buildPrs
|
// function : buildPrs
|
||||||
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
|
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() {
|
||||||
{
|
Handle (GEOM_Annotation)
|
||||||
Handle (GEOM_Annotation) aPresentation = new GEOM_Annotation();
|
aPresentation = new GEOM_Annotation();
|
||||||
|
|
||||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||||
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
|
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
|
||||||
@ -550,10 +590,10 @@ SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
|
|||||||
|
|
||||||
// add Prs to preview
|
// add Prs to preview
|
||||||
SUIT_ViewWindow* vw =
|
SUIT_ViewWindow* vw =
|
||||||
SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
||||||
SOCC_Prs* aPrs =
|
SOCC_Prs* aPrs =
|
||||||
dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*) (vw->getViewManager()->getViewModel()))->CreatePrs(
|
dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*) (vw->getViewManager()->getViewModel()))->CreatePrs(
|
||||||
0));
|
0));
|
||||||
|
|
||||||
if (aPrs)
|
if (aPrs)
|
||||||
aPrs->AddObject(aPresentation);
|
aPrs->AddObject(aPresentation);
|
||||||
@ -561,13 +601,23 @@ SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
|
|||||||
return aPrs;
|
return aPrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : updateSubShapeEnableState
|
||||||
|
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
||||||
|
//=================================================================================
|
||||||
|
void MeasureGUI_AnnotationDlg::updateSubShapeEnableState()
|
||||||
|
{
|
||||||
|
bool isWholeShape = getShapeType() == TopAbs_SHAPE;
|
||||||
|
bool aNullShape = myShape->_is_nil();
|
||||||
|
mySubShapeSelBtn->setEnabled(!aNullShape && !isWholeShape);
|
||||||
|
mySubShapeName->setEnabled(!aNullShape && !isWholeShape);
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : buildPrs
|
// function : buildPrs
|
||||||
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
// purpose : creates annotation presentation object and corresponded SALOME presentation
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
void MeasureGUI_AnnotationDlg::redisplayPreview()
|
void MeasureGUI_AnnotationDlg::redisplayPreview() {
|
||||||
{
|
|
||||||
QString aMess;
|
QString aMess;
|
||||||
if (!isValid(aMess)) {
|
if (!isValid(aMess)) {
|
||||||
erasePreview(true);
|
erasePreview(true);
|
||||||
@ -583,11 +633,9 @@ void MeasureGUI_AnnotationDlg::redisplayPreview()
|
|||||||
|
|
||||||
if (SALOME_Prs* aPrs = buildPrs())
|
if (SALOME_Prs* aPrs = buildPrs())
|
||||||
displayPreview(aPrs);
|
displayPreview(aPrs);
|
||||||
}
|
} catch (const SALOME::SALOME_Exception& e) {
|
||||||
catch (const SALOME::SALOME_Exception& e) {
|
|
||||||
SalomeApp_Tools::QtCatchCorbaException(e);
|
SalomeApp_Tools::QtCatchCorbaException(e);
|
||||||
}
|
} catch (...) {
|
||||||
catch (...) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,8 +643,7 @@ void MeasureGUI_AnnotationDlg::redisplayPreview()
|
|||||||
// function : getAttachPoint
|
// function : getAttachPoint
|
||||||
// purpose : finds a point on shape to attach annotation object
|
// purpose : finds a point on shape to attach annotation object
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint(const TopoDS_Shape& theShape)
|
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint(const TopoDS_Shape& theShape) {
|
||||||
{
|
|
||||||
gp_Pnt aPoint = gp_Pnt(0, 0, 0);
|
gp_Pnt aPoint = gp_Pnt(0, 0, 0);
|
||||||
|
|
||||||
return aPoint;
|
return aPoint;
|
||||||
|
Loading…
Reference in New Issue
Block a user