Shape index and type property.

Compilation errors has been fixed.
This commit is contained in:
apl 2016-09-29 17:36:19 +03:00
parent 5e351de3da
commit 4697d21bcd
3 changed files with 79 additions and 35 deletions

View File

@ -76,6 +76,7 @@ SET(GEOMGUI_HEADERS
GEOMGUI_CreationInfoWdg.h GEOMGUI_CreationInfoWdg.h
GEOMGUI_TextTreeWdg.h GEOMGUI_TextTreeWdg.h
GEOMGUI_DimensionProperty.h GEOMGUI_DimensionProperty.h
GEOMGUI_ShapeAnnotations.h
) )
# header files / to be processed by moc # header files / to be processed by moc
@ -116,6 +117,7 @@ SET(GEOMGUI_SOURCES
GEOMGUI_CreationInfoWdg.cxx GEOMGUI_CreationInfoWdg.cxx
GEOMGUI_TextTreeWdg.cxx GEOMGUI_TextTreeWdg.cxx
GEOMGUI_DimensionProperty.cxx GEOMGUI_DimensionProperty.cxx
GEOMGUI_ShapeAnnotations.cxx
${_moc_SOURCES} ${_moc_SOURCES}
${_rcc_SOURCES} ${_rcc_SOURCES}
) )

View File

@ -38,26 +38,30 @@
// ENTRY: { text[string] : visibility[bool] : screen fixed[bool] : position[xyz] : attach[xyz] } // ENTRY: { text[string] : visibility[bool] : screen fixed[bool] : position[xyz] : attach[xyz] }
namespace namespace
{ {
static const QString PATTERN_ITEM_GROUP = "\\{ (Text=(?::{2,}|.)*:(?!:)Visible=.*:Screen=.*:Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}) \\}"; static const QString PATTERN_ITEM_GROUP = "\\{ (Text=(?::{2,}|.)*:(?!:)Visible=.*:Screen=.*:Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=.*:ShapeType=.*) \\}";
static const QString PATTERN_ITEM = "Text=((?::{2,}|.)*):(?!:)Visible=(\\d{1}):Screen=(\\d{1}):Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}"; static const QString PATTERN_ITEM = "Text=((?::{2,}|.)*):(?!:)Visible=(\\d{1}):Screen=(\\d{1}):Position=\\{(.*):(.*):(.*)\\}:Attach=\\{(.*):(.*):(.*)\\}:ShapeIdx=(\\d{1,*}):ShapeType=(\\d{1})";
static QString toPattern (const QString& theText, static QString toPattern (const QString& theText,
const bool theIsVisible, const bool theIsVisible,
const bool theIsFixed, const bool theIsFixed,
const gp_Pnt& thePosition, const gp_Pnt& thePosition,
const gp_Pnt& theAttach) const gp_Pnt& theAttach,
const int theShapeIndex,
const int theShapeType)
{ {
return QString("{ Text=") + theText + return QString( "{ Text=" ) + theText +
QString(":") + QString("Visible=") + QString::number( theIsVisible ? 1 : 0 ) + QString( ":" ) + QString( "Visible=" ) + QString::number( theIsVisible ? 1 : 0 ) +
QString(":") + QString("Screen=") + QString::number( theIsFixed ? 1 : 0 ) + QString( ":" ) + QString( "Screen=" ) + QString::number( theIsFixed ? 1 : 0 ) +
QString(":") + QString("Position={") + QString( ":" ) + QString( "Position={" ) +
QString::number( thePosition.X() ) + QString(":") + QString::number( thePosition.X() ) + QString( ":" ) +
QString::number( thePosition.Y() ) + QString(":") + QString::number( thePosition.Y() ) + QString( ":" ) +
QString::number( thePosition.Z() ) + QString("}") + QString::number( thePosition.Z() ) + QString( "}" ) +
QString(":") + QString("Attach={") + QString( ":" ) + QString( "Attach={" ) +
QString::number( theAttach.X() ) + QString(":") + QString::number( theAttach.X() ) + QString( ":" ) +
QString::number( theAttach.Y() ) + QString(":") + QString::number( theAttach.Y() ) + QString( ":" ) +
QString::number( theAttach.Z() ) + QString("}") + QString::number( theAttach.Z() ) + QString( "}" ) +
QString(" }"); QString( ":" ) + QString( "ShapeIdx=" ) + QString::number( theShapeIndex ) +
QString( ":" ) + QString( "ShapeType=" ) + QString::number( theShapeType ) +
QString( " }" );
} }
}; };
@ -110,15 +114,17 @@ GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty )
continue; continue;
} }
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 );
QString aStrPosX = aRegExpItem.cap( 4 ); QString aStrPosX = aRegExpItem.cap( 4 );
QString aStrPosY = aRegExpItem.cap( 5 ); QString aStrPosY = aRegExpItem.cap( 5 );
QString aStrPosZ = aRegExpItem.cap( 6 ); QString aStrPosZ = aRegExpItem.cap( 6 );
QString aStrAttX = aRegExpItem.cap( 7 ); QString aStrAttX = aRegExpItem.cap( 7 );
QString aStrAttY = aRegExpItem.cap( 8 ); QString aStrAttY = aRegExpItem.cap( 8 );
QString aStrAttZ = aRegExpItem.cap( 9 ); QString aStrAttZ = aRegExpItem.cap( 9 );
QString aStrShapeIdx = aRegExpItem.cap( 10 );
QString aStrShapeType = aRegExpItem.cap( 11 );
aStrText.replace( "::", ":" ); aStrText.replace( "::", ":" );
ShapeAnnotation aEntry; ShapeAnnotation aEntry;
@ -131,6 +137,8 @@ GEOMGUI_ShapeAnnotations::GEOMGUI_ShapeAnnotations( const QString& theProperty )
aEntry.Attach.SetX( aStrAttX.toDouble() ); aEntry.Attach.SetX( aStrAttX.toDouble() );
aEntry.Attach.SetY( aStrAttY.toDouble() ); aEntry.Attach.SetY( aStrAttY.toDouble() );
aEntry.Attach.SetZ( aStrAttZ.toDouble() ); aEntry.Attach.SetZ( aStrAttZ.toDouble() );
aEntry.ShapeIndex = aStrShapeIdx.toInt();
aEntry.ShapeType = aStrShapeType.toInt();
myAnnotations.append( aEntry ); myAnnotations.append( aEntry );
} }
@ -167,7 +175,13 @@ GEOMGUI_ShapeAnnotations::operator QString() const
{ {
const ShapeAnnotation& aEntry = myAnnotations[i]; const ShapeAnnotation& aEntry = myAnnotations[i];
// //
anItems.append (toPattern (aEntry.Text, aEntry.IsVisible, aEntry.IsScreenFixed, aEntry.Position, aEntry.Attach)); anItems.append( toPattern( aEntry.Text,
aEntry.IsVisible,
aEntry.IsScreenFixed,
aEntry.Position,
aEntry.Attach,
aEntry.ShapeIndex,
aEntry.ShapeType ) );
} }
return anItems.join( ":" ); return anItems.join( ":" );
@ -179,12 +193,12 @@ GEOMGUI_ShapeAnnotations::operator QString() const
//================================================================================= //=================================================================================
bool GEOMGUI_ShapeAnnotations::operator == (const GEOMGUI_ShapeAnnotations& theOther) const bool GEOMGUI_ShapeAnnotations::operator == (const GEOMGUI_ShapeAnnotations& theOther) const
{ {
if ( myAnnotation.size() != theOther.myAnnotations.size() ) if ( myAnnotations.size() != theOther.myAnnotations.size() )
{ {
return false; return false;
} }
for ( int i = 0; i < myAnnotation.size(); ++i ) for ( int i = 0; i < myAnnotations.size(); ++i )
{ {
if ( myAnnotations[i] != theOther.myAnnotations[i] ) if ( myAnnotations[i] != theOther.myAnnotations[i] )
{ {
@ -219,7 +233,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.Text = QString( theShapeAnnotation->GetText().ToExtString() ); 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();
} }
@ -236,8 +250,13 @@ void GEOMGUI_ShapeAnnotations::ToPresentation( const int theIndex,
aToLCS.SetTransformation( theLCS, gp_Ax3() ); aToLCS.SetTransformation( theLCS, gp_Ax3() );
// //
const ShapeAnnotation& aEntry = myAnnotations[theIndex]; const ShapeAnnotation& aEntry = myAnnotations[theIndex];
//
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->SetScreenFixed( aEntry.IsScreenFixed );
theShapeAnnotation->SetText( aEntry.Text ); theShapeAnnotation->SetText( aText );
theShapeAnnotation->SetPosition( aEntry.Position ); theShapeAnnotation->SetPosition( aEntry.Position );
theShapeAnnotation->SetAttachPoint( aEntry.Attach.Transformed( aToLCS ) ); theShapeAnnotation->SetAttachPoint( aEntry.Attach.Transformed( aToLCS ) );
} }
@ -273,7 +292,7 @@ void GEOMGUI_ShapeAnnotations::LoadFromAttribute( SalomeApp_Study* theStudy, con
std::vector<double> aPropertyArray = aDataAtt->GetColumn( i ); std::vector<double> aPropertyArray = aDataAtt->GetColumn( i );
ShapeAnnotation aEntry; ShapeAnnotation aEntry;
aEntry.Text = QString( aDataAtt->GetColumnTitle( i ).c_str() ); aEntry.Text = aDataAtt->GetColumnTitle( i ).c_str();
aEntry.IsVisible = static_cast<bool>( aPropertyArray[i++] ); aEntry.IsVisible = static_cast<bool>( aPropertyArray[i++] );
aEntry.IsScreenFixed = static_cast<bool>( aPropertyArray[i++] ); aEntry.IsScreenFixed = static_cast<bool>( aPropertyArray[i++] );
aEntry.Position.SetX( static_cast<double>( aPropertyArray[i++] ) ); aEntry.Position.SetX( static_cast<double>( aPropertyArray[i++] ) );
@ -282,6 +301,8 @@ void GEOMGUI_ShapeAnnotations::LoadFromAttribute( SalomeApp_Study* theStudy, con
aEntry.Attach.SetX( static_cast<double>( aPropertyArray[i++] ) ); aEntry.Attach.SetX( static_cast<double>( aPropertyArray[i++] ) );
aEntry.Attach.SetY( static_cast<double>( aPropertyArray[i++] ) ); aEntry.Attach.SetY( static_cast<double>( aPropertyArray[i++] ) );
aEntry.Attach.SetZ( static_cast<double>( aPropertyArray[i++] ) ); aEntry.Attach.SetZ( static_cast<double>( aPropertyArray[i++] ) );
aEntry.ShapeIndex = static_cast<int>( aPropertyArray[i++] );
aEntry.ShapeType = static_cast<int>( aPropertyArray[i++] );
myAnnotations.append( aEntry ); myAnnotations.append( aEntry );
} }
@ -319,6 +340,8 @@ void GEOMGUI_ShapeAnnotations::SaveToAttribute( SalomeApp_Study *theStudy, const
aPropertyArray.push_back( aEntry.Attach.X() ); aPropertyArray.push_back( aEntry.Attach.X() );
aPropertyArray.push_back( aEntry.Attach.Y() ); aPropertyArray.push_back( aEntry.Attach.Y() );
aPropertyArray.push_back( aEntry.Attach.Z() ); aPropertyArray.push_back( aEntry.Attach.Z() );
aPropertyArray.push_back( static_cast<double>( aEntry.ShapeIndex ) );
aPropertyArray.push_back( static_cast<double>( aEntry.ShapeType ) );
aDataAtt->AddColumn( aPropertyArray ); aDataAtt->AddColumn( aPropertyArray );
aDataAtt->SetColumnTitle( i + 1, aEntry.Text.toStdString() ); aDataAtt->SetColumnTitle( i + 1, aEntry.Text.toStdString() );

View File

@ -38,6 +38,7 @@
#include <list> #include <list>
class SalomeApp_Study; class SalomeApp_Study;
class GEOM_Annotation;
/*! /*!
* \brief Algorithms to translate and manitain list of shape annotation properties. * \brief Algorithms to translate and manitain list of shape annotation properties.
@ -55,11 +56,29 @@ public:
*/ */
struct ShapeAnnotation struct ShapeAnnotation
{ {
QString Text; QString Text; // annotation text label
bool IsVisible; bool IsVisible; // visibility of annotation
bool IsScreenFixed; bool IsScreenFixed; // fixed screen mode flag
gp_Pnt Position; gp_Pnt Position; // position of the annotation
gp_Pnt Attach; gp_Pnt Attach; // attachment point of the annotation
int ShapeIndex; // index of the annotated subshape
int ShapeType; // type of the annotated subshape
bool operator == (const ShapeAnnotation& theOther) const
{
return Text == theOther.Text
&& IsVisible == theOther.IsVisible
&& IsScreenFixed == theOther.IsScreenFixed
&& Position.IsEqual (theOther.Position, 0.0)
&& Attach.IsEqual (theOther.Attach, 0.0)
&& ShapeIndex == theOther.ShapeIndex
&& ShapeType == theOther.ShapeType;
}
bool operator != (const ShapeAnnotation& theOther) const
{
return !(operator == (theOther));
}
}; };
public: public: