Annotation's visualization in tree

This commit is contained in:
nds 2016-10-11 17:44:18 +03:00
parent d95aebd2b3
commit f88158f329
9 changed files with 635 additions and 284 deletions

View File

@ -75,6 +75,7 @@ SET(GEOMGUI_HEADERS
GEOM_GEOMGUI.hxx
GEOMGUI_CreationInfoWdg.h
GEOMGUI_TextTreeWdg.h
GEOMGUI_VisualProperties.h
GEOMGUI_DimensionProperty.h
GEOMGUI_ShapeAnnotations.h
)

View File

@ -28,6 +28,8 @@
#define GEOMGUI_DIMENSIONPROPERTY_H
// OCCT includes
#include <GEOMGUI_VisualProperties.h>
#include <AIS_DiameterDimension.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_AngleDimension.hxx>
@ -42,6 +44,9 @@
class SalomeApp_Study;
class GEOMGUI_DimensionProperty;
typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
/*!
* \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]
* 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:

View File

@ -232,17 +232,6 @@ bool GEOMGUI_ShapeAnnotations::operator == (const GEOMGUI_ShapeAnnotations& theO
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
// purpose :
@ -285,6 +274,26 @@ void GEOMGUI_ShapeAnnotations::ToPresentation( const int theIndex,
//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
// purpose :

View File

@ -27,6 +27,8 @@
#ifndef GEOMGUI_SHAPEANNOTATIONS_H
#define GEOMGUI_SHAPEANNOTATIONS_H
#include <GEOMGUI_VisualProperties.h>
// OCCT includes
#include <gp_Ax3.hxx>
#include <QVariant>
@ -40,6 +42,9 @@
class SalomeApp_Study;
class GEOM_Annotation;
class GEOMGUI_ShapeAnnotations;
typedef QSharedPointer<GEOMGUI_ShapeAnnotations> ShapeAnnotationsPtr;
/*!
* \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
* transformation.
*/
class Standard_EXPORT GEOMGUI_ShapeAnnotations
class Standard_EXPORT GEOMGUI_ShapeAnnotations : public GEOMGUI_VisualProperties
{
public:
@ -143,19 +148,13 @@ public:
/*!
* \brief Adds new shape annotation entry using explicit definition.
* \param theShapeAnnotation [in] the explicit definition of the annotation.
* \param theLCS [in] the local coordinate system of parent object.
*/
void Add( const ShapeAnnotation& 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.
* \param theIndex [in] the index of the dimension record.
@ -211,7 +210,37 @@ public:
/*!
* \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:
@ -220,14 +249,14 @@ public:
* \param theStudy [in] the study.
* \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.
* \param theStudy [in] the study.
* \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:

View File

@ -22,6 +22,7 @@
#include "GEOMGUI_TextTreeWdg.h"
#include "GEOMGUI_DimensionProperty.h"
#include "GEOMGUI_ShapeAnnotations.h"
#include "GeometryGUI.h"
#include "GeometryGUI_Operations.h"
#include <GEOM_Constants.h>
@ -144,7 +145,8 @@ void GEOMGUI_TextTreeWdg::updateTree()
if ( SC ) {
_PTR(ChildIterator) anIter ( aDSStudy->NewChildIterator( SC ) );
anIter->InitEx( true );
QList<QString> objEntries = myObjects.keys();
QList<QString> aGeomObjEntries = getObjects( Geometry ).keys();
QList<QString> anAnnotationObjEntries = getObjects( AnnotationShape ).keys();
while( anIter->More() ) {
_PTR(SObject) valSO ( anIter->Value() );
_PTR(SObject) refSO;
@ -152,12 +154,16 @@ void GEOMGUI_TextTreeWdg::updateTree()
// update tree of object's dimensions
QString anEntry = valSO->GetID().c_str();
updateBranch( anEntry );
objEntries.removeAll( anEntry );
aGeomObjEntries.removeAll( anEntry );
anAnnotationObjEntries.removeAll( anEntry );
}
anIter->Next();
}
foreach (QString entry, objEntries) {
removeBranch( entry, true );
foreach (QString entry, aGeomObjEntries) {
removeBranch( Geometry, entry, true );
}
foreach (QString entry, anAnnotationObjEntries) {
removeBranch( AnnotationShape, entry, true );
}
}
}
@ -168,40 +174,58 @@ void GEOMGUI_TextTreeWdg::updateTree()
// purpose :
//=================================================================================
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() );
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();
if ( aStudyDS ) {
_PTR(SObject) obj( aStudyDS->FindObjectID( theEntry.toStdString() ) );
QString aName = obj->GetName().c_str();
GEOMGUI_DimensionProperty aProp;
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
int nbProps = aProp.GetNumber();
int nbProps = aProp->GetNumber();
QTreeWidgetItem* objectItem = itemFromEntry( theEntry );
QTreeWidgetItem* objectItem = itemFromEntry( theBranchType, theEntry );
if ( objectItem ) {
removeBranch( theEntry, nbProps > 0 ? false : true );
removeBranch( theBranchType, theEntry, nbProps > 0 ? false : true );
}
QStringList itemName;
if ( nbProps > 0 ) {
itemName << aName << "";
if ( !objectItem ) {
objectItem = new QTreeWidgetItem( myDimensionsItem, itemName );
QTreeWidgetItem* aPropRootItem = getPropertyRootItem(theBranchType);
objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
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 );
aPropRootItem->addChild( objectItem );
getObjects( theBranchType ).insert( theEntry, objectItem );
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 < aProp->GetNumber(); ++anIt ) {
QString aName = aProp->GetName( anIt );
bool isVisible = aProp->IsVisible( anIt );
QTreeWidgetItem* anItem = new QTreeWidgetItem;
anItem->setText( 0, aName );
@ -216,19 +240,39 @@ void GEOMGUI_TextTreeWdg::updateBranch( const QString& theEntry )
}
}
//=================================================================================
// 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
// 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 )
return;
qDeleteAll( objectItem->takeChildren() );
if ( force ) {
myDimensionsItem->removeChild( objectItem );
myObjects.remove( theEntry );
QTreeWidgetItem* aPropRootItem = getPropertyRootItem( theBranchType );
aPropRootItem->removeChild( objectItem );
getObjects( theBranchType ).remove( theEntry );
}
}
@ -242,17 +286,21 @@ void GEOMGUI_TextTreeWdg::onItemClicked( QTreeWidgetItem* theItem, int theColumn
return;
std::string anEntry = entryFromItem( theItem->parent() ).toStdString();
BranchType aBranchType = branchTypeFromItem( theItem );
int aDimIndex = idFromItem( theItem );
GEOMGUI_DimensionProperty aProp;
aProp.LoadFromAttribute( myStudy, anEntry );
if ( aProp.IsVisible( aDimIndex ) ) {
aProp.SetVisible( aDimIndex, false );
VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
aProp->LoadFromAttribute( myStudy, anEntry );
if ( aProp->IsVisible( aDimIndex ) ) {
aProp->SetVisible( aDimIndex, false );
theItem->setIcon( 1, myInvisibleIcon );
} else {
aProp.SetVisible( aDimIndex, true );
aProp->SetVisible( aDimIndex, true );
theItem->setIcon( 1, myVisibleIcon );
}
aProp.SaveToAttribute( myStudy, anEntry );
aProp->SaveToAttribute( myStudy, anEntry );
redisplay( anEntry.c_str() );
}
@ -287,33 +335,48 @@ QString GEOMGUI_TextTreeWdg::entryFromItem( QTreeWidgetItem* theShapeItem )
// function : itemFromEntry
// purpose :
//=================================================================================
QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( QString theEntry )
QTreeWidgetItem* GEOMGUI_TextTreeWdg::itemFromEntry( const BranchType& theBranchType, QString theEntry )
{
if ( theEntry.isEmpty() )
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
// 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 )
return;
anItem->setDisabled( theState != Qtx::ShownState );
QTreeWidgetItem* aChildItem;
GEOMGUI_DimensionProperty aProp;
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
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 )
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
if ( aProp->GetNumber() == 0 )
continue;
aChildItem->setIcon( 1, aProp.IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon : myInvisibleIcon );
aChildItem->setIcon( 1, aProp->IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
: myInvisibleIcon );
aChildItem->setDisabled( false );
} else {
aChildItem->setIcon( 1, QIcon() );
@ -333,55 +396,64 @@ void GEOMGUI_TextTreeWdg::showContextMenu( const QPoint& pos )
QMenu aMenu;
aMenu.addAction( myActions[GEOMOp::OpShow] );
aMenu.addAction( myActions[GEOMOp::OpHide] );
if ( selectedItems().count() == 1 ) {
QTreeWidgetItem* anItem = selectedItems().first();
QString anEntry = entryFromItem( anItem->parent() );
if ( !anEntry.isEmpty() ) {
GEOMGUI_DimensionProperty aProp;
aProp.LoadFromAttribute( myStudy, anEntry.toStdString() );
if ( aProp.GetNumber() == 0 )
BranchType aBranchType = branchTypeFromItem( anItem );
VisualPropertiesPtr aProp = getVisualProperty( aBranchType );
aProp->LoadFromAttribute( myStudy, anEntry.toStdString() );
if ( aProp->GetNumber() == 0 )
return;
aMenu.clear();
if ( aProp.IsVisible( idFromItem( anItem ) ) )
if ( aProp->IsVisible( idFromItem( anItem ) ) )
aMenu.addAction( myActions[GEOMOp::OpHide] );
else
aMenu.addAction( myActions[GEOMOp::OpShow] );
}
}
QAction* selPopupItem = aMenu.exec( viewport()->mapToGlobal(pos) );
if ( selPopupItem == myActions[GEOMOp::OpShow] )
setVisibility( true );
else if ( selPopupItem == myActions[GEOMOp::OpHide] )
setVisibility( false );
if ( selPopupItem == myActions[GEOMOp::OpShow] ||
selPopupItem == myActions[GEOMOp::OpHide] ) {
bool isVisible = selPopupItem == myActions[GEOMOp::OpShow];
foreach ( QTreeWidgetItem* anItem, selectedItems() ) {
setVisibility( anItem, isVisible );
}
}
}
//=================================================================================
// 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
QTreeWidgetItem* anItem;
foreach ( QString entry, myObjects.keys() ) {
anItem = itemFromEntry( entry );
foreach ( QString entry, getObjects( aBranchType ).keys() ) {
anItem = itemFromEntry( aBranchType, entry );
if ( !anItem->isDisabled() )
setShapeDimensionsVisibility( entry, theVisibility );
setShapeDimensionsVisibility( aBranchType, entry, theVisibility );
}
return;
}
foreach ( QTreeWidgetItem* item, selectedItems() ) {
if ( item->isDisabled() || item->parent()->isSelected() )
continue;
QString anEntry = entryFromItem( item );
else {
if ( !theItem->isDisabled() && !theItem->parent()->isSelected() ) {
QString anEntry = entryFromItem( theItem );
if ( !anEntry.isEmpty() ) {
// it is a shape item
setShapeDimensionsVisibility( anEntry, theVisibility );
setShapeDimensionsVisibility( aBranchType, anEntry, theVisibility );
} else {
// it is a dimension item
anEntry = entryFromItem( item->parent() );
setDimensionVisibility( anEntry, item, theVisibility );
anEntry = entryFromItem( theItem->parent() );
setDimensionVisibility( aBranchType, anEntry, theItem, theVisibility );
}
}
}
}
@ -390,13 +462,14 @@ void GEOMGUI_TextTreeWdg::setVisibility( bool theVisibility )
// function : setShapeDimensionsVisibility
// 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;
for ( int i=0; i < anItem->childCount(); i++ ) {
aChildItem = anItem->child( i );
setDimensionVisibility( theEntry, aChildItem, theVisibility );
setDimensionVisibility( theBranchType, theEntry, aChildItem, theVisibility );
}
redisplay( theEntry );
}
@ -405,15 +478,17 @@ void GEOMGUI_TextTreeWdg::setShapeDimensionsVisibility( QString theEntry, bool t
// function : setDimensionVisibility
// 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;
aProp.LoadFromAttribute( myStudy, theEntry.toStdString() );
VisualPropertiesPtr aProp = getVisualProperty( theBranchType );
aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
int aDimIndex = idFromItem( theDimItem );
if ( aProp.GetNumber() == 0 || aProp.IsVisible( aDimIndex ) == theVisibility )
if ( aProp->GetNumber() == 0 || aProp->IsVisible( aDimIndex ) == theVisibility )
return;;
aProp.SetVisible( aDimIndex, theVisibility );
aProp.SaveToAttribute( myStudy, theEntry.toStdString() );
aProp->SetVisible( aDimIndex, theVisibility );
aProp->SaveToAttribute( myStudy, theEntry.toStdString() );
theDimItem->setIcon( 1, theVisibility ? myVisibleIcon : myInvisibleIcon );
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" );
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;
}

View File

@ -22,6 +22,7 @@
#include "GEOM_GEOMGUI.hxx"
#include "GEOM_Displayer.h"
#include "GEOMGUI_VisualProperties.h"
#include <QTreeWidget>
#include <QHash>
@ -35,6 +36,7 @@ class QTreeWidgetItem;
class SalomeApp_Application;
class SalomeApp_Study;
/*!
* \brief Tree view contains Dimension and Annotation text items:
* - text visibility in OCC viewer
@ -44,20 +46,26 @@ class GEOMGUI_EXPORT GEOMGUI_TextTreeWdg : public QTreeWidget
{
Q_OBJECT
public:
enum BranchType { Geometry, AnnotationShape };
public:
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
~GEOMGUI_TextTreeWdg();
int getWinID() { return myWindowID; }
void removeBranch( const QString& theEntry,
void removeBranch( const BranchType& theBranchType, const QString& theEntry,
bool force = true );
int idFromItem( QTreeWidgetItem* theItem );
QString entryFromItem( QTreeWidgetItem* theShapeItem );
QTreeWidgetItem* itemFromEntry( QString theEntry );
void setShapeDimensionsVisibility( QString theEntry, bool theVisibility );
void setDimensionVisibility( QString theEntry, QTreeWidgetItem* theDimItem, bool theVisibility );
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 );
protected:
void createActions();
void redisplay( QString theEntry );
@ -69,16 +77,28 @@ protected:
private slots:
void onItemClicked(QTreeWidgetItem*, int );
void updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState );
void setVisibility( bool visibility );
void setVisibility( QTreeWidgetItem* theItem, bool visibility );
void showContextMenu( const QPoint& pos );
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;
QIcon myVisibleIcon;
QIcon myInvisibleIcon;
QHash<QString, QTreeWidgetItem*> myObjects;
QHash<QString, QTreeWidgetItem*> myAnnotationObjects;
SalomeApp_Study* myStudy;
QTreeWidgetItem* myDimensionsItem;
QTreeWidgetItem* myAnnotationsItem;

View 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

View File

@ -1422,7 +1422,7 @@ void GEOM_Displayer::updateShapeAnnotations( const Handle(SALOME_InteractiveObje
{
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 )
{

219
src/MeasureGUI/MeasureGUI_AnnotationDlg.cxx Executable file → Normal file
View File

@ -93,8 +93,8 @@
//purpose :
//=======================================================================
MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
const bool theIsCreate, QWidget* parent, bool modal, Qt::WindowFlags fl)
MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI, const bool theIsCreate,
QWidget* parent, bool modal, Qt::WindowFlags fl )
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
myIsCreation( theIsCreate )
{
@ -103,9 +103,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle(myIsCreation ?
tr("CREATE_ANNOTATION_TITLE") :
tr("EDIT_ANNOTATION_TITLE"));
setWindowTitle( myIsCreation ? tr("CREATE_ANNOTATION_TITLE") : tr("EDIT_ANNOTATION_TITLE"));
// Shape type button group
mainFrame()->GroupConstructors->hide();
@ -138,7 +136,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
myTypeCombo = new QComboBox(propGroup);
myTypeCombo->insertItem(0, tr("3D"));
myTypeCombo->insertItem(1, tr("2D"));
myTypeCombo->setCurrentIndex(0); // double
myTypeCombo->setCurrentIndex(0); // 3D, not fixed
propLayout->addWidget(shapeLabel, 1, 0);
propLayout->addWidget(myShapeSelBtn, 1, 1);
@ -154,7 +152,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
mySubShapeTypeCombo->addItem(tr("GEOM_EDGE"), TopAbs_EDGE);
mySubShapeTypeCombo->addItem(tr("GEOM_FACE"), TopAbs_FACE);
mySubShapeTypeCombo->addItem(tr("GEOM_SOLID"), TopAbs_SOLID);
mySubShapeTypeCombo->setCurrentIndex(0); // VERTEX
mySubShapeTypeCombo->setCurrentIndex(0); // SHAPE
propLayout->addWidget(shapeTypeLabel, 3, 0);
propLayout->addWidget(mySubShapeTypeCombo, 3, 1, 1, 2);
@ -171,7 +169,8 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
propLayout->addWidget(mySubShapeName, 4, 2);
// Field properties
QGroupBox* styleGroup = new QGroupBox(tr("ANNOTATION_STYLE"), centralWidget());
QGroupBox* styleGroup = new QGroupBox(tr("ANNOTATION_STYLE"),
centralWidget());
QGridLayout* styleLayout = new QGridLayout(styleGroup);
styleLayout->setMargin(9);
styleLayout->setSpacing(6);
@ -205,8 +204,7 @@ MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
//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
// the values of modified object
//=================================================================================
void MeasureGUI_AnnotationDlg::Init()
{
void MeasureGUI_AnnotationDlg::Init() {
if (myIsCreation) {
initName(tr("ANNOTATION_PREFIX"));
myEditCurrentArgument = myShapeName;
// default presentation values
myAnnotationProperties.Position = gp_Pnt(250, 250, 250);
myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
@ -230,12 +225,29 @@ void MeasureGUI_AnnotationDlg::Init()
myAnnotationProperties.ShapeIndex = -1;
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();
updateSubShapeEnableState();
mySelectionMode = TopAbs_SHAPE;
connect(myShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(mySubShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
// connect controls
connect(myShapeSelBtn, SIGNAL(clicked()), this,
SLOT(SetEditCurrentArgument()));
connect(mySubShapeSelBtn, SIGNAL(clicked()), this,
SLOT(SetEditCurrentArgument()));
connect(myTextEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChange()));
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange()));
@ -243,8 +255,7 @@ void MeasureGUI_AnnotationDlg::Init()
this, SLOT(onSubShapeTypeChange()));
//SelectionIntoArgument();
}
else { // edition
} else { // edition
}
redisplayPreview();
@ -254,8 +265,7 @@ void MeasureGUI_AnnotationDlg::Init()
// function : activateSelection
// purpose : Activate local selection
//=================================================================================
void MeasureGUI_AnnotationDlg::activateSelection()
{
void MeasureGUI_AnnotationDlg::activateSelection() {
//globalSelection(GEOM_ALLSHAPES);
//if (!myShape->_is_nil() && mySelectionMode != TopAbs_SHAPE) {
// localSelection(myShape.get(), mySelectionMode);
@ -266,17 +276,16 @@ void MeasureGUI_AnnotationDlg::activateSelection()
// function : getShapeType()
// purpose :
//=================================================================================
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const
{
return (TopAbs_ShapeEnum)mySubShapeTypeCombo->itemData(mySubShapeTypeCombo->currentIndex()).toInt();
TopAbs_ShapeEnum MeasureGUI_AnnotationDlg::getShapeType() const {
return (TopAbs_ShapeEnum) mySubShapeTypeCombo->itemData(
mySubShapeTypeCombo->currentIndex()).toInt();
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void MeasureGUI_AnnotationDlg::ClickOnOk()
{
void MeasureGUI_AnnotationDlg::ClickOnOk() {
setIsApplyAndClose(true);
if (ClickOnApply())
ClickOnCancel();
@ -287,8 +296,7 @@ void MeasureGUI_AnnotationDlg::ClickOnOk()
// function : ClickOnApply()
// purpose :
//=================================================================================
bool MeasureGUI_AnnotationDlg::ClickOnApply()
{
bool MeasureGUI_AnnotationDlg::ClickOnApply() {
if (!isApplyAndClose()) {
setIsDisableBrowsing(true);
setIsDisplayResult(false);
@ -303,17 +311,14 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply()
SUIT_OverrideCursor wc;
SUIT_Session::session()->activeApplication()->putInfo("");
try
{
try {
if (openCommand())
if (!execute (/*isApplyAndClose()*/))
{
if (!execute(/*isApplyAndClose()*/)) {
abortCommand();
showError();
return false;
}
}
catch(const SALOME::SALOME_Exception& e) {
} catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
abortCommand();
return false;
@ -339,30 +344,36 @@ bool MeasureGUI_AnnotationDlg::ClickOnApply()
// 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
//=================================================================================
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
{
void MeasureGUI_AnnotationDlg::SetEditCurrentArgument() {
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;
if (aSelectButton == myShapeSelBtn) {
if (theSelectionButton == myShapeSelBtn) {
myEditCurrentArgument = myShapeName;
anOtherButton = mySubShapeSelBtn;
}
else if (aSelectButton == mySubShapeSelBtn) {
} else if (theSelectionButton == mySubShapeSelBtn) {
myEditCurrentArgument = mySubShapeName;
anOtherButton = myShapeSelBtn;
}
else
} else
myEditCurrentArgument = 0;
if (myEditCurrentArgument)
myEditCurrentArgument->setFocus();
aSelectButton->setDown(true);
if (aSelectButton->isChecked())
theSelectionButton->setDown(true);
anOtherButton->setDown(false);
SelectionIntoArgument();
}
//=================================================================================
@ -370,40 +381,37 @@ void MeasureGUI_AnnotationDlg::SetEditCurrentArgument()
// purpose : Called when selection has changed. Sets the current selection in the
// annotation property and redisplays presentation
//=================================================================================
void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
{
void MeasureGUI_AnnotationDlg::SelectionIntoArgument() {
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);
int aSubShapeIndex = -1;
if (myEditCurrentArgument == myShapeName) { // Selection of a shape is active
if (mySelectionMode == TopAbs_SHAPE) {
myEditCurrentArgument->setText(aName);
if (anObj->_is_nil())
if (anObj->_is_nil() || mySelectionMode != TopAbs_SHAPE) {
myShape = GEOM::GEOM_Object::_nil();
else
} else {
myShape = anObj;
QString aName = GEOMBase::GetName(anObj.get());
myEditCurrentArgument->setText(aName);
}
bool aNullShape = myShape->_is_nil();
mySubShapeTypeCombo->setEnabled(!aNullShape);
mySubShapeSelBtn->setEnabled(!aNullShape);
mySubShapeName->setEnabled(!aNullShape);
activateSelection();
updateSubShapeEnableState();
activateSelection();
if (!myShape->_is_nil()) {
TopoDS_Shape aShape;
GEOMBase::GetShape(myShape.get(), aShape);
anAttachPoint = getAttachPoint(aShape);
}
}
}
else if (myEditCurrentArgument == mySubShapeName) {
} else if (myEditCurrentArgument == mySubShapeName) {
if (!myShape->_is_nil()) {
QString aName = GEOMBase::GetName(anObj.get());
myEditCurrentArgument->setText(aName);
TopTools_IndexedMapOfShape aMainMap;
@ -424,18 +432,19 @@ void MeasureGUI_AnnotationDlg::SelectionIntoArgument()
}
}
anAttachPoint = getAttachPoint(aSubShape);
myAnnotationProperties.ShapeIndex = aSubShapeIndex;
}
}
myAnnotationProperties.Attach = anAttachPoint;
}
redisplayPreview();
}
//=======================================================================
//function : onTextChange
//purpose : change annotation text
//=======================================================================
void MeasureGUI_AnnotationDlg::onTextChange()
{
void MeasureGUI_AnnotationDlg::onTextChange() {
myAnnotationProperties.Text = myTextEdit->text();
redisplayPreview();
}
@ -444,8 +453,7 @@ void MeasureGUI_AnnotationDlg::onTextChange()
//function : onTypeChange
//purpose : change annotation type: 2D or 3D
//=======================================================================
void MeasureGUI_AnnotationDlg::onTypeChange()
{
void MeasureGUI_AnnotationDlg::onTypeChange() {
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
redisplayPreview();
}
@ -454,12 +462,19 @@ void MeasureGUI_AnnotationDlg::onTypeChange()
//function : onSubShapeTypeChange
//purpose :
//=======================================================================
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
{
void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
activateSelectionArgument(mySubShapeSelBtn);
TopAbs_ShapeEnum aShapeType = getShapeType();
myAnnotationProperties.ShapeType = aShapeType;
if (aShapeType != mySelectionMode) {
mySubShapeName->setText("");
myAnnotationProperties.ShapeIndex = -1;
mySelectionMode = aShapeType;
}
updateSubShapeEnableState();
mySelectionMode = getShapeType();
activateSelection();
redisplayPreview();
}
@ -474,8 +489,7 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange()
// function : isValid()
// purpose : Verify validity of input data
//=================================================================================
bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage)
{
bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage) {
SalomeApp_Study* study = getStudy();
RETURN_WITH_MSG(!study, tr("GEOM_NO_STUDY"))
RETURN_WITH_MSG(study->studyDS()->GetProperties()->IsLocked(),
@ -483,16 +497,14 @@ bool MeasureGUI_AnnotationDlg::isValid(QString& theMessage)
if (myIsCreation) {
RETURN_WITH_MSG(myShape->_is_nil(), tr("NO_SHAPE"))
}
else {
} else {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
}
if (getShapeType() != TopAbs_SHAPE) {
if (myIsCreation) {
RETURN_WITH_MSG(myAnnotationProperties.ShapeIndex < 0, tr("NO_SUB_SHAPE"))
}
else {
} else {
//RETURN_WITH_MSG(CORBA::is_nil(myShape), tr("NO_FIELD"))
}
}
@ -510,7 +522,35 @@ bool MeasureGUI_AnnotationDlg::execute()
return false;
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;
}
@ -519,9 +559,9 @@ bool MeasureGUI_AnnotationDlg::execute()
// function : buildPrs
// purpose : creates annotation presentation object and corresponded SALOME presentation
//=================================================================================
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
{
Handle (GEOM_Annotation) aPresentation = new GEOM_Annotation();
SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs() {
Handle (GEOM_Annotation)
aPresentation = new GEOM_Annotation();
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
const QFont aFont = aResMgr->fontValue( "Geometry", "shape_annotation_font", QFont( "Y14.5M-2009", 24 ) );
@ -561,13 +601,23 @@ SALOME_Prs* MeasureGUI_AnnotationDlg::buildPrs()
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
// purpose : creates annotation presentation object and corresponded SALOME presentation
//=================================================================================
void MeasureGUI_AnnotationDlg::redisplayPreview()
{
void MeasureGUI_AnnotationDlg::redisplayPreview() {
QString aMess;
if (!isValid(aMess)) {
erasePreview(true);
@ -583,11 +633,9 @@ void MeasureGUI_AnnotationDlg::redisplayPreview()
if (SALOME_Prs* aPrs = buildPrs())
displayPreview(aPrs);
}
catch (const SALOME::SALOME_Exception& e) {
} catch (const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
}
catch (...) {
} catch (...) {
}
}
@ -595,8 +643,7 @@ void MeasureGUI_AnnotationDlg::redisplayPreview()
// function : getAttachPoint
// 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);
return aPoint;