mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-14 08:01:33 +05:00
Annotation is stored into study on "Apply" click
This commit is contained in:
parent
f88158f329
commit
5414e209c2
@ -137,6 +137,7 @@ GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty )
|
||||
continue;
|
||||
}
|
||||
|
||||
QString aStrName = "Annotation_X"; // TODO
|
||||
QString aStrText = aRegExpItem.cap( 1 );
|
||||
QString aStrVisible = aRegExpItem.cap( 2 );
|
||||
QString aStrFixed = aRegExpItem.cap( 3 );
|
||||
@ -151,6 +152,7 @@ GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty )
|
||||
aStrText.replace( "::", ":" );
|
||||
|
||||
ShapeAnnotation aEntry;
|
||||
aEntry.Name = aStrName;
|
||||
aEntry.Text = aStrText;
|
||||
aEntry.IsVisible = aStrVisible.toInt() != 0;
|
||||
aEntry.IsScreenFixed = aStrFixed.toInt() != 0;
|
||||
@ -245,6 +247,7 @@ void GEOMGUI_ShapeAnnotations::FromPresentation( const int theIndex,
|
||||
//
|
||||
ShapeAnnotation& aChangeEntry = myAnnotations[theIndex];
|
||||
aChangeEntry.IsScreenFixed = theShapeAnnotation->GetIsScreenFixed();
|
||||
aChangeEntry.Name = "Annotation_X"; /// TODO
|
||||
aChangeEntry.Text = QString( (QChar*) theShapeAnnotation->GetText().ToExtString(), theShapeAnnotation->GetText().Length() );
|
||||
aChangeEntry.Attach = theShapeAnnotation->GetAttachPoint().Transformed( aFromLCS );
|
||||
aChangeEntry.Position = theShapeAnnotation->GetPosition();
|
||||
@ -258,40 +261,7 @@ void GEOMGUI_ShapeAnnotations::ToPresentation( const int theIndex,
|
||||
const Handle(GEOM_Annotation)& theShapeAnnotation,
|
||||
const gp_Ax3& theLCS )
|
||||
{
|
||||
//gp_Trsf aToLCS;
|
||||
//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 )
|
||||
{
|
||||
myAnnotations[theIndex].ToPresentation(theShapeAnnotation, theLCS);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
*/
|
||||
struct ShapeAnnotation
|
||||
{
|
||||
QString Name; // annotation name label
|
||||
QString Text; // annotation text label
|
||||
bool IsVisible; // visibility of annotation
|
||||
bool IsScreenFixed; // fixed screen mode flag
|
||||
@ -78,7 +79,8 @@ public:
|
||||
|
||||
bool operator == (const ShapeAnnotation& theOther) const
|
||||
{
|
||||
return Text == theOther.Text
|
||||
return Name == theOther.Name
|
||||
&& Text == theOther.Text
|
||||
&& IsVisible == theOther.IsVisible
|
||||
&& IsScreenFixed == theOther.IsScreenFixed
|
||||
&& Position.IsEqual (theOther.Position, 0.0)
|
||||
@ -217,7 +219,10 @@ public:
|
||||
*
|
||||
* \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.
|
||||
@ -225,14 +230,20 @@ public:
|
||||
* \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 );
|
||||
virtual void SetVisible( const int theIndex, const bool theIsVisible )
|
||||
{
|
||||
myAnnotations[theIndex].IsVisible = 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;
|
||||
virtual QString GetName( const int theIndex ) const
|
||||
{
|
||||
return myAnnotations[theIndex].Name;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Changes name of dimension record.
|
||||
@ -240,7 +251,10 @@ public:
|
||||
* \param theIndex [in] the index of the dimension record.
|
||||
* \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:
|
||||
|
||||
|
@ -217,9 +217,10 @@ void MeasureGUI_AnnotationDlg::Init() {
|
||||
initName(tr("ANNOTATION_PREFIX"));
|
||||
|
||||
// default presentation values
|
||||
myAnnotationProperties.Name = getNewObjectName();
|
||||
myAnnotationProperties.Position = gp_Pnt(250, 250, 250);
|
||||
myAnnotationProperties.Text = tr("ANNOTATION_PREFIX");
|
||||
myAnnotationProperties.IsVisible = true;
|
||||
myAnnotationProperties.IsVisible = false;
|
||||
myAnnotationProperties.IsScreenFixed = false;
|
||||
myAnnotationProperties.Attach = gp_Pnt(0, 0, 0);
|
||||
myAnnotationProperties.ShapeIndex = -1;
|
||||
@ -485,6 +486,15 @@ void MeasureGUI_AnnotationDlg::onSubShapeTypeChange() {
|
||||
return false; \
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : createOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr MeasureGUI_AnnotationDlg::createOperation()
|
||||
{
|
||||
return getGeomEngine()->GetILocalOperations(getStudyId());
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : isValid()
|
||||
// purpose : Verify validity of input data
|
||||
@ -522,8 +532,6 @@ bool MeasureGUI_AnnotationDlg::execute()
|
||||
return false;
|
||||
|
||||
if (myIsCreation) {
|
||||
QString aName = getNewObjectName();
|
||||
|
||||
SalomeApp_Study* aStudy = getStudy();
|
||||
GEOMGUI_ShapeAnnotations aProp =
|
||||
aStudy->getObjectProperty( GEOM::sharedPropertiesId(),
|
||||
@ -533,14 +541,16 @@ bool MeasureGUI_AnnotationDlg::execute()
|
||||
.value<GEOMGUI_ShapeAnnotations>();
|
||||
|
||||
// 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.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);
|
||||
aProp.SaveToAttribute( aStudy, myShape->GetStudyEntry() );
|
||||
myGeomGUI->emitDimensionsUpdated( QString( myShape->GetStudyEntry() ) );
|
||||
}
|
||||
else {
|
||||
@ -624,17 +634,17 @@ void MeasureGUI_AnnotationDlg::redisplayPreview() {
|
||||
return;
|
||||
}
|
||||
|
||||
erasePreview(false);
|
||||
erasePreview( false );
|
||||
|
||||
try {
|
||||
//SUIT_OverrideCursor wc;
|
||||
//getDisplayer()->SetColor(Quantity_NOC_VIOLET);
|
||||
//getDisplayer()->SetToActivate(false);
|
||||
|
||||
if (SALOME_Prs* aPrs = buildPrs())
|
||||
if ( SALOME_Prs* aPrs = buildPrs() )
|
||||
displayPreview(aPrs);
|
||||
} catch (const SALOME::SALOME_Exception& e) {
|
||||
SalomeApp_Tools::QtCatchCorbaException(e);
|
||||
} catch ( const SALOME::SALOME_Exception& e ) {
|
||||
SalomeApp_Tools::QtCatchCorbaException( e );
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
@ -643,8 +653,9 @@ 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 aPoint = gp_Pnt(0, 0, 0);
|
||||
gp_Pnt MeasureGUI_AnnotationDlg::getAttachPoint(const TopoDS_Shape& theShape)
|
||||
{
|
||||
gp_Pnt aPoint = gp_Pnt( 0, 0, 0 );
|
||||
|
||||
return aPoint;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ public:
|
||||
|
||||
protected:
|
||||
// redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
virtual bool isValid (QString&);
|
||||
virtual bool execute ();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user