Annotation is stored into study on "Apply" click

This commit is contained in:
nds 2016-10-12 11:08:05 +03:00
parent f88158f329
commit 5414e209c2
4 changed files with 46 additions and 50 deletions

View File

@ -137,6 +137,7 @@ GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty )
continue; continue;
} }
QString aStrName = "Annotation_X"; // TODO
QString aStrText = aRegExpItem.cap( 1 ); QString aStrText = aRegExpItem.cap( 1 );
QString aStrVisible = aRegExpItem.cap( 2 ); QString aStrVisible = aRegExpItem.cap( 2 );
QString aStrFixed = aRegExpItem.cap( 3 ); QString aStrFixed = aRegExpItem.cap( 3 );
@ -151,6 +152,7 @@ GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty )
aStrText.replace( "::", ":" ); aStrText.replace( "::", ":" );
ShapeAnnotation aEntry; ShapeAnnotation aEntry;
aEntry.Name = aStrName;
aEntry.Text = aStrText; aEntry.Text = aStrText;
aEntry.IsVisible = aStrVisible.toInt() != 0; aEntry.IsVisible = aStrVisible.toInt() != 0;
aEntry.IsScreenFixed = aStrFixed.toInt() != 0; aEntry.IsScreenFixed = aStrFixed.toInt() != 0;
@ -245,6 +247,7 @@ void GEOMGUI_ShapeAnnotations::FromPresentation( const int theIndex,
// //
ShapeAnnotation& aChangeEntry = myAnnotations[theIndex]; ShapeAnnotation& aChangeEntry = myAnnotations[theIndex];
aChangeEntry.IsScreenFixed = theShapeAnnotation->GetIsScreenFixed(); aChangeEntry.IsScreenFixed = theShapeAnnotation->GetIsScreenFixed();
aChangeEntry.Name = "Annotation_X"; /// TODO
aChangeEntry.Text = QString( (QChar*) theShapeAnnotation->GetText().ToExtString(), theShapeAnnotation->GetText().Length() ); aChangeEntry.Text = QString( (QChar*) theShapeAnnotation->GetText().ToExtString(), theShapeAnnotation->GetText().Length() );
aChangeEntry.Attach = theShapeAnnotation->GetAttachPoint().Transformed( aFromLCS ); aChangeEntry.Attach = theShapeAnnotation->GetAttachPoint().Transformed( aFromLCS );
aChangeEntry.Position = theShapeAnnotation->GetPosition(); aChangeEntry.Position = theShapeAnnotation->GetPosition();
@ -258,40 +261,7 @@ void GEOMGUI_ShapeAnnotations::ToPresentation( const int theIndex,
const Handle(GEOM_Annotation)& theShapeAnnotation, const Handle(GEOM_Annotation)& theShapeAnnotation,
const gp_Ax3& theLCS ) const gp_Ax3& theLCS )
{ {
//gp_Trsf aToLCS; myAnnotations[theIndex].ToPresentation(theShapeAnnotation, theLCS);
//aToLCS.SetTransformation( theLCS, gp_Ax3() );
//
const ShapeAnnotation& aEntry = myAnnotations[theIndex];
aEntry.ToPresentation(theShapeAnnotation, theLCS);
////
//TCollection_ExtendedString aText;
//for (int i = 0; i < (int)aEntry.Text.length(); i++ )
// aText.Insert( i + 1, aEntry.Text[ i ].unicode() );
////
//theShapeAnnotation->SetScreenFixed( aEntry.IsScreenFixed );
//theShapeAnnotation->SetText( aText );
//theShapeAnnotation->SetPosition( aEntry.Position );
//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 )
{
} }
//================================================================================= //=================================================================================

View File

@ -61,6 +61,7 @@ public:
*/ */
struct ShapeAnnotation struct ShapeAnnotation
{ {
QString Name; // annotation name label
QString Text; // annotation text label QString Text; // annotation text label
bool IsVisible; // visibility of annotation bool IsVisible; // visibility of annotation
bool IsScreenFixed; // fixed screen mode flag bool IsScreenFixed; // fixed screen mode flag
@ -78,7 +79,8 @@ public:
bool operator == (const ShapeAnnotation& theOther) const bool operator == (const ShapeAnnotation& theOther) const
{ {
return Text == theOther.Text return Name == theOther.Name
&& Text == theOther.Text
&& IsVisible == theOther.IsVisible && IsVisible == theOther.IsVisible
&& IsScreenFixed == theOther.IsScreenFixed && IsScreenFixed == theOther.IsScreenFixed
&& Position.IsEqual (theOther.Position, 0.0) && Position.IsEqual (theOther.Position, 0.0)
@ -217,7 +219,10 @@ public:
* *
* \param theIndex [in] the index of the dimension record. * \param theIndex [in] the index of the dimension record.
*/ */
virtual bool IsVisible( const int theIndex ) const; virtual bool IsVisible( const int theIndex ) const
{
return myAnnotations[theIndex].IsVisible;
}
/*! /*!
* \brief Changes visibility state of the dimension record. * \brief Changes visibility state of the dimension record.
@ -225,14 +230,20 @@ public:
* \param theIndex [in] the index of the dimension record. * \param theIndex [in] the index of the dimension record.
* \param theIsVisible [in] the new visibility state. * \param theIsVisible [in] the new visibility state.
*/ */
virtual void SetVisible( const int theIndex, const bool theIsVisible ); virtual void SetVisible( const int theIndex, const bool theIsVisible )
{
myAnnotations[theIndex].IsVisible = theIsVisible;
}
/*! /*!
* \brief Returns name of dimension record by its index. * \brief Returns name of dimension record by its index.
* *
* \param theIndex [in] the index of the dimension record. * \param theIndex [in] the index of the dimension record.
*/ */
virtual QString GetName( const int theIndex ) const; virtual QString GetName( const int theIndex ) const
{
return myAnnotations[theIndex].Name;
}
/*! /*!
* \brief Changes name of dimension record. * \brief Changes name of dimension record.
@ -240,7 +251,10 @@ public:
* \param theIndex [in] the index of the dimension record. * \param theIndex [in] the index of the dimension record.
* \param theName [in] the new name. * \param theName [in] the new name.
*/ */
virtual void SetName( const int theIndex, const QString& theName ); virtual void SetName( const int theIndex, const QString& theName )
{
myAnnotations[theIndex].Name = theName;
}
public: public:

View File

@ -217,9 +217,10 @@ void MeasureGUI_AnnotationDlg::Init() {
initName(tr("ANNOTATION_PREFIX")); initName(tr("ANNOTATION_PREFIX"));
// default presentation values // default presentation values
myAnnotationProperties.Name = getNewObjectName();
myAnnotationProperties.Position = gp_Pnt(250, 250, 250); myAnnotationProperties.Position = gp_Pnt(250, 250, 250);
myAnnotationProperties.Text = tr("ANNOTATION_PREFIX"); myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
myAnnotationProperties.IsVisible = true; myAnnotationProperties.IsVisible = false;
myAnnotationProperties.IsScreenFixed = false; myAnnotationProperties.IsScreenFixed = false;
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0); myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
myAnnotationProperties.ShapeIndex = -1; myAnnotationProperties.ShapeIndex = -1;
@ -485,6 +486,15 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
return false; \ return false; \
} }
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr MeasureGUI_AnnotationDlg::createOperation()
{
return getGeomEngine()->GetILocalOperations(getStudyId());
}
//================================================================================= //=================================================================================
// function : isValid() // function : isValid()
// purpose : Verify validity of input data // purpose : Verify validity of input data
@ -522,8 +532,6 @@ bool MeasureGUI_AnnotationDlg::execute()
return false; return false;
if (myIsCreation) { if (myIsCreation) {
QString aName = getNewObjectName();
SalomeApp_Study* aStudy = getStudy(); SalomeApp_Study* aStudy = getStudy();
GEOMGUI_ShapeAnnotations aProp = GEOMGUI_ShapeAnnotations aProp =
aStudy->getObjectProperty( GEOM::sharedPropertiesId(), aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
@ -533,14 +541,16 @@ bool MeasureGUI_AnnotationDlg::execute()
.value<GEOMGUI_ShapeAnnotations>(); .value<GEOMGUI_ShapeAnnotations>();
// append new dimension record to data // append new dimension record to data
int aPropId = aProp.GetNumber() - 1;
myAnnotationProperties.Name = getNewObjectName(); // update here as we do not listen name modification
myAnnotationProperties.IsVisible = true; // initially created annotation is hidden
aProp.Add( myAnnotationProperties ); aProp.Add( myAnnotationProperties );
aProp.SetName( aProp.GetNumber() - 1, aName );
aProp.SetVisible( aProp.GetNumber() - 1, true );
// store modified property data // store modified property data
aStudy->setObjectProperty( GEOM::sharedPropertiesId(), aStudy->setObjectProperty( GEOM::sharedPropertiesId(),
myShape->GetStudyEntry(), GEOM::propertyName(GEOM::ShapeAnnotations), myShape->GetStudyEntry(), GEOM::propertyName(GEOM::ShapeAnnotations),
aProp); aProp);
aProp.SaveToAttribute( aStudy, myShape->GetStudyEntry() );
myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) ); myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) );
} }
else { else {
@ -643,7 +653,8 @@ void MeasureGUI_AnnotationDlg::redisplayPreview() {
// function : getAttachPoint // function : getAttachPoint
// purpose : finds a point on shape to attach annotation object // purpose : finds a point on shape to attach annotation object
//================================================================================= //=================================================================================
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint(const TopoDS_Shape& theShape) { gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint(const TopoDS_Shape& theShape)
{
gp_Pnt aPoint = gp_Pnt( 0, 0, 0 ); gp_Pnt aPoint = gp_Pnt( 0, 0, 0 );
return aPoint; return aPoint;

View File

@ -65,6 +65,7 @@ public:
protected: protected:
// redefined from GEOMBase_Helper // redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid (QString&); virtual bool isValid (QString&);
virtual bool execute (); virtual bool execute ();