GEOM_GEOMGUI.hxx
GEOMGUI_CreationInfoWdg.h
GEOMGUI_TextTreeWdg.h
+ GEOMGUI_VisualProperties.h
GEOMGUI_DimensionProperty.h
GEOMGUI_ShapeAnnotations.h
)
#define GEOMGUI_DIMENSIONPROPERTY_H
// OCCT includes
+#include <GEOMGUI_VisualProperties.h>
+
#include <AIS_DiameterDimension.hxx>
#include <AIS_LengthDimension.hxx>
#include <AIS_AngleDimension.hxx>
class SalomeApp_Study;
+class GEOMGUI_DimensionProperty;
+typedef QSharedPointer<GEOMGUI_DimensionProperty> DimensionPropertyPtr;
+
/*!
* \brief Utility class to unpack/pack dimension presentations as object property of 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:
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 :
//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 :
#ifndef GEOMGUI_SHAPEANNOTATIONS_H
#define GEOMGUI_SHAPEANNOTATIONS_H
+#include <GEOMGUI_VisualProperties.h>
+
// OCCT includes
#include <gp_Ax3.hxx>
#include <QVariant>
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.
*
* 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:
/*!
* \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.
/*!
* \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:
* \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:
#include "GEOMGUI_TextTreeWdg.h"
#include "GEOMGUI_DimensionProperty.h"
+#include "GEOMGUI_ShapeAnnotations.h"
#include "GeometryGUI.h"
#include "GeometryGUI_Operations.h"
#include <GEOM_Constants.h>
createActions();
setContextMenuPolicy( Qt::CustomContextMenu );
connect( this, SIGNAL( customContextMenuRequested(const QPoint&) ),
- this, SLOT( showContextMenu(const QPoint&) ) );
+ this, SLOT( showContextMenu(const QPoint&) ) );
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() ) );
GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>( app->module( "Geometry" ) );
connect( aGeomGUI, SIGNAL( DimensionsUpdated( const QString& ) ), this, SLOT( updateBranch( const QString& ) ) );
connect( this, SIGNAL( itemClicked( QTreeWidgetItem*, int) ),
- this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
+ this, SLOT( onItemClicked( QTreeWidgetItem*, int ) ) );
}
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;
- if ( !valSO->ReferencedObject( refSO ) ) {
- // update tree of object's dimensions
- QString anEntry = valSO->GetID().c_str();
- updateBranch( anEntry );
- objEntries.removeAll( anEntry );
- }
- anIter->Next();
+ _PTR(SObject) valSO ( anIter->Value() );
+ _PTR(SObject) refSO;
+ if ( !valSO->ReferencedObject( refSO ) ) {
+ // update tree of object's dimensions
+ QString anEntry = valSO->GetID().c_str();
+ updateBranch( 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 );
}
}
}
// 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 );
- 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;
- 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 );
- }
+ itemName << aName << "";
+ if ( !objectItem ) {
+ QTreeWidgetItem* aPropRootItem = getPropertyRootItem(theBranchType);
+
+ objectItem = new QTreeWidgetItem( aPropRootItem, itemName );
+ objectItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+ objectItem->setData( 1, Qt::UserRole, theEntry );
+ 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 );
+
+ 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
// 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 );
}
}
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() );
}
// 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 icons of dimension items.
+// purpose : Update visible state of icons of entry items.
//=================================================================================
void GEOMGUI_TextTreeWdg::updateVisibilityColumn( QString theEntry, Qtx::VisibilityState theState )
{
- QTreeWidgetItem* anItem = itemFromEntry( theEntry );
+ //BranchType theBranchType,
+ updateVisibilityColumn( Geometry, theEntry, theState );
+ updateVisibilityColumn( AnnotationShape, theEntry, theState );
+}
+
+//=================================================================================
+// function : updateVisibilityColumn
+// purpose : Update icons of dimension items.
+//=================================================================================
+void GEOMGUI_TextTreeWdg::updateVisibilityColumn( const BranchType& theBranchType, QString theEntry,
+ Qtx::VisibilityState theState )
+{
+ 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 )
- continue;
- aChildItem->setIcon( 1, aProp.IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon : myInvisibleIcon );
+ aProp->LoadFromAttribute( myStudy, theEntry.toStdString() );
+ if ( aProp->GetNumber() == 0 )
+ continue;
+ aChildItem->setIcon( 1, aProp->IsVisible( idFromItem( aChildItem ) ) ? myVisibleIcon
+ : myInvisibleIcon );
aChildItem->setDisabled( false );
} else {
aChildItem->setIcon( 1, QIcon() );
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 )
- return;
+ 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 ) ) )
- aMenu.addAction( myActions[GEOMOp::OpHide] );
+ if ( aProp->IsVisible( idFromItem( anItem ) ) )
+ aMenu.addAction( myActions[GEOMOp::OpHide] );
else
- aMenu.addAction( myActions[GEOMOp::OpShow] );
+ 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 );
- if ( !anEntry.isEmpty() ) {
- // it is a shape item
- setShapeDimensionsVisibility( anEntry, theVisibility );
- } else {
- // it is a dimension item
- anEntry = entryFromItem( item->parent() );
- setDimensionVisibility( anEntry, item, theVisibility );
- }
+ else {
+ if ( !theItem->isDisabled() && !theItem->parent()->isSelected() ) {
+ QString anEntry = entryFromItem( theItem );
+ if ( !anEntry.isEmpty() ) {
+ // it is a shape item
+ setShapeDimensionsVisibility( aBranchType, anEntry, theVisibility );
+ } else {
+ // it is a dimension item
+ anEntry = entryFromItem( theItem->parent() );
+ setDimensionVisibility( aBranchType, anEntry, theItem, 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 );
}
// 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 );
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;
+}
+
#include "GEOM_GEOMGUI.hxx"
#include "GEOM_Displayer.h"
+#include "GEOMGUI_VisualProperties.h"
#include <QTreeWidget>
#include <QHash>
class SalomeApp_Application;
class SalomeApp_Study;
+
/*!
* \brief Tree view contains Dimension and Annotation text items:
* - text visibility in OCC viewer
{
Q_OBJECT
- public:
+public:
+ enum BranchType { Geometry, AnnotationShape };
+
+
+public:
GEOMGUI_TextTreeWdg( SalomeApp_Application* app );
~GEOMGUI_TextTreeWdg();
int getWinID() { return myWindowID; }
- void removeBranch( const QString& theEntry,
- bool force = true );
+ 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 );
- public slots:
+public slots:
void updateTree();
void updateBranch( const QString& theEntry );
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:
+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;
--- /dev/null
+// 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
{
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 )
{
//purpose :
//=======================================================================
-MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI,
- const bool theIsCreate, QWidget* parent, bool modal, Qt::WindowFlags fl)
-: GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
- myIsCreation(theIsCreate)
+MeasureGUI_AnnotationDlg::MeasureGUI_AnnotationDlg(GeometryGUI* theGeometryGUI, const bool theIsCreate,
+ QWidget* parent, bool modal, Qt::WindowFlags fl )
+: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
+ myIsCreation( theIsCreate )
{
myEditCurrentArgument = 0;
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();
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);
propLayout->addWidget(myShapeName, 1, 2);
- propLayout->addWidget(typeLabel, 2, 0, 1, 2);
- propLayout->addWidget(myTypeCombo, 2, 2);
+ propLayout->addWidget(typeLabel, 2, 0, 1, 2);
+ propLayout->addWidget(myTypeCombo, 2, 2);
propLayout->setColumnStretch(2, 5);
QLabel* shapeTypeLabel = new QLabel(tr("ANNOTATION_SUB_SHAPE"), propGroup);
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);
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);
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
connect(aSelMgr, SIGNAL(currentSelectionChanged()), this,
- SLOT(SelectionIntoArgument()));
+ SLOT(SelectionIntoArgument()));
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
//purpose :
//=======================================================================
-MeasureGUI_AnnotationDlg::~MeasureGUI_AnnotationDlg()
-{
+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");
myAnnotationProperties.IsScreenFixed = false;
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
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();
+ 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(mySubShapeSelBtn, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
-
- connect(myTextEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChange()));
- connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange()));
- connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)),
- this, SLOT(onSubShapeTypeChange()));
+ connect(myTextEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChange()));
+ connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange()));
+ connect(mySubShapeTypeCombo, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(onSubShapeTypeChange()));
//SelectionIntoArgument();
- }
- else { // edition
+ } else { // edition
}
redisplayPreview();
// 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);
// 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()
-{
- setIsApplyAndClose(true);
- if (ClickOnApply())
- ClickOnCancel();
- setIsApplyAndClose(false);
+void MeasureGUI_AnnotationDlg::ClickOnOk() {
+ setIsApplyAndClose(true);
+ if (ClickOnApply())
+ ClickOnCancel();
+ setIsApplyAndClose(false);
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
-bool MeasureGUI_AnnotationDlg::ClickOnApply()
-{
- if(!isApplyAndClose()) {
- setIsDisableBrowsing(true);
- setIsDisplayResult(false);
- }
+bool MeasureGUI_AnnotationDlg::ClickOnApply() {
+ if (!isApplyAndClose()) {
+ setIsDisableBrowsing(true);
+ setIsDisplayResult(false);
+ }
- QString msg;
- if (!isValid(msg)) {
- showError(msg);
- return false;
- }
+ QString msg;
+ if (!isValid(msg)) {
+ showError(msg);
+ return false;
+ }
- SUIT_OverrideCursor wc;
- SUIT_Session::session()->activeApplication()->putInfo("");
-
- try
- {
- if (openCommand())
- if (!execute (/*isApplyAndClose()*/))
- {
- abortCommand();
- showError();
- return false;
- }
- }
- catch(const SALOME::SALOME_Exception& e) {
- SalomeApp_Tools::QtCatchCorbaException(e);
+ SUIT_OverrideCursor wc;
+ SUIT_Session::session()->activeApplication()->putInfo("");
+
+ try {
+ if (openCommand())
+ if (!execute(/*isApplyAndClose()*/)) {
abortCommand();
+ showError();
return false;
- }
- commitCommand();
+ }
+ } catch (const SALOME::SALOME_Exception& e) {
+ SalomeApp_Tools::QtCatchCorbaException(e);
+ abortCommand();
+ return false;
+ }
+ commitCommand();
- if(!isApplyAndClose()) {
- setIsDisableBrowsing(false);
- setIsDisplayResult(true);
- }
+ if (!isApplyAndClose()) {
+ setIsDisableBrowsing(false);
+ setIsDisplayResult(true);
+ }
- /*if (myIsCreation)
- {
- myAnnotation = GEOM::GEOM_Field::_nil();
- if (!isApplyAndClose())
- Init();
- }*/
- return true;
- }
+ /*if (myIsCreation)
+ {
+ myAnnotation = GEOM::GEOM_Field::_nil();
+ if (!isApplyAndClose())
+ Init();
+ }*/
+ return true;
+}
//=================================================================================
// function : SetEditCurrentArgument()
// 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()
-{
- QPushButton* aSelectButton = (QPushButton*)sender();
+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())
- anOtherButton->setDown(false);
-
- SelectionIntoArgument();
+ theSelectionButton->setDown(true);
+ anOtherButton->setDown(false);
}
//=================================================================================
// 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) {
+ if (anObj->_is_nil() || mySelectionMode != TopAbs_SHAPE) {
+ myShape = GEOM::GEOM_Object::_nil();
+ } else {
+ myShape = anObj;
+ QString aName = GEOMBase::GetName(anObj.get());
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();
+ bool aNullShape = myShape->_is_nil();
+ mySubShapeTypeCombo->setEnabled(!aNullShape);
+ updateSubShapeEnableState();
+ activateSelection();
- if (!myShape->_is_nil()) {
- TopoDS_Shape aShape;
- GEOMBase::GetShape(myShape.get(), aShape);
- anAttachPoint = getAttachPoint(aShape);
- }
+ 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;
GEOMBase::GetShape(myShape.get(), aMainShape);
TopExp::MapShapes(aMainShape, aMainMap);
- TopExp_Explorer anExp (aMainShape, getShapeType());
+ TopExp_Explorer anExp(aMainShape, getShapeType());
bool isShowWarning = true;
TopoDS_Shape aSubShape;
}
}
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();
}
//function : onTypeChange
//purpose : change annotation type: 2D or 3D
//=======================================================================
-void MeasureGUI_AnnotationDlg::onTypeChange()
-{
+void MeasureGUI_AnnotationDlg::onTypeChange() {
myAnnotationProperties.IsScreenFixed = myTypeCombo->currentIndex() == 1;
redisplayPreview();
}
//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();
}
// 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(),
- tr("GEOM_STUDY_LOCKED"))
+ tr("GEOM_STUDY_LOCKED"))
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"))
}
}
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;
}
// 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 ) );
// add Prs to preview
SUIT_ViewWindow* vw =
- SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
SOCC_Prs* aPrs =
- dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*) (vw->getViewManager()->getViewModel()))->CreatePrs(
- 0));
+ dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*) (vw->getViewManager()->getViewModel()))->CreatePrs(
+ 0));
if (aPrs)
aPrs->AddObject(aPresentation);
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);
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 (...) {
}
}
// 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;