mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-13 02:00:35 +05:00
21854: Add persistent dimensions
- Dumping GUI state to python
This commit is contained in:
parent
555088296a
commit
e6d5c5f71b
@ -32,6 +32,42 @@
|
||||
|
||||
#include <SalomeApp_Study.h>
|
||||
|
||||
// Static patterns for casting value-to-string & value-from-string. The patterns are:
|
||||
// ITEM: { name[string] : visibility : type : values[composite] };
|
||||
// PLANE: a[float] : b[float] : c[float] : d[float]
|
||||
// PROPS: flyout[float] : text h pos[int] : text v pos[int] : arrow pos[int]
|
||||
// XYZ: x [float] : y[float] : z[float]
|
||||
// FLOAT: value [float]
|
||||
namespace
|
||||
{
|
||||
static const QString PATTERN_ITEM_GROUP = "\\{ (Name=(?::{2,}|.)*:(?!:)Visible=.*:Type=.*:.*) \\}";
|
||||
static const QString PATTERN_ITEM = "Name=((?::{2,}|.)*):(?!:)Visible=(\\d{1}):Type=(\\d{1}):(.*)";
|
||||
static const QString PATTERN_PLANE = "Plane=\\{(.*):(.*):(.*):(.*)\\}";
|
||||
static const QString PATTERN_PROPS = "Flyout=(.*):TextH=(.*):TextV=(.*):Arrow=(.*)";
|
||||
static const QString PATTERN_XYZ = "%1=\\{(.*):(.*):(.*)\\}";
|
||||
static const QString PATTERN_FLOAT = "%1=(.*)";
|
||||
|
||||
static const QString PATTERN_LENGTH =
|
||||
PATTERN_PLANE + ":" +
|
||||
PATTERN_PROPS + ":" +
|
||||
PATTERN_XYZ.arg( "Point1" ) + ":" +
|
||||
PATTERN_XYZ.arg( "Point2" );
|
||||
|
||||
static const QString PATTERN_DIAMETER =
|
||||
PATTERN_PLANE + ":" +
|
||||
PATTERN_PROPS + ":" +
|
||||
PATTERN_XYZ.arg( "Position" ) + ":" +
|
||||
PATTERN_XYZ.arg( "NDir" ) + ":" +
|
||||
PATTERN_XYZ.arg( "XDir" ) + ":" +
|
||||
PATTERN_FLOAT.arg( "Radius" );
|
||||
|
||||
static const QString PATTERN_ANGLE =
|
||||
PATTERN_PROPS + ":" +
|
||||
PATTERN_XYZ.arg( "Point1" ) + ":" +
|
||||
PATTERN_XYZ.arg( "Point2" ) + ":" +
|
||||
PATTERN_XYZ.arg( "Point3" );
|
||||
};
|
||||
|
||||
//=================================================================================
|
||||
// function : Length::Init
|
||||
// purpose :
|
||||
@ -73,6 +109,77 @@ void GEOMGUI_DimensionProperty::Length::Update( Handle(AIS_LengthDimension)& the
|
||||
theIO->SetDimensionAspect( aStyle );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Length::ToValues
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_DimensionProperty::Length::ToValues(std::vector<double>& theValues) const
|
||||
{
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A, B, C, D;
|
||||
Plane.Coefficients( A, B, C, D );
|
||||
theValues.push_back( (double) A );
|
||||
theValues.push_back( (double) B );
|
||||
theValues.push_back( (double) C );
|
||||
theValues.push_back( (double) D );
|
||||
|
||||
// flyout size [6]
|
||||
theValues.push_back( (double) Flyout );
|
||||
|
||||
// text flags [7,8]
|
||||
theValues.push_back( (double) TextHPos );
|
||||
theValues.push_back( (double) TextVPos );
|
||||
|
||||
// arrow flags [9]
|
||||
theValues.push_back( (double) ArrowPos );
|
||||
|
||||
// point 1 [10,11,12]
|
||||
theValues.push_back( (double) FirstPoint.X() );
|
||||
theValues.push_back( (double) FirstPoint.Y() );
|
||||
theValues.push_back( (double) FirstPoint.Z() );
|
||||
|
||||
// point 2 [13,14,15]
|
||||
theValues.push_back( (double) SecondPoint.X() );
|
||||
theValues.push_back( (double) SecondPoint.Y() );
|
||||
theValues.push_back( (double) SecondPoint.Z() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Length::FromValues
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_DimensionProperty::Length::FromValues(int& theIt, const std::vector<double>& theValues)
|
||||
{
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real B = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real C = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real D = (Standard_Real) theValues[theIt++];
|
||||
Plane = gp_Pln( A, B, C, D );
|
||||
|
||||
// flyout size [6]
|
||||
Flyout = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// text flags [7,8]
|
||||
TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)theValues[theIt++];
|
||||
TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)theValues[theIt++];
|
||||
|
||||
// arrow flags [9]
|
||||
ArrowPos = (Prs3d_DimensionArrowOrientation) (int)theValues[theIt++];
|
||||
|
||||
// point 1 [10,11,12]
|
||||
Standard_Real aFirstX = theValues[theIt++];
|
||||
Standard_Real aFirstY = theValues[theIt++];
|
||||
Standard_Real aFirstZ = theValues[theIt++];
|
||||
FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
|
||||
|
||||
// point 2 [13,14,15]
|
||||
Standard_Real aSecondX = theValues[theIt++];
|
||||
Standard_Real aSecondY = theValues[theIt++];
|
||||
Standard_Real aSecondZ = theValues[theIt++];
|
||||
SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Length::operator ==
|
||||
// purpose :
|
||||
@ -162,6 +269,97 @@ void GEOMGUI_DimensionProperty::Diameter::Update( Handle(AIS_DiameterDimension)&
|
||||
theIO->SetDimensionAspect( aStyle );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Diameter::ToValues
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_DimensionProperty::Diameter::ToValues(std::vector<double>& theValues) const
|
||||
{
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A, B, C, D;
|
||||
Plane.Coefficients( A, B, C, D );
|
||||
theValues.push_back( (double) A );
|
||||
theValues.push_back( (double) B );
|
||||
theValues.push_back( (double) C );
|
||||
theValues.push_back( (double) D );
|
||||
|
||||
// flyout size [6]
|
||||
theValues.push_back( (double) Flyout );
|
||||
|
||||
// text flags [7,8]
|
||||
theValues.push_back( (double) TextHPos );
|
||||
theValues.push_back( (double) TextVPos );
|
||||
|
||||
// arrow flags [9]
|
||||
theValues.push_back( (double) ArrowPos );
|
||||
|
||||
// circle location [10,11,12]
|
||||
theValues.push_back( (double) Circle.Location().X() );
|
||||
theValues.push_back( (double) Circle.Location().Y() );
|
||||
theValues.push_back( (double) Circle.Location().Z() );
|
||||
|
||||
// circle normal [13,14,15]
|
||||
theValues.push_back( (double) Circle.Axis().Direction().X() );
|
||||
theValues.push_back( (double) Circle.Axis().Direction().Y() );
|
||||
theValues.push_back( (double) Circle.Axis().Direction().Z() );
|
||||
|
||||
// x-direction [16,17,18]
|
||||
theValues.push_back( (double) Circle.XAxis().Direction().X() );
|
||||
theValues.push_back( (double) Circle.XAxis().Direction().Y() );
|
||||
theValues.push_back( (double) Circle.XAxis().Direction().Z() );
|
||||
|
||||
// radius [19]
|
||||
theValues.push_back( (double) Circle.Radius() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Diameter::FromValues
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_DimensionProperty::Diameter::FromValues(int& theIt, const std::vector<double>& theValues)
|
||||
{
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real B = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real C = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real D = (Standard_Real) theValues[theIt++];
|
||||
Plane = gp_Pln( A, B, C, D );
|
||||
|
||||
// flyout size [6]
|
||||
Flyout = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// text flags [7,8]
|
||||
TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)theValues[theIt++];
|
||||
TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)theValues[theIt++];
|
||||
|
||||
// arrow flags [9]
|
||||
ArrowPos = (Prs3d_DimensionArrowOrientation) (int)theValues[theIt++];
|
||||
|
||||
// circle location [10,11,12]
|
||||
Standard_Real aLocX = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aLocY = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aLocZ = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// circle normal [13,14,15]
|
||||
Standard_Real aNormX = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aNormY = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aNormZ = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// x-direction [16,17,18]
|
||||
Standard_Real aXDirX = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aXDirY = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aXDirZ = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// radius [19]
|
||||
Standard_Real aRadius = (Standard_Real) theValues[theIt++];
|
||||
|
||||
gp_Ax2 anAx( gp_Pnt( aLocX, aLocY, aLocZ ),
|
||||
gp_Dir( aNormX, aNormY, aNormZ ),
|
||||
gp_Dir( aXDirX, aXDirY, aXDirZ ) );
|
||||
|
||||
Circle = gp_Circ( anAx, aRadius );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Diameter::operator ==
|
||||
// purpose :
|
||||
@ -244,6 +442,74 @@ void GEOMGUI_DimensionProperty::Angle::Update( Handle(AIS_AngleDimension)& theIO
|
||||
theIO->SetDimensionAspect( aStyle );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Angle::ToValues
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_DimensionProperty::Angle::ToValues(std::vector<double>& theValues) const
|
||||
{
|
||||
// flyout [2]
|
||||
theValues.push_back( (double) Flyout );
|
||||
|
||||
// text flags [3,4]
|
||||
theValues.push_back( (double) TextHPos );
|
||||
theValues.push_back( (double) TextVPos );
|
||||
|
||||
// arrow flags [5]
|
||||
theValues.push_back( (double) ArrowPos );
|
||||
|
||||
// point 1 [6,7,8]
|
||||
theValues.push_back( (double) FirstPoint.X() );
|
||||
theValues.push_back( (double) FirstPoint.Y() );
|
||||
theValues.push_back( (double) FirstPoint.Z() );
|
||||
|
||||
// point 2 [9,10,11]
|
||||
theValues.push_back( (double) SecondPoint.X() );
|
||||
theValues.push_back( (double) SecondPoint.Y() );
|
||||
theValues.push_back( (double) SecondPoint.Z() );
|
||||
|
||||
// center [12,13,14]
|
||||
theValues.push_back( (double) CenterPoint.X() );
|
||||
theValues.push_back( (double) CenterPoint.Y() );
|
||||
theValues.push_back( (double) CenterPoint.Z() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Angle::FromValues
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void GEOMGUI_DimensionProperty::Angle::FromValues(int& theIt, const std::vector<double>& theValues)
|
||||
{
|
||||
// flyout [2]
|
||||
Flyout = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// text flags [3,4]
|
||||
TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)theValues[theIt++];
|
||||
TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)theValues[theIt++];
|
||||
|
||||
// arrow flags [5]
|
||||
ArrowPos = (Prs3d_DimensionArrowOrientation) (int)theValues[theIt++];
|
||||
|
||||
// point 1 [6,7,8]
|
||||
Standard_Real aFirstX = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aFirstY = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aFirstZ = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// point 2 [9,10,11]
|
||||
Standard_Real aSecondX = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aSecondY = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aSecondZ = (Standard_Real) theValues[theIt++];
|
||||
|
||||
// center [12,13,14]
|
||||
Standard_Real aCenterX = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aCenterY = (Standard_Real) theValues[theIt++];
|
||||
Standard_Real aCenterZ = (Standard_Real) theValues[theIt++];
|
||||
|
||||
FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
|
||||
SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
|
||||
CenterPoint = gp_Pnt( aCenterX, aCenterY, aCenterZ );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Angle::operator ==
|
||||
// purpose :
|
||||
@ -329,6 +595,85 @@ GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( SalomeApp_Study* theStudy,
|
||||
LoadFromAttribute( theStudy, theEntry );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Init constructor
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOMGUI_DimensionProperty::GEOMGUI_DimensionProperty( const QString& theProperty )
|
||||
{
|
||||
QRegExp aRegExpItemGroups( PATTERN_ITEM_GROUP );
|
||||
QRegExp aRegExpItem( "^" + PATTERN_ITEM + "$" );
|
||||
aRegExpItemGroups.setMinimal( true );
|
||||
aRegExpItem.setMinimal( true );
|
||||
|
||||
int aPos = 0;
|
||||
while ( ( aPos = aRegExpItemGroups.indexIn( theProperty, aPos ) ) != -1 )
|
||||
{
|
||||
aPos += aRegExpItemGroups.matchedLength();
|
||||
|
||||
QString aStrItem = aRegExpItemGroups.cap(1);
|
||||
|
||||
if ( aRegExpItem.indexIn( aStrItem ) < 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// extract name
|
||||
QString aStrName = aRegExpItem.cap( 1 );
|
||||
QString aStrVisible = aRegExpItem.cap( 2 );
|
||||
QString aStrType = aRegExpItem.cap( 3 );
|
||||
QString aStrValues = aRegExpItem.cap( 4 );
|
||||
|
||||
// extract values
|
||||
aStrName.replace( "::", ":" );
|
||||
bool isVisible = aStrVisible.toInt() != 0;
|
||||
int aType = aStrType.toInt();
|
||||
|
||||
RecordPtr aRecord;
|
||||
switch ( aType )
|
||||
{
|
||||
case DimensionType_Length : aRecord = RecordPtr( new Length ); break;
|
||||
case DimensionType_Diameter : aRecord = RecordPtr( new Diameter ); break;
|
||||
case DimensionType_Angle : aRecord = RecordPtr( new Angle ); break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
QRegExp aRegExpValues;
|
||||
switch ( aType )
|
||||
{
|
||||
case DimensionType_Length : aRegExpValues = QRegExp( "^" + PATTERN_LENGTH + "$" ); break;
|
||||
case DimensionType_Diameter : aRegExpValues = QRegExp( "^" + PATTERN_DIAMETER + "$" ); break;
|
||||
case DimensionType_Angle : aRegExpValues = QRegExp( "^" + PATTERN_ANGLE + "$" ); break;
|
||||
}
|
||||
|
||||
aRegExpValues.setMinimal(true);
|
||||
|
||||
if ( aRegExpValues.indexIn( aStrValues ) < 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<double> aValues;
|
||||
|
||||
QStringList aStrListOfValues = aRegExpValues.capturedTexts();
|
||||
QStringList::Iterator aStrListOfValuesIt = aStrListOfValues.begin();
|
||||
++aStrListOfValuesIt; // skip first capture
|
||||
for ( ; aStrListOfValuesIt != aStrListOfValues.end(); ++aStrListOfValuesIt )
|
||||
{
|
||||
aValues.push_back( (*aStrListOfValuesIt).toDouble() );
|
||||
}
|
||||
|
||||
int aValueIt = 0;
|
||||
|
||||
aRecord->FromValues( aValueIt, aValues );
|
||||
|
||||
myVisibility.append( isVisible );
|
||||
myNames.append( aStrName );
|
||||
myRecords.append( aRecord );
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Destructor
|
||||
// purpose :
|
||||
@ -341,13 +686,77 @@ GEOMGUI_DimensionProperty::~GEOMGUI_DimensionProperty()
|
||||
// function : operator QVariant()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOMGUI_DimensionProperty::operator QVariant()
|
||||
GEOMGUI_DimensionProperty::operator QVariant() const
|
||||
{
|
||||
QVariant aQVariant;
|
||||
aQVariant.setValue( *this );
|
||||
return aQVariant;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : operator QString()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOMGUI_DimensionProperty::operator QString() const
|
||||
{
|
||||
QStringList anItems;
|
||||
|
||||
VectorOfVisibility::ConstIterator aVisibilityIt = myVisibility.constBegin();
|
||||
VectorOfRecords::ConstIterator aRecordIt = myRecords.constBegin();
|
||||
VectorOfNames::ConstIterator aNameIt = myNames.constBegin();
|
||||
for ( ; aRecordIt != myRecords.constEnd(); ++aRecordIt, ++aNameIt, ++aVisibilityIt )
|
||||
{
|
||||
QString aName = *aNameIt;
|
||||
const bool& isVisible = *aVisibilityIt;
|
||||
const RecordPtr& aRecord = *aRecordIt;
|
||||
|
||||
// pack values
|
||||
std::vector<double> aPacked;
|
||||
aRecord->ToValues( aPacked );
|
||||
|
||||
// put values into pattern
|
||||
QString aStringValues;
|
||||
switch ( aRecord->Type() )
|
||||
{
|
||||
case DimensionType_Length : aStringValues = PATTERN_LENGTH; break;
|
||||
case DimensionType_Diameter : aStringValues = PATTERN_DIAMETER; break;
|
||||
case DimensionType_Angle : aStringValues = PATTERN_ANGLE; break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
aStringValues.remove("\\");
|
||||
|
||||
int it = 0;
|
||||
for ( ; it < aPacked.size(); ++it )
|
||||
{
|
||||
int aNextPos = aStringValues.indexOf("(.*)");
|
||||
if ( aNextPos < 0 )
|
||||
{
|
||||
break; // invalid pattern
|
||||
}
|
||||
|
||||
aStringValues.replace( aNextPos, 4, QString::number( aPacked.at(it) ) );
|
||||
}
|
||||
|
||||
if ( it < aPacked.size() )
|
||||
{
|
||||
continue; // invalid pattern
|
||||
}
|
||||
|
||||
// replace all ':' to '::' for pattern matching
|
||||
aName.replace(":", "::");
|
||||
|
||||
anItems.append(
|
||||
QString("{ Name=") + aName +
|
||||
QString(":") + QString("Visible=") + QString::number( isVisible ? 1 : 0 ) +
|
||||
QString(":") + QString("Type=") + QString::number( (int) aRecord->Type() ) +
|
||||
QString(":") + aStringValues + QString(" }") );
|
||||
}
|
||||
|
||||
return anItems.join( ":" );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : operator ==
|
||||
// purpose :
|
||||
@ -651,129 +1060,11 @@ void GEOMGUI_DimensionProperty::LoadFromAttribute( SalomeApp_Study* theStudy,
|
||||
|
||||
switch (aType)
|
||||
{
|
||||
case DimensionType_Length :
|
||||
{
|
||||
Length* aLength = new Length;
|
||||
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A = (Standard_Real) aPacked[it++];
|
||||
Standard_Real B = (Standard_Real) aPacked[it++];
|
||||
Standard_Real C = (Standard_Real) aPacked[it++];
|
||||
Standard_Real D = (Standard_Real) aPacked[it++];
|
||||
aLength->Plane = gp_Pln( A, B, C, D );
|
||||
|
||||
// flyout size [6]
|
||||
aLength->Flyout = (Standard_Real) aPacked[it++];
|
||||
|
||||
// text flags [7,8]
|
||||
aLength->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
|
||||
aLength->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
|
||||
|
||||
// arrow flags [9]
|
||||
aLength->ArrowPos = (Prs3d_DimensionArrowOrientation) (int)aPacked[it++];
|
||||
|
||||
// point 1 [10,11,12]
|
||||
Standard_Real aFirstX = aPacked[it++];
|
||||
Standard_Real aFirstY = aPacked[it++];
|
||||
Standard_Real aFirstZ = aPacked[it++];
|
||||
aLength->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
|
||||
|
||||
// point 2 [13,14,15]
|
||||
Standard_Real aSecondX = aPacked[it++];
|
||||
Standard_Real aSecondY = aPacked[it++];
|
||||
Standard_Real aSecondZ = aPacked[it++];
|
||||
aLength->SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
|
||||
|
||||
aRecord = RecordPtr( aLength );
|
||||
break;
|
||||
}
|
||||
|
||||
case DimensionType_Diameter :
|
||||
{
|
||||
Diameter* aDiam = new Diameter;
|
||||
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A = (Standard_Real) aPacked[it++];
|
||||
Standard_Real B = (Standard_Real) aPacked[it++];
|
||||
Standard_Real C = (Standard_Real) aPacked[it++];
|
||||
Standard_Real D = (Standard_Real) aPacked[it++];
|
||||
aDiam->Plane = gp_Pln( A, B, C, D );
|
||||
|
||||
// flyout size [6]
|
||||
aDiam->Flyout = (Standard_Real) aPacked[it++];
|
||||
|
||||
// text flags [7,8]
|
||||
aDiam->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
|
||||
aDiam->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
|
||||
|
||||
// arrow flags [9]
|
||||
aDiam->ArrowPos = (Prs3d_DimensionArrowOrientation) (int)aPacked[it++];
|
||||
|
||||
// circle location [10,11,12]
|
||||
Standard_Real aLocX = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aLocY = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aLocZ = (Standard_Real) aPacked[it++];
|
||||
|
||||
// circle normal [13,14,15]
|
||||
Standard_Real aNormX = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aNormY = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aNormZ = (Standard_Real) aPacked[it++];
|
||||
|
||||
// x-direction [16,17,18]
|
||||
Standard_Real aXDirX = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aXDirY = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aXDirZ = (Standard_Real) aPacked[it++];
|
||||
|
||||
// radius [19]
|
||||
Standard_Real aRadius = (Standard_Real) aPacked[it++];
|
||||
|
||||
gp_Ax2 anAx( gp_Pnt( aLocX, aLocY, aLocZ ),
|
||||
gp_Dir( aNormX, aNormY, aNormZ ),
|
||||
gp_Dir( aXDirX, aXDirY, aXDirZ ) );
|
||||
|
||||
aDiam->Circle = gp_Circ( anAx, aRadius );
|
||||
|
||||
aRecord = RecordPtr( aDiam );
|
||||
break;
|
||||
}
|
||||
|
||||
case DimensionType_Angle :
|
||||
{
|
||||
Angle* anAngle = new Angle;
|
||||
|
||||
// flyout [2]
|
||||
anAngle->Flyout = (Standard_Real) aPacked[it++];
|
||||
|
||||
// text flags [3,4]
|
||||
anAngle->TextHPos = (Prs3d_DimensionTextHorizontalPosition)(int)aPacked[it++];
|
||||
anAngle->TextVPos = (Prs3d_DimensionTextVerticalPosition) (int)aPacked[it++];
|
||||
|
||||
// arrow flags [5]
|
||||
anAngle->ArrowPos = (Prs3d_DimensionArrowOrientation) (int)aPacked[it++];
|
||||
|
||||
// point 1 [6,7,8]
|
||||
Standard_Real aFirstX = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aFirstY = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aFirstZ = (Standard_Real) aPacked[it++];
|
||||
|
||||
// point 2 [9,10,11]
|
||||
Standard_Real aSecondX = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aSecondY = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aSecondZ = (Standard_Real) aPacked[it++];
|
||||
|
||||
// center [12,13,14]
|
||||
Standard_Real aCenterX = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aCenterY = (Standard_Real) aPacked[it++];
|
||||
Standard_Real aCenterZ = (Standard_Real) aPacked[it++];
|
||||
|
||||
anAngle->FirstPoint = gp_Pnt( aFirstX, aFirstY, aFirstZ );
|
||||
anAngle->SecondPoint = gp_Pnt( aSecondX, aSecondY, aSecondZ );
|
||||
anAngle->CenterPoint = gp_Pnt( aCenterX, aCenterY, aCenterZ );
|
||||
|
||||
aRecord = RecordPtr( anAngle );
|
||||
break;
|
||||
}
|
||||
case DimensionType_Length : aRecord = RecordPtr( new Length ); break;
|
||||
case DimensionType_Diameter : aRecord = RecordPtr( new Diameter ); break;
|
||||
case DimensionType_Angle : aRecord = RecordPtr( new Angle ); break;
|
||||
}
|
||||
aRecord->FromValues(it, aPacked);
|
||||
|
||||
myVisibility.append( isVisible );
|
||||
myNames.append( aName );
|
||||
@ -815,115 +1106,8 @@ void GEOMGUI_DimensionProperty::SaveToAttribute( SalomeApp_Study *theStudy,
|
||||
// type [1]
|
||||
aPacked.push_back( (double) aRecord->Type() );
|
||||
|
||||
switch ( aRecord->Type() )
|
||||
{
|
||||
case DimensionType_Length:
|
||||
{
|
||||
Length* aProps = aRecord->AsLength();
|
||||
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A, B, C, D;
|
||||
aProps->Plane.Coefficients( A, B, C, D );
|
||||
aPacked.push_back( (double) A );
|
||||
aPacked.push_back( (double) B );
|
||||
aPacked.push_back( (double) C );
|
||||
aPacked.push_back( (double) D );
|
||||
|
||||
// flyout size [6]
|
||||
aPacked.push_back( (double) aProps->Flyout );
|
||||
|
||||
// text flags [7,8]
|
||||
aPacked.push_back( (double) aProps->TextHPos );
|
||||
aPacked.push_back( (double) aProps->TextVPos );
|
||||
|
||||
// arrow flags [9]
|
||||
aPacked.push_back( (double) aProps->ArrowPos );
|
||||
|
||||
// point 1 [10,11,12]
|
||||
aPacked.push_back( (double) aProps->FirstPoint.X() );
|
||||
aPacked.push_back( (double) aProps->FirstPoint.Y() );
|
||||
aPacked.push_back( (double) aProps->FirstPoint.Z() );
|
||||
|
||||
// point 2 [13,14,15]
|
||||
aPacked.push_back( (double) aProps->SecondPoint.X() );
|
||||
aPacked.push_back( (double) aProps->SecondPoint.Y() );
|
||||
aPacked.push_back( (double) aProps->SecondPoint.Z() );
|
||||
break;
|
||||
}
|
||||
|
||||
case DimensionType_Diameter:
|
||||
{
|
||||
Diameter* aProps = aRecord->AsDiameter();
|
||||
|
||||
// custom plane [2,3,4,5]
|
||||
Standard_Real A, B, C, D;
|
||||
aProps->Plane.Coefficients( A, B, C, D );
|
||||
aPacked.push_back( (double) A );
|
||||
aPacked.push_back( (double) B );
|
||||
aPacked.push_back( (double) C );
|
||||
aPacked.push_back( (double) D );
|
||||
|
||||
// flyout size [6]
|
||||
aPacked.push_back( (double) aProps->Flyout );
|
||||
|
||||
// text flags [7,8]
|
||||
aPacked.push_back( (double) aProps->TextHPos );
|
||||
aPacked.push_back( (double) aProps->TextVPos );
|
||||
|
||||
// arrow flags [9]
|
||||
aPacked.push_back( (double) aProps->ArrowPos );
|
||||
|
||||
// circle location [10,11,12]
|
||||
aPacked.push_back( (double) aProps->Circle.Location().X() );
|
||||
aPacked.push_back( (double) aProps->Circle.Location().Y() );
|
||||
aPacked.push_back( (double) aProps->Circle.Location().Z() );
|
||||
|
||||
// circle normal [13,14,15]
|
||||
aPacked.push_back( (double) aProps->Circle.Axis().Direction().X() );
|
||||
aPacked.push_back( (double) aProps->Circle.Axis().Direction().Y() );
|
||||
aPacked.push_back( (double) aProps->Circle.Axis().Direction().Z() );
|
||||
|
||||
// x-direction [16,17,18]
|
||||
aPacked.push_back( (double) aProps->Circle.XAxis().Direction().X() );
|
||||
aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Y() );
|
||||
aPacked.push_back( (double) aProps->Circle.XAxis().Direction().Z() );
|
||||
|
||||
// radius [19]
|
||||
aPacked.push_back( (double) aProps->Circle.Radius() );
|
||||
break;
|
||||
}
|
||||
|
||||
case DimensionType_Angle:
|
||||
{
|
||||
Angle* aProps = aRecord->AsAngle();
|
||||
|
||||
// flyout [2]
|
||||
aPacked.push_back( (double) aProps->Flyout );
|
||||
|
||||
// text flags [3,4]
|
||||
aPacked.push_back( (double) aProps->TextHPos );
|
||||
aPacked.push_back( (double) aProps->TextVPos );
|
||||
|
||||
// arrow flags [5]
|
||||
aPacked.push_back( (double) aProps->ArrowPos );
|
||||
|
||||
// point 1 [6,7,8]
|
||||
aPacked.push_back( (double) aProps->FirstPoint.X() );
|
||||
aPacked.push_back( (double) aProps->FirstPoint.Y() );
|
||||
aPacked.push_back( (double) aProps->FirstPoint.Z() );
|
||||
|
||||
// point 2 [9,10,11]
|
||||
aPacked.push_back( (double) aProps->SecondPoint.X() );
|
||||
aPacked.push_back( (double) aProps->SecondPoint.Y() );
|
||||
aPacked.push_back( (double) aProps->SecondPoint.Z() );
|
||||
|
||||
// center [12,13,14]
|
||||
aPacked.push_back( (double) aProps->CenterPoint.X() );
|
||||
aPacked.push_back( (double) aProps->CenterPoint.Y() );
|
||||
aPacked.push_back( (double) aProps->CenterPoint.Z() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
// values
|
||||
aRecord->ToValues( aPacked );
|
||||
|
||||
aRecordsAtt->AddColumn( aPacked );
|
||||
aRecordsAtt->SetColumnTitle( it + 1, aName.toStdString() );
|
||||
|
@ -93,6 +93,9 @@ public:
|
||||
Diameter* AsDiameter() { return static_cast<Diameter*>( this ); }
|
||||
Angle* AsAngle() { return static_cast<Angle*>( this ); }
|
||||
|
||||
virtual void ToValues(std::vector<double>& theValues) const = 0;
|
||||
virtual void FromValues(int& theIt, const std::vector<double>& theValues) = 0;
|
||||
|
||||
private:
|
||||
DimensionType myType;
|
||||
};
|
||||
@ -140,6 +143,19 @@ public:
|
||||
*/
|
||||
void Update( Handle(AIS_LengthDimension)& theIO, const gp_Ax3& theLCS );
|
||||
|
||||
/*!
|
||||
* \brief Packs properties to array of doubles.
|
||||
* \param theValues [out] the values vector to populate.
|
||||
*/
|
||||
void ToValues(std::vector<double>& theValues) const;
|
||||
|
||||
/*!
|
||||
* \brief Unpacks properties from array of doubles.
|
||||
* \param theIt [in/out] the array index iterator.
|
||||
* \param theValues [in] the vector of values.
|
||||
*/
|
||||
void FromValues(int& theIt, const std::vector<double>& theValues);
|
||||
|
||||
/*!
|
||||
* \brief Overload comparsion.
|
||||
*/
|
||||
@ -195,6 +211,19 @@ public:
|
||||
*/
|
||||
void Update( Handle(AIS_DiameterDimension)& theIO, const gp_Ax3& theLCS );
|
||||
|
||||
/*!
|
||||
* \brief Packs properties to array of doubles.
|
||||
* \param theValues [out] the values vector to populate.
|
||||
*/
|
||||
void ToValues(std::vector<double>& theValues) const;
|
||||
|
||||
/*!
|
||||
* \brief Unpacks properties from array of doubles.
|
||||
* \param theIt [in/out] the array index iterator.
|
||||
* \param theValues [in] the vector of values.
|
||||
*/
|
||||
void FromValues(int& theIt, const std::vector<double>& theValues);
|
||||
|
||||
/*!
|
||||
* \brief Overload comparsion.
|
||||
*/
|
||||
@ -252,6 +281,19 @@ public:
|
||||
*/
|
||||
void Update( Handle(AIS_AngleDimension)& theIO, const gp_Ax3& theLCS );
|
||||
|
||||
/*!
|
||||
* \brief Packs properties to array of doubles.
|
||||
* \param theValues [out] the values vector to populate.
|
||||
*/
|
||||
void ToValues(std::vector<double>& theValues) const;
|
||||
|
||||
/*!
|
||||
* \brief Unpacks properties from array of doubles.
|
||||
* \param theIt [in/out] the array index iterator.
|
||||
* \param theValues [in] the vector of values.
|
||||
*/
|
||||
void FromValues(int& theIt, const std::vector<double>& theValues);
|
||||
|
||||
/*!
|
||||
* \brief Overload comparsion.
|
||||
*/
|
||||
@ -286,6 +328,11 @@ public:
|
||||
*/
|
||||
GEOMGUI_DimensionProperty( SalomeApp_Study* theStudy, const std::string& theEntry );
|
||||
|
||||
/*!
|
||||
* \brief Constructor. Inits property from formatted QString.
|
||||
*/
|
||||
GEOMGUI_DimensionProperty( const QString& theProperty );
|
||||
|
||||
/*!
|
||||
* \brief Destructor.
|
||||
*/
|
||||
@ -294,7 +341,12 @@ public:
|
||||
/*!
|
||||
* \brief Overload QVariant cast operator.
|
||||
*/
|
||||
operator QVariant();
|
||||
operator QVariant() const;
|
||||
|
||||
/*!
|
||||
* \brief Overload QString cast operator.
|
||||
*/
|
||||
operator QString() const;
|
||||
|
||||
/*!
|
||||
* \brief Overload comparsion.
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "GEOMGUI_OCCSelector.h"
|
||||
#include "GEOMGUI_Selection.h"
|
||||
#include "GEOMGUI_CreationInfoWdg.h"
|
||||
#include "GEOMGUI_DimensionProperty.h"
|
||||
#include "GEOM_Constants.h"
|
||||
#include "GEOM_Displayer.h"
|
||||
#include "GEOM_AISShape.hxx"
|
||||
@ -87,6 +88,7 @@
|
||||
|
||||
// External includes
|
||||
#include <QDir>
|
||||
#include <QSet>
|
||||
#include <QMenu>
|
||||
#include <QTime>
|
||||
#include <QAction>
|
||||
@ -2727,6 +2729,7 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
savePoint);
|
||||
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
|
||||
|
||||
QSet<QString> anEntriesToStoreShared;
|
||||
QList<SUIT_ViewManager*> lst;
|
||||
QList<SUIT_ViewManager*>::Iterator it;
|
||||
|
||||
@ -2758,6 +2761,13 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
if (!obj->FindAttribute(anAttr, "AttributeIOR"))
|
||||
continue;
|
||||
|
||||
// remember entry of object to store shared GEOM properties
|
||||
// (e.g. dimension properties).
|
||||
if ( vType == OCCViewer_Viewer::Type() )
|
||||
{
|
||||
anEntriesToStoreShared.insert( o_it.key() );
|
||||
}
|
||||
|
||||
QString param, occParam = vType;
|
||||
occParam += GEOM::sectionSeparator();
|
||||
occParam += QString::number(aMgrId);
|
||||
@ -2843,6 +2853,26 @@ void GeometryGUI::storeVisualParameters (int savePoint)
|
||||
} // object iterator
|
||||
} // for (views)
|
||||
} // for (viewManagers)
|
||||
|
||||
// store dimension attributes of objects:
|
||||
// since the displayed object always persists in property map, we remember the object entries
|
||||
// on the passes when we store viewer related properties - to avoid extra iterations on GEOM component tree.
|
||||
QString aDimensionParam = OCCViewer_Viewer::Type() + GEOM::sectionSeparator() + GEOM::propertyName( GEOM::Dimensions );
|
||||
QSet<QString>::ConstIterator aEntryIt = anEntriesToStoreShared.constBegin();
|
||||
for ( ; aEntryIt != anEntriesToStoreShared.constEnd(); ++aEntryIt )
|
||||
{
|
||||
std::string aStudyEntry = (*aEntryIt).toLatin1().data();
|
||||
std::string aStoreEntry = ip->encodeEntry( aStudyEntry, componentName);
|
||||
|
||||
GEOMGUI_DimensionProperty aDimensions( appStudy, aStudyEntry );
|
||||
|
||||
if ( aDimensions.GetNumber() == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ip->setParameter( aStoreEntry, aDimensionParam.toStdString(), ((QString)aDimensions).toLatin1().data() );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2899,12 +2929,36 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
|
||||
|
||||
for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
|
||||
{
|
||||
// visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
|
||||
// visual parameters are stored in strings as follows:
|
||||
// 1) ViewerType_ViewIndex_ParamName
|
||||
// 2) ViewerType_ParamName (shared for GEOM module)
|
||||
// '_' is used as separator and should not be used in viewer type or parameter names.
|
||||
QStringList lst = QString((*namesIt).c_str()).split( GEOM::sectionSeparator(), QString::SkipEmptyParts);
|
||||
if (lst.size() != 3)
|
||||
continue;
|
||||
|
||||
bool isShared = lst.size() == 2;
|
||||
bool isViewer = lst.size() == 3;
|
||||
if ( !isShared && !isViewer )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// shared visual parameters
|
||||
if ( isShared )
|
||||
{
|
||||
QString aParamNameStr( lst[1] );
|
||||
QString aValuesStr( (*valuesIt).c_str() );
|
||||
|
||||
// shared dimension properties are stored as attribute
|
||||
if ( aParamNameStr == GEOM::propertyName( GEOM::Dimensions ) )
|
||||
{
|
||||
GEOMGUI_DimensionProperty aDimensionProp( aValuesStr );
|
||||
aDimensionProp.SaveToAttribute( appStudy, entry.toLatin1().data() );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// per view visual parameters
|
||||
viewerTypStr = lst[0];
|
||||
viewIndexStr = lst[1];
|
||||
QString paramNameStr = lst[2];
|
||||
|
@ -358,6 +358,11 @@ bool MeasureGUI_CreateDimensionDlg::ClickOnApply()
|
||||
{
|
||||
StopLocalEditing();
|
||||
|
||||
if ( myDimension.IsNull() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !AddDimensionToOwner() )
|
||||
{
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user