mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-24 11:30:34 +05:00
Improvement 0019703: deform (scale along axes) a shape.
This commit is contained in:
parent
a60b0da186
commit
d72b7ebbff
@ -7,13 +7,23 @@
|
||||
|
||||
\n This operation creates a scaled shape basing on the initial
|
||||
shape. For this, you need to define the \b Shape to be scaled, the
|
||||
<b>Central Point</b> of scale and the Scale Factor.
|
||||
<b>Central Point</b> of scale and the Scale Factor(s).
|
||||
\n The \b Result will be a \b GEOM_Object.
|
||||
\n <b>TUI Command:</b> <em>geompy.MakeScaleTransform(Shape, CenterOfScale, Factor)</em>
|
||||
\n <b>Arguments:</b> Name + 1 shape(s) + 1 vertex + 1 Scale Factor.
|
||||
\n <b>TUI Command:</b> <em>geompy.MakeScaleAlongAxes(Shape, CenterOfScale, FactorX, FactorY, FactorZ)</em>
|
||||
\n <b>Arguments:</b> Name + 1 shape(s) + 1 vertex + 3 Scale Factors.
|
||||
\n <b>Advanced option:</b>
|
||||
\ref restore_presentation_parameters_page "Set presentation parameters and subshapes from arguments".
|
||||
|
||||
\note If <b>Central Point</b> is not defined, the scaling will be
|
||||
performed relatively the origin of global coordinate system.
|
||||
|
||||
\note Scaling by a factor is a simple transformation, it does not modify
|
||||
geometry of the shape, while scaling by different factors along axes
|
||||
is a general transformation, which can modify geometry, for example, a
|
||||
circle can be transformed into an ellipse.
|
||||
|
||||
\image html transformation10.png
|
||||
|
||||
\n <b>Example:</b>
|
||||
@ -23,6 +33,6 @@ shape. For this, you need to define the \b Shape to be scaled, the
|
||||
\image html scale_transformsn2.png
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of the use of
|
||||
\ref tui_scale "Transformation Operations".
|
||||
\ref tui_scale "Scale Transformation" and of \ref swig_scale "Scale Along Axes Transformation"
|
||||
|
||||
*/
|
||||
|
@ -43,6 +43,12 @@
|
||||
\until MakeSewing
|
||||
|
||||
\anchor swig_all_trsf
|
||||
\until RotatPnt
|
||||
|
||||
\anchor swig_scale
|
||||
\until Scale4
|
||||
|
||||
\anchor swig_all_trsf_more
|
||||
\until MakeOffset
|
||||
|
||||
\anchor swig_ChangeOrientation
|
||||
|
@ -11,8 +11,8 @@
|
||||
// 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
|
||||
// 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
|
||||
@ -36,7 +36,7 @@ module GEOM
|
||||
* Topological types of shapes (like Open Cascade types)
|
||||
*/
|
||||
enum shape_type { COMPOUND, COMPSOLID, SOLID, SHELL,
|
||||
FACE, WIRE, EDGE, VERTEX, SHAPE };
|
||||
FACE, WIRE, EDGE, VERTEX, SHAPE };
|
||||
|
||||
|
||||
/*!
|
||||
@ -332,13 +332,13 @@ module GEOM
|
||||
*/
|
||||
GEOM_Object MakePointOnLinesIntersection (in GEOM_Object theRefLine1,
|
||||
in GEOM_Object theRefLine2);
|
||||
|
||||
|
||||
/*!
|
||||
* Create a vector, corresponding to tangent to the given parameter on the given curve.
|
||||
* \param theRefCurve The referenced curve.
|
||||
* \param theParameter Value of parameter on the referenced curve.This value should be have value
|
||||
* \between 0. and 1.. Value of 0. corresponds first parameter of curve value 1. corresponds
|
||||
* \last parameter of curve.
|
||||
* \last parameter of curve.
|
||||
* \return New GEOM_Object, containing the created point.
|
||||
*/
|
||||
GEOM_Object MakeTangentOnCurve (in GEOM_Object theRefCurve,
|
||||
@ -432,11 +432,11 @@ module GEOM
|
||||
GEOM_Object MakeMarker (in double theOX , in double theOY , in double theOZ,
|
||||
in double theXDX, in double theXDY, in double theXDZ,
|
||||
in double theYDX, in double theYDY, in double theYDZ);
|
||||
|
||||
|
||||
/*!
|
||||
* Create a tangent plane to specified face in the point with specified parameters.
|
||||
* Values of parameters should be between 0. and 1.0
|
||||
* \param theFace - face for which tangent plane shuold be built.
|
||||
* \param theFace - face for which tangent plane shuold be built.
|
||||
* \param theParameterU - value of parameter by U
|
||||
* \param theParameterV - value of parameter Vthe
|
||||
* \param theTrimSize - defines sizes of created face
|
||||
@ -735,6 +735,33 @@ module GEOM
|
||||
GEOM_Object ScaleShapeCopy (in GEOM_Object theObject, in GEOM_Object thePoint,
|
||||
in double theFactor);
|
||||
|
||||
/*!
|
||||
* Scale the given object by different factors along coordinate axes.
|
||||
* \param theObject The object to be scaled.
|
||||
* \param thePoint Center point for scaling.
|
||||
* \param theFactorX,theFactorY,theFactorZ Scaling factors along each axis.
|
||||
* \return theObject.
|
||||
*/
|
||||
GEOM_Object ScaleShapeAlongAxes (in GEOM_Object theObject,
|
||||
in GEOM_Object thePoint,
|
||||
in double theFactorX,
|
||||
in double theFactorY,
|
||||
in double theFactorZ);
|
||||
|
||||
/*!
|
||||
* Scale the given object by different factors along coordinate axes,
|
||||
* creating its copy before the scaling.
|
||||
* \param theObject The object to be scaled.
|
||||
* \param thePoint Center point for scaling.
|
||||
* \param theFactorX,theFactorY,theFactorZ Scaling factors along each axis.
|
||||
* \return New GEOM_Object, containing the scaled shape.
|
||||
*/
|
||||
GEOM_Object ScaleShapeAlongAxesCopy (in GEOM_Object theObject,
|
||||
in GEOM_Object thePoint,
|
||||
in double theFactorX,
|
||||
in double theFactorY,
|
||||
in double theFactorZ);
|
||||
|
||||
/*!
|
||||
* Modify the Location of the given object by LCS.
|
||||
* \param theObject The object to be displaced.
|
||||
@ -989,7 +1016,7 @@ module GEOM
|
||||
in GEOM_Object thePath,
|
||||
in boolean theWithContact ,
|
||||
in boolean theWithCorrection );
|
||||
|
||||
|
||||
/*!
|
||||
* Create a shape by extrusion of the profile shape along
|
||||
* the path shape. The path shape can be a shell or a face.
|
||||
@ -1323,7 +1350,7 @@ module GEOM
|
||||
in long theShapeType,
|
||||
in GEOM_Object theAx1,
|
||||
in shape_state theState);
|
||||
|
||||
|
||||
/*!
|
||||
* Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
|
||||
* the specified plane by the certain way, defined through \a theState parameter.
|
||||
@ -1331,7 +1358,7 @@ module GEOM
|
||||
* \param theShapeType Type of sub-shapes to be retrieved.
|
||||
* \param theAx1 Vector (or line, or linear edge), specifying normal
|
||||
* direction of the plane to find shapes on.
|
||||
* \param thePnt Point specifying location of the plane to find shapes on.
|
||||
* \param thePnt Point specifying location of the plane to find shapes on.
|
||||
* \param theState The state of the subshapes to find.
|
||||
* \return List of IDs of all found sub-shapes.
|
||||
*/
|
||||
@ -2128,7 +2155,7 @@ module GEOM
|
||||
GEOM_Object MakeChamferEdge (in GEOM_Object theShape,
|
||||
in double theD1, in double theD2,
|
||||
in long theFace1, in long theFace2);
|
||||
/*!
|
||||
/*!
|
||||
* The Same but with params theD = Chamfer Lenght
|
||||
* and theAngle = Chamfer Angle (Angle in radians)
|
||||
*/
|
||||
@ -2152,7 +2179,7 @@ module GEOM
|
||||
GEOM_Object MakeChamferFaces (in GEOM_Object theShape,
|
||||
in double theD1, in double theD2,
|
||||
in ListOfLong theFaces);
|
||||
/*!
|
||||
/*!
|
||||
* The Same but with params theD = Chamfer Lenght
|
||||
* and theAngle = Chamfer Angle (Angle in radians)
|
||||
*/
|
||||
@ -2171,7 +2198,7 @@ module GEOM
|
||||
GEOM_Object MakeChamferEdges (in GEOM_Object theShape,
|
||||
in double theD1, in double theD2,
|
||||
in ListOfLong theEdges);
|
||||
/*!
|
||||
/*!
|
||||
* The Same but with params theD = Chamfer Lenght
|
||||
* and theAngle = Chamfer Angle (Angle in radians)
|
||||
*/
|
||||
|
@ -309,6 +309,16 @@ module GEOM
|
||||
GEOM_Object ScaleShapeCopy (in GEOM_Object theObject,
|
||||
in GEOM_Object thePoint,
|
||||
in double theFactor) ;
|
||||
GEOM_Object ScaleShapeAlongAxes (in GEOM_Object theObject,
|
||||
in GEOM_Object thePoint,
|
||||
in double theFactorX,
|
||||
in double theFactorY,
|
||||
in double theFactorZ);
|
||||
GEOM_Object ScaleShapeAlongAxesCopy (in GEOM_Object theObject,
|
||||
in GEOM_Object thePoint,
|
||||
in double theFactorX,
|
||||
in double theFactorY,
|
||||
in double theFactorZ);
|
||||
GEOM_Object PositionShape (in GEOM_Object theObject,
|
||||
in GEOM_Object theStartLCS,
|
||||
in GEOM_Object theEndLCS) ;
|
||||
|
@ -127,6 +127,7 @@ revol.png \
|
||||
rotate.png \
|
||||
rotatepnt.png \
|
||||
scale.png \
|
||||
scale_along_axes.png \
|
||||
section.png \
|
||||
select1.png \
|
||||
sewing.png \
|
||||
|
BIN
resources/scale_along_axes.png
Normal file
BIN
resources/scale_along_axes.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 513 B |
@ -294,56 +294,57 @@ void BasicGUI_CurveDlg::SelectionIntoArgument()
|
||||
SALOME_ListIO selected;
|
||||
aSelMgr->selectedObjects( selected, QString::null, false );
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO anIt( selected ); anIt.More(); anIt.Next() )
|
||||
for (SALOME_ListIteratorOfListIO anIt (selected); anIt.More(); anIt.Next())
|
||||
{
|
||||
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
|
||||
|
||||
if (!CORBA::is_nil(aSelectedObject) && aRes)
|
||||
{
|
||||
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
|
||||
if (GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull())
|
||||
{
|
||||
aSelMgr->GetIndexes( anIt.Value(), aMapIndexes );
|
||||
|
||||
if ( !CORBA::is_nil( aSelectedObject ) && aRes )
|
||||
{
|
||||
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
|
||||
{
|
||||
aSelMgr->GetIndexes( anIt.Value(), aMapIndexes );
|
||||
if (aMapIndexes.Extent() > 0)
|
||||
{
|
||||
for (int ii=1; ii <= aMapIndexes.Extent(); ii++) {
|
||||
anIndex = aMapIndexes(ii);
|
||||
QString aName = GEOMBase::GetName( aSelectedObject );
|
||||
aName = aName + ":vertex_" + QString::number( anIndex );
|
||||
anObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
|
||||
//Find Object in study
|
||||
_PTR(SObject) obj ( aDStudy->FindObjectID( anIt.Value()->getEntry() ) );
|
||||
bool inStudy = false;
|
||||
_PTR(ChildIterator) iit (aDStudy->NewChildIterator(obj));
|
||||
for (; iit->More() && !inStudy; iit->Next()) {
|
||||
_PTR(SObject) child (iit->Value());
|
||||
QString aChildName = child->GetName();
|
||||
if (aChildName == aName) {
|
||||
inStudy = true;
|
||||
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(iit->Value());
|
||||
anObject = GEOM::GEOM_Object::_narrow( corbaObj );
|
||||
}
|
||||
}
|
||||
|
||||
if ( aMapIndexes.Extent() > 0 )
|
||||
{
|
||||
for (int ii=1; ii <= aMapIndexes.Extent(); ii++) {
|
||||
anIndex = aMapIndexes(ii);
|
||||
QString aName = GEOMBase::GetName( aSelectedObject );
|
||||
aName = aName + ":vertex_" + QString::number( anIndex );
|
||||
anObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
|
||||
//Find Object in study
|
||||
_PTR(SObject) obj ( aDStudy->FindObjectID( anIt.Value()->getEntry() ) );
|
||||
bool inStudy = false;
|
||||
for (_PTR(ChildIterator) iit (aDStudy->NewChildIterator(obj)); iit->More(); iit->Next()) {
|
||||
_PTR(SObject) child (iit->Value());
|
||||
QString aChildName = child->GetName();
|
||||
if (aChildName == aName) {
|
||||
inStudy = true;
|
||||
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(iit->Value());
|
||||
anObject = GEOM::GEOM_Object::_narrow( corbaObj );
|
||||
}
|
||||
}
|
||||
if (!inStudy)
|
||||
GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy),
|
||||
anObject, aName, aSelectedObject);
|
||||
|
||||
if (!inStudy)
|
||||
GeometryGUI::GetGeomGen()->AddInStudy(GeometryGUI::ClientStudyToStudy(aDStudy),
|
||||
anObject, aName, aSelectedObject);
|
||||
|
||||
int pos = isPointInList(myOrderedSel, anObject);
|
||||
if (pos==-1) {
|
||||
myOrderedSel.push_back(anObject);
|
||||
}
|
||||
// if (!inStudy)
|
||||
aList.push_back(anObject);
|
||||
}
|
||||
} else { // aMap.Extent() == 0
|
||||
int pos = isPointInList(myOrderedSel,aSelectedObject);
|
||||
if(pos==-1)
|
||||
myOrderedSel.push_back(aSelectedObject);
|
||||
aList.push_back(aSelectedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
int pos = isPointInList(myOrderedSel, anObject);
|
||||
if (pos==-1) {
|
||||
myOrderedSel.push_back(anObject);
|
||||
}
|
||||
// if (!inStudy)
|
||||
aList.push_back(anObject);
|
||||
}
|
||||
} else { // aMap.Extent() == 0
|
||||
int pos = isPointInList(myOrderedSel,aSelectedObject);
|
||||
if (pos==-1)
|
||||
myOrderedSel.push_back(aSelectedObject);
|
||||
aList.push_back(aSelectedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myPoints->length( aList.size() );
|
||||
|
||||
|
@ -331,6 +331,10 @@ msgstr "rotatepnt.png"
|
||||
msgid "ICON_DLG_SCALE"
|
||||
msgstr "scale.png"
|
||||
|
||||
#ScaleDlg
|
||||
msgid "ICON_DLG_SCALE_ALONG_AXES"
|
||||
msgstr "scale_along_axes.png"
|
||||
|
||||
#OffsetDlg
|
||||
msgid "ICON_DLG_OFFSET"
|
||||
msgstr "offset.png"
|
||||
|
@ -1280,6 +1280,15 @@ msgstr "Offset Surface"
|
||||
msgid "GEOM_SCALE_FACTOR"
|
||||
msgstr "Scale Factor :"
|
||||
|
||||
msgid "GEOM_SCALE_FACTOR_X"
|
||||
msgstr "Scale Factor X :"
|
||||
|
||||
msgid "GEOM_SCALE_FACTOR_Y"
|
||||
msgstr "Scale Factor Y :"
|
||||
|
||||
msgid "GEOM_SCALE_FACTOR_Z"
|
||||
msgstr "Scale Factor Z :"
|
||||
|
||||
#: GeometryGUI_SectionDlg.cxx:50
|
||||
msgid "GEOM_SECTION_TITLE"
|
||||
msgstr "BOOLEAN : Section Of Two Objects"
|
||||
|
@ -25,6 +25,8 @@
|
||||
#define SCALE_ARG_SHAPE 1
|
||||
#define SCALE_ARG_VALUE 2
|
||||
#define SCALE_ARG_POINT 3
|
||||
#define SCALE_ARG_VALUE_Y 4
|
||||
#define SCALE_ARG_VALUE_Z 5
|
||||
|
||||
class GEOMImpl_IScale
|
||||
{
|
||||
@ -44,6 +46,14 @@ class GEOMImpl_IScale
|
||||
|
||||
Handle(GEOM_Function) GetPoint() { return _func->GetReference(SCALE_ARG_POINT); }
|
||||
|
||||
void SetFactorX(double theValue) { _func->SetReal(SCALE_ARG_VALUE , theValue); }
|
||||
void SetFactorY(double theValue) { _func->SetReal(SCALE_ARG_VALUE_Y, theValue); }
|
||||
void SetFactorZ(double theValue) { _func->SetReal(SCALE_ARG_VALUE_Z, theValue); }
|
||||
|
||||
double GetFactorX() { return _func->GetReal(SCALE_ARG_VALUE ); }
|
||||
double GetFactorY() { return _func->GetReal(SCALE_ARG_VALUE_Y); }
|
||||
double GetFactorZ() { return _func->GetReal(SCALE_ARG_VALUE_Z); }
|
||||
|
||||
private:
|
||||
|
||||
Handle(GEOM_Function) _func;
|
||||
|
@ -1030,14 +1030,11 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
if (theObject.IsNull() || thePoint.IsNull()) return NULL;
|
||||
if (theObject.IsNull()) return NULL;
|
||||
|
||||
Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
|
||||
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
|
||||
|
||||
// Get last functions of the arguments
|
||||
Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
|
||||
|
||||
//Add a scale function
|
||||
Handle(GEOM_Function) aFunction =
|
||||
theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
|
||||
@ -1046,11 +1043,17 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
|
||||
|
||||
// Set arguments
|
||||
GEOMImpl_IScale aTI (aFunction);
|
||||
aTI.SetShape(anOriginal);
|
||||
aTI.SetPoint(aPF);
|
||||
aTI.SetFactor(theFactor);
|
||||
|
||||
// Set point argument
|
||||
if (!thePoint.IsNull()) {
|
||||
Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
|
||||
aTI.SetPoint(aPF);
|
||||
}
|
||||
|
||||
//Compute the scale
|
||||
try {
|
||||
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
||||
@ -1085,7 +1088,7 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
if (theObject.IsNull() || thePoint.IsNull()) return NULL;
|
||||
if (theObject.IsNull()) return NULL;
|
||||
|
||||
Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
|
||||
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
|
||||
@ -1101,11 +1104,17 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
|
||||
|
||||
// Set arguments
|
||||
GEOMImpl_IScale aTI (aFunction);
|
||||
aTI.SetShape(anOriginal);
|
||||
aTI.SetPoint(thePoint->GetLastFunction());
|
||||
aTI.SetFactor(theFactor);
|
||||
|
||||
// Set point argument
|
||||
if (!thePoint.IsNull()) {
|
||||
Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
|
||||
aTI.SetPoint(aPF);
|
||||
}
|
||||
|
||||
//Compute the scale
|
||||
try {
|
||||
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
||||
@ -1130,6 +1139,85 @@ Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
|
||||
return aCopy;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ScaleShapeAlongAxes
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint,
|
||||
double theFactorX,
|
||||
double theFactorY,
|
||||
double theFactorZ,
|
||||
bool doCopy)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
if (theObject.IsNull()) return NULL;
|
||||
|
||||
Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
|
||||
if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
|
||||
|
||||
//Add a scale function
|
||||
Handle(GEOM_Object) aCopy; //Add a new Copy object
|
||||
Handle(GEOM_Function) aFunction;
|
||||
if (doCopy) {
|
||||
aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
|
||||
aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
|
||||
}
|
||||
else {
|
||||
aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
|
||||
}
|
||||
if (aFunction.IsNull()) return NULL;
|
||||
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
|
||||
|
||||
// Set arguments
|
||||
GEOMImpl_IScale aTI (aFunction);
|
||||
aTI.SetShape(anOriginal);
|
||||
aTI.SetFactorX(theFactorX);
|
||||
aTI.SetFactorY(theFactorY);
|
||||
aTI.SetFactorZ(theFactorZ);
|
||||
|
||||
// Set point (optional argument)
|
||||
if (!thePoint.IsNull()) {
|
||||
Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
|
||||
aTI.SetPoint(aPF);
|
||||
}
|
||||
|
||||
//Compute the scale
|
||||
try {
|
||||
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
|
||||
OCC_CATCH_SIGNALS;
|
||||
#endif
|
||||
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||
SetErrorCode("Scale driver failed");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||
SetErrorCode(aFail->GetMessageString());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
|
||||
//Make a Python command
|
||||
if (doCopy) {
|
||||
GEOM::TPythonDump(aFunction) << "geompy.MakeScaleAlongAxes("
|
||||
<< theObject << ", " << thePoint << ", "
|
||||
<< theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
|
||||
return aCopy;
|
||||
}
|
||||
|
||||
GEOM::TPythonDump(aFunction) << "geompy.TrsfOp.ScaleShapeAlongAxes("
|
||||
<< theObject << ", " << thePoint << ", "
|
||||
<< theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
|
||||
return theObject;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* PositionShape
|
||||
|
@ -27,99 +27,125 @@
|
||||
#include "GEOM_Object.hxx"
|
||||
#include <TDocStd_Document.hxx>
|
||||
|
||||
class GEOMImpl_ITransformOperations : public GEOM_IOperations {
|
||||
class GEOMImpl_ITransformOperations : public GEOM_IOperations
|
||||
{
|
||||
public:
|
||||
Standard_EXPORT GEOMImpl_ITransformOperations(GEOM_Engine* theEngine, int theDocID);
|
||||
Standard_EXPORT ~GEOMImpl_ITransformOperations();
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateTwoPoints (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateTwoPointsCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateDXDYDZ (Handle(GEOM_Object) theObject, double theX, double theY, double theZ);
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateDXDYDZ (Handle(GEOM_Object) theObject,
|
||||
double theX, double theY, double theZ);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateDXDYDZCopy (Handle(GEOM_Object) theObject, double theX, double theY, double theZ);
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateDXDYDZCopy (Handle(GEOM_Object) theObject,
|
||||
double theX, double theY, double theZ);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateVector (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theVector);
|
||||
Handle(GEOM_Object) theVector);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateVectorCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theVector);
|
||||
Handle(GEOM_Object) theVector);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) TranslateVectorDistance (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theVector, double theDistance, bool theCopy);
|
||||
Handle(GEOM_Object) theVector,
|
||||
double theDistance,
|
||||
bool theCopy);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) Translate1D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theStep, Standard_Integer theNbTimes);
|
||||
Standard_EXPORT Handle(GEOM_Object) Translate1D (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theVector,
|
||||
double theStep,
|
||||
Standard_Integer theNbTimes);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) Translate2D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theStep1, Standard_Integer theNbTimes1,
|
||||
Handle(GEOM_Object) theVector2, double theStep2, Standard_Integer theNbTimes2);
|
||||
Standard_EXPORT Handle(GEOM_Object) Translate2D (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theVector,
|
||||
double theStep1,
|
||||
Standard_Integer theNbTimes1,
|
||||
Handle(GEOM_Object) theVector2,
|
||||
double theStep2,
|
||||
Standard_Integer theNbTimes2);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MirrorPlane (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePlane);
|
||||
Handle(GEOM_Object) thePlane);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MirrorPlaneCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePlane);
|
||||
Handle(GEOM_Object) thePlane);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MirrorAxis (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis);
|
||||
Handle(GEOM_Object) theAxis);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MirrorAxisCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis);
|
||||
Handle(GEOM_Object) theAxis);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MirrorPoint (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint);
|
||||
Handle(GEOM_Object) thePoint);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) MirrorPointCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint);
|
||||
Handle(GEOM_Object) thePoint);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) OffsetShape (Handle(GEOM_Object) theObject,
|
||||
double theOffset);
|
||||
double theOffset);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) OffsetShapeCopy (Handle(GEOM_Object) theObject,
|
||||
double theOffset);
|
||||
double theOffset);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) ScaleShape (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint,
|
||||
double theFactor);
|
||||
Handle(GEOM_Object) thePoint,
|
||||
double theFactor);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) ScaleShapeCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint,
|
||||
double theFactor);
|
||||
Handle(GEOM_Object) thePoint,
|
||||
double theFactor);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) thePoint,
|
||||
double theFactorX,
|
||||
double theFactorY,
|
||||
double theFactorZ,
|
||||
bool doCopy);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) PositionShape (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theStartLCS,
|
||||
Handle(GEOM_Object) theEndLCS);
|
||||
Handle(GEOM_Object) theStartLCS,
|
||||
Handle(GEOM_Object) theEndLCS);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) PositionShapeCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theStartLCS,
|
||||
Handle(GEOM_Object) theEndLCS);
|
||||
Handle(GEOM_Object) theStartLCS,
|
||||
Handle(GEOM_Object) theEndLCS);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) Rotate (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle);
|
||||
Standard_EXPORT Handle(GEOM_Object) Rotate (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis,
|
||||
double theAngle);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, double theAngle);
|
||||
Standard_EXPORT Handle(GEOM_Object) RotateCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis,
|
||||
double theAngle);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) Rotate1D (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, Standard_Integer theNbTimes);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) Rotate2D (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis,
|
||||
double theAngle,
|
||||
Standard_Integer theNbTimes1,
|
||||
double theStep,
|
||||
Standard_Integer theNbTimes2);
|
||||
Standard_EXPORT Handle(GEOM_Object) Rotate1D (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis,
|
||||
Standard_Integer theNbTimes);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) Rotate2D (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theAxis,
|
||||
double theAngle,
|
||||
Standard_Integer theNbTimes1,
|
||||
double theStep,
|
||||
Standard_Integer theNbTimes2);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) RotateThreePoints (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theCentPoint,
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
Handle(GEOM_Object) theCentPoint,
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) RotateThreePointsCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theCentPoint,
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
Standard_EXPORT Handle(GEOM_Object) RotateThreePointsCopy (Handle(GEOM_Object) theObject,
|
||||
Handle(GEOM_Object) theCentPoint,
|
||||
Handle(GEOM_Object) thePoint1,
|
||||
Handle(GEOM_Object) thePoint2);
|
||||
|
||||
};
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <GEOM_Function.hxx>
|
||||
|
||||
#include <BRepBuilderAPI_Transform.hxx>
|
||||
#include <BRepBuilderAPI_GTransform.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepAlgo.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
@ -37,6 +38,8 @@
|
||||
|
||||
#include <Precision.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <gp_GTrsf.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
@ -73,11 +76,17 @@ Standard_Integer GEOMImpl_ScaleDriver::Execute(TFunction_Logbook& log) const
|
||||
|
||||
if (aType == SCALE_SHAPE || aType == SCALE_SHAPE_COPY) {
|
||||
Handle(GEOM_Function) aRefShape = aCI.GetShape();
|
||||
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
|
||||
TopoDS_Shape aShapeBase = aRefShape->GetValue();
|
||||
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
|
||||
if (aShapeBase.IsNull() || aShapePnt.IsNull()) return 0;
|
||||
if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0;
|
||||
if (aShapeBase.IsNull()) return 0;
|
||||
|
||||
gp_Pnt aP (0,0,0);
|
||||
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
|
||||
if (!aRefPoint.IsNull()) {
|
||||
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
|
||||
if (aShapePnt.IsNull()) return 0;
|
||||
if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0;
|
||||
aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
|
||||
}
|
||||
|
||||
// Bug 6839: Check for standalone (not included in faces) degenerated edges
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
|
||||
@ -94,12 +103,67 @@ Standard_Integer GEOMImpl_ScaleDriver::Execute(TFunction_Logbook& log) const
|
||||
}
|
||||
|
||||
// Perform Scaling
|
||||
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
|
||||
gp_Trsf aTrsf;
|
||||
aTrsf.SetScale(aP, aCI.GetFactor());
|
||||
BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False);
|
||||
aShape = aBRepTrsf.Shape();
|
||||
} else {
|
||||
}
|
||||
else if (aType == SCALE_SHAPE_AXES || aType == SCALE_SHAPE_AXES_COPY) {
|
||||
Handle(GEOM_Function) aRefShape = aCI.GetShape();
|
||||
TopoDS_Shape aShapeBase = aRefShape->GetValue();
|
||||
if (aShapeBase.IsNull()) return 0;
|
||||
|
||||
bool isP = false;
|
||||
gp_Pnt aP (0,0,0);
|
||||
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
|
||||
if (!aRefPoint.IsNull()) {
|
||||
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
|
||||
if (aShapePnt.IsNull()) return 0;
|
||||
if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0;
|
||||
aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
|
||||
isP = true;
|
||||
}
|
||||
|
||||
// Bug 6839: Check for standalone (not included in faces) degenerated edges
|
||||
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
|
||||
TopExp::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, aEFMap);
|
||||
Standard_Integer i, nbE = aEFMap.Extent();
|
||||
for (i = 1; i <= nbE; i++) {
|
||||
TopoDS_Shape anEdgeSh = aEFMap.FindKey(i);
|
||||
if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeSh))) {
|
||||
const TopTools_ListOfShape& aFaces = aEFMap.FindFromIndex(i);
|
||||
if (aFaces.IsEmpty())
|
||||
Standard_ConstructionError::Raise
|
||||
("Scaling aborted : cannot scale standalone degenerated edge");
|
||||
}
|
||||
}
|
||||
|
||||
// Perform Scaling
|
||||
gp_GTrsf aGTrsf;
|
||||
gp_Mat rot (aCI.GetFactorX(), 0, 0,
|
||||
0, aCI.GetFactorY(), 0,
|
||||
0, 0, aCI.GetFactorZ());
|
||||
aGTrsf.SetVectorialPart(rot);
|
||||
|
||||
if (isP) {
|
||||
gp_Pnt anO (0,0,0);
|
||||
if (anO.Distance(aP) > Precision::Confusion()) {
|
||||
gp_GTrsf aGTrsfP0;
|
||||
aGTrsfP0.SetTranslationPart(anO.XYZ() - aP.XYZ());
|
||||
gp_GTrsf aGTrsf0P;
|
||||
aGTrsf0P.SetTranslationPart(aP.XYZ());
|
||||
//aGTrsf = aGTrsf0P * aGTrsf * aGTrsfP0;
|
||||
aGTrsf = aGTrsf0P.Multiplied(aGTrsf);
|
||||
aGTrsf = aGTrsf.Multiplied(aGTrsfP0);
|
||||
}
|
||||
}
|
||||
|
||||
BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
|
||||
if (!aBRepGTrsf.IsDone())
|
||||
Standard_ConstructionError::Raise("Scaling not done");
|
||||
aShape = aBRepGTrsf.Shape();
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
if (aShape.IsNull()) return 0;
|
||||
|
@ -144,6 +144,8 @@
|
||||
|
||||
#define SCALE_SHAPE 1
|
||||
#define SCALE_SHAPE_COPY 2
|
||||
#define SCALE_SHAPE_AXES 3
|
||||
#define SCALE_SHAPE_AXES_COPY 4
|
||||
|
||||
#define POSITION_SHAPE 1
|
||||
#define POSITION_SHAPE_COPY 2
|
||||
|
@ -310,9 +310,9 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
GetOperations()->SetNotDone(); //Set a not done flag
|
||||
|
||||
|
||||
if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
|
||||
|
||||
|
||||
//check if the object is a subshape
|
||||
if (!theCopy && !theObject->IsMainShape()) {
|
||||
GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
|
||||
@ -728,14 +728,14 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
|
||||
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
|
||||
(GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactor)
|
||||
CORBA::Double theFactor)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
|
||||
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
|
||||
if (theObject->_is_nil()) return aGEOMObject._retn();
|
||||
|
||||
//check if the object is a subshape
|
||||
if (!theObject->IsMainShape()) {
|
||||
@ -750,10 +750,12 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
|
||||
if (anObject.IsNull()) return aGEOMObject._retn();
|
||||
|
||||
//Get the point
|
||||
CORBA::String_var aPntEntry = thePoint->GetEntry();
|
||||
Handle(GEOM_Object) aPoint =
|
||||
GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), aPntEntry);
|
||||
if (aPoint.IsNull()) return aGEOMObject._retn();
|
||||
Handle(GEOM_Object) aPoint;
|
||||
if (!thePoint->_is_nil()) {
|
||||
CORBA::String_var aPntEntry = thePoint->GetEntry();
|
||||
aPoint = GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), aPntEntry);
|
||||
if (aPoint.IsNull()) return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//Perform the scale
|
||||
GetOperations()->ScaleShape(anObject, aPoint, theFactor);
|
||||
@ -769,14 +771,14 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
|
||||
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
|
||||
(GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactor)
|
||||
CORBA::Double theFactor)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
|
||||
if (theObject->_is_nil()) return aGEOMObject._retn();
|
||||
|
||||
//Get the basic object
|
||||
CORBA::String_var anEntry = theObject->GetEntry();
|
||||
@ -785,10 +787,12 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
|
||||
if (aBasicObject.IsNull()) return aGEOMObject._retn();
|
||||
|
||||
//Get the point
|
||||
CORBA::String_var aPntEntry = thePoint->GetEntry();
|
||||
Handle(GEOM_Object) aPoint =
|
||||
GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), aPntEntry);
|
||||
if (aPoint.IsNull()) return aGEOMObject._retn();
|
||||
Handle(GEOM_Object) aPoint;
|
||||
if (!thePoint->_is_nil()) {
|
||||
CORBA::String_var aPntEntry = thePoint->GetEntry();
|
||||
aPoint = GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), aPntEntry);
|
||||
if (aPoint.IsNull()) return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//Perform the scale
|
||||
Handle(GEOM_Object) anObject =
|
||||
@ -799,6 +803,94 @@ GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ScaleShapeAlongAxes
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxes
|
||||
(GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
|
||||
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
if (theObject->_is_nil()) return aGEOMObject._retn();
|
||||
|
||||
//check if the object is a subshape
|
||||
if (!theObject->IsMainShape()) {
|
||||
GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//Get the object itself
|
||||
CORBA::String_var anEntry = theObject->GetEntry();
|
||||
Handle(GEOM_Object) anObject =
|
||||
GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), anEntry);
|
||||
if (anObject.IsNull()) return aGEOMObject._retn();
|
||||
|
||||
//Get the point
|
||||
Handle(GEOM_Object) aPoint;
|
||||
if (!thePoint->_is_nil()) {
|
||||
CORBA::String_var aPntEntry = thePoint->GetEntry();
|
||||
aPoint = GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), aPntEntry);
|
||||
if (aPoint.IsNull()) return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//Perform the scale
|
||||
GetOperations()->ScaleShapeAlongAxes
|
||||
(anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
|
||||
|
||||
return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ScaleShapeAlongAxesCopy
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeAlongAxesCopy
|
||||
(GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
|
||||
//Set a not done flag
|
||||
GetOperations()->SetNotDone();
|
||||
|
||||
if (theObject->_is_nil()) return aGEOMObject._retn();
|
||||
|
||||
//Get the basic object
|
||||
CORBA::String_var anEntry = theObject->GetEntry();
|
||||
Handle(GEOM_Object) aBasicObject =
|
||||
GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), anEntry);
|
||||
if (aBasicObject.IsNull()) return aGEOMObject._retn();
|
||||
|
||||
//Get the point
|
||||
Handle(GEOM_Object) aPoint;
|
||||
if (!thePoint->_is_nil()) {
|
||||
CORBA::String_var aPntEntry = thePoint->GetEntry();
|
||||
aPoint = GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), aPntEntry);
|
||||
if (aPoint.IsNull()) return aGEOMObject._retn();
|
||||
}
|
||||
|
||||
//Perform the scale
|
||||
Handle(GEOM_Object) anObject = GetOperations()->ScaleShapeAlongAxes
|
||||
(aBasicObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/true);
|
||||
if (!GetOperations()->IsDone() || anObject.IsNull())
|
||||
return aGEOMObject._retn();
|
||||
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* PositionShape
|
||||
|
@ -121,6 +121,18 @@ class GEOM_I_EXPORT GEOM_ITransformOperations_i :
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactor);
|
||||
|
||||
GEOM::GEOM_Object_ptr ScaleShapeAlongAxes (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ);
|
||||
|
||||
GEOM::GEOM_Object_ptr ScaleShapeAlongAxesCopy (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ);
|
||||
|
||||
GEOM::GEOM_Object_ptr PositionShape (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr theStartLCS,
|
||||
GEOM::GEOM_Object_ptr theEndLCS);
|
||||
|
@ -1634,6 +1634,42 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeCopy (GEOM::GEOM_Object_ptr theOb
|
||||
return anObj;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// ScaleShapeAlongAxes:
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeAlongAxes (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ)
|
||||
{
|
||||
beginService( " GEOM_Superv_i::ScaleShapeAlongAxes" );
|
||||
MESSAGE("GEOM_Superv_i::ScaleShapeAlongAxes");
|
||||
getTransfOp();
|
||||
GEOM::GEOM_Object_ptr anObj = myTransfOp->ScaleShapeAlongAxes
|
||||
(theObject, thePoint, theFactorX, theFactorY, theFactorZ);
|
||||
endService( " GEOM_Superv_i::ScaleShapeAlongAxes" );
|
||||
return anObj;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// ScaleShapeAlongAxesCopy:
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_Superv_i::ScaleShapeAlongAxesCopy (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ)
|
||||
{
|
||||
beginService( " GEOM_Superv_i::ScaleShapeAlongAxesCopy" );
|
||||
MESSAGE("GEOM_Superv_i::ScaleShapeAlongAxesCopy");
|
||||
getTransfOp();
|
||||
GEOM::GEOM_Object_ptr anObj = myTransfOp->ScaleShapeAlongAxesCopy
|
||||
(theObject, thePoint, theFactorX, theFactorY, theFactorZ);
|
||||
endService( " GEOM_Superv_i::ScaleShapeAlongAxesCopy" );
|
||||
return anObj;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
// PositionShape:
|
||||
//=============================================================================
|
||||
|
@ -377,6 +377,16 @@ public:
|
||||
GEOM::GEOM_Object_ptr ScaleShapeCopy (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactor);
|
||||
GEOM::GEOM_Object_ptr ScaleShapeAlongAxes (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ);
|
||||
GEOM::GEOM_Object_ptr ScaleShapeAlongAxesCopy (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
CORBA::Double theFactorX,
|
||||
CORBA::Double theFactorY,
|
||||
CORBA::Double theFactorZ);
|
||||
GEOM::GEOM_Object_ptr PositionShape (GEOM::GEOM_Object_ptr theObject,
|
||||
GEOM::GEOM_Object_ptr theStartLCS,
|
||||
GEOM::GEOM_Object_ptr theEndLCS);
|
||||
|
@ -184,12 +184,21 @@ def TestAll (geompy, math):
|
||||
TranslVectD = geompy.MakeTranslationVectorDistance(Box, vxyz, 50.0) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
|
||||
Rotation = geompy.MakeRotation(Box, vz, angle1) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
|
||||
RotatPnt = geompy.MakeRotationThreePoints(Box, px, py, pz) #(4 GEOM_Object_ptr)->GEOM_Object_ptr
|
||||
Scale = geompy.MakeScaleTransform(Box, p0, factor) #
|
||||
Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
|
||||
MirrorAxis = geompy.MakeMirrorByAxis(Box, Line1) #
|
||||
MirrorPnt = geompy.MakeMirrorByPoint(Box, p200) #
|
||||
Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
|
||||
Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
|
||||
|
||||
#Scale by factor relatively given point
|
||||
Scale1 = geompy.MakeScaleTransform(Box, pxyz, factor) #(2 GEOM_Object_ptr, Double)->GEOM_Object_ptr
|
||||
#Scale by factor relatively the origin of global CS
|
||||
Scale2 = geompy.MakeScaleTransform(Box, None, factor) #
|
||||
#Scale along axes of global CS by different factors. Scale relatively given point
|
||||
Scale3 = geompy.MakeScaleAlongAxes(Box, pxyz, 1.5, 0.5, 3) #(2 GEOM_Object_ptr, 3 Doubles)->GEOM_Object_ptr
|
||||
#Scale along axes of global CS by different factors. Scale relatively the origin of global CS
|
||||
Scale4 = geompy.MakeScaleAlongAxes(Box, None, 1.5, 0.5, 3) #
|
||||
|
||||
Mirror = geompy.MakeMirrorByPlane(Box, Plane) #(2 GEOM_Object_ptr)->GEOM_Object_ptr
|
||||
MirrorAxis = geompy.MakeMirrorByAxis(Box, Line1) #
|
||||
MirrorPnt = geompy.MakeMirrorByPoint(Box, p200) #
|
||||
Position = geompy.MakePosition(Box, cs1, cs2) #(3 GEOM_Object_ptr)->GEOM_Object_ptr
|
||||
Offset = geompy.MakeOffset(Box, 10.) #(GEOM_Object_ptr, Double)->GEOM_Object_ptr
|
||||
Orientation = geompy.ChangeOrientation(Box)
|
||||
|
||||
#IDList for Fillet/Chamfer
|
||||
@ -338,7 +347,10 @@ def TestAll (geompy, math):
|
||||
id_TranslVectD = geompy.addToStudy(TranslVectD, "Translation along vector with defined distance")
|
||||
id_Rotation = geompy.addToStudy(Rotation, "Rotation")
|
||||
id_RotatPnt = geompy.addToStudy(RotatPnt, "Rotation by three points")
|
||||
id_Scale = geompy.addToStudy(Scale, "Scale")
|
||||
id_Scale1 = geompy.addToStudy(Scale1, "Scale1")
|
||||
id_Scale2 = geompy.addToStudy(Scale2, "Scale2")
|
||||
id_Scale3 = geompy.addToStudy(Scale3, "Scale3")
|
||||
id_Scale4 = geompy.addToStudy(Scale4, "Scale4")
|
||||
id_Mirror = geompy.addToStudy(Mirror, "Mirror by Plane")
|
||||
id_MirrorAxis = geompy.addToStudy(MirrorAxis, "Mirror by Axis")
|
||||
id_MirrorPnt = geompy.addToStudy(MirrorPnt, "Mirror by Point")
|
||||
|
@ -217,8 +217,6 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
|
||||
## Publish sub-shapes, standing for arguments and sub-shapes of arguments
|
||||
# To be used from python scripts out of geompy.addToStudy (non-default usage)
|
||||
# \param theStudy the study, in which theObject is published already,
|
||||
# and in which the arguments will be published
|
||||
# \param theObject published GEOM object, arguments of which will be published
|
||||
# \param theArgs list of GEOM_Object, operation arguments to be published.
|
||||
# If this list is empty, all operation arguments will be published
|
||||
@ -1683,9 +1681,8 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
RaiseIfFailed("DivideEdge", self.HealOp)
|
||||
return anObj
|
||||
|
||||
## Change orientation of the given object.
|
||||
## Change orientation of the given object. Updates given shape.
|
||||
# @param theObject Shape to be processed.
|
||||
# @update given shape
|
||||
#
|
||||
# @ref swig_todo "Example"
|
||||
def ChangeOrientationShell(self,theObject):
|
||||
@ -2008,16 +2005,33 @@ class geompyDC(GEOM._objref_GEOM_Gen):
|
||||
## Scale the given object by the factor, creating its copy before the scaling.
|
||||
# @param theObject The object to be scaled.
|
||||
# @param thePoint Center point for scaling.
|
||||
# Passing None for it means scaling relatively the origin of global CS.
|
||||
# @param theFactor Scaling factor value.
|
||||
# @return New GEOM_Object, containing the scaled shape.
|
||||
#
|
||||
# @ref tui_scale "Example"
|
||||
def MakeScaleTransform(self,theObject, thePoint, theFactor):
|
||||
def MakeScaleTransform(self, theObject, thePoint, theFactor):
|
||||
# Example: see GEOM_TestAll.py
|
||||
anObj = self.TrsfOp.ScaleShapeCopy(theObject, thePoint, theFactor)
|
||||
RaiseIfFailed("ScaleShapeCopy", self.TrsfOp)
|
||||
return anObj
|
||||
|
||||
## Scale the given object by different factors along coordinate axes,
|
||||
# creating its copy before the scaling.
|
||||
# @param theObject The object to be scaled.
|
||||
# @param thePoint Center point for scaling.
|
||||
# Passing None for it means scaling relatively the origin of global CS.
|
||||
# @param theFactorX,theFactorY,theFactorZ Scaling factors along each axis.
|
||||
# @return New GEOM_Object, containing the scaled shape.
|
||||
#
|
||||
# @ref swig_scale "Example"
|
||||
def MakeScaleAlongAxes(self, theObject, thePoint, theFactorX, theFactorY, theFactorZ):
|
||||
# Example: see GEOM_TestAll.py
|
||||
anObj = self.TrsfOp.ScaleShapeAlongAxesCopy(theObject, thePoint,
|
||||
theFactorX, theFactorY, theFactorZ)
|
||||
RaiseIfFailed("MakeScaleAlongAxes", self.TrsfOp)
|
||||
return anObj
|
||||
|
||||
## Create an object, symmetrical
|
||||
# to the given one relatively the given plane.
|
||||
# @param theObject The object to be mirrored.
|
||||
|
@ -10,13 +10,13 @@
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//
|
||||
@ -39,6 +39,8 @@
|
||||
#include <TColStd_IndexedMapOfInteger.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
|
||||
#include "DlgRef_SpinBox.h"
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qcheckbox.h>
|
||||
|
||||
@ -55,74 +57,174 @@ using namespace std;
|
||||
// The dialog will by default be modeless, unless you set 'modal' to
|
||||
// TRUE to construct a modal dialog.
|
||||
//=================================================================================
|
||||
TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
|
||||
const char* name, bool modal, WFlags fl)
|
||||
:GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
|
||||
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
|
||||
TransformationGUI_ScaleDlg::TransformationGUI_ScaleDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
|
||||
const char* name, bool modal, WFlags fl)
|
||||
: GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
|
||||
WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
|
||||
{
|
||||
QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_SCALE")));
|
||||
QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
|
||||
SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
|
||||
QPixmap image1 (aResMgr->loadPixmap("GEOM",tr("ICON_DLG_SCALE")));
|
||||
QPixmap image2 (aResMgr->loadPixmap("GEOM",tr("ICON_DLG_SCALE_ALONG_AXES")));
|
||||
QPixmap image3 (aResMgr->loadPixmap("GEOM",tr("ICON_SELECT")));
|
||||
|
||||
setCaption(tr("GEOM_SCALE_TITLE"));
|
||||
|
||||
/***************************************************************/
|
||||
// Constructors
|
||||
GroupConstructors->setTitle(tr("GEOM_SCALE"));
|
||||
RadioButton1->setPixmap(image0);
|
||||
RadioButton2->close(TRUE);
|
||||
RadioButton1->setPixmap(image1);
|
||||
RadioButton2->setPixmap(image2);
|
||||
RadioButton3->close(TRUE);
|
||||
|
||||
GroupPoints = new DlgRef_2Sel1Spin2Check(this, "GroupPoints");
|
||||
GroupPoints->CheckButton2->hide();
|
||||
GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
|
||||
GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS"));
|
||||
GroupPoints->TextLabel2->setText(tr("GEOM_CENTRAL_POINT"));
|
||||
GroupPoints->TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
|
||||
GroupPoints->LineEdit1->setReadOnly( true );
|
||||
GroupPoints->LineEdit2->setReadOnly( true );
|
||||
GroupPoints->PushButton1->setPixmap(image1);
|
||||
GroupPoints->PushButton2->setPixmap(image1);
|
||||
GroupPoints->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
|
||||
// Own widgets
|
||||
GroupBox1 = new QGroupBox (this, "GroupBox1");
|
||||
GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
|
||||
GroupBox1->setColumnLayout(0, Qt::Vertical);
|
||||
GroupBox1->layout()->setSpacing(6);
|
||||
GroupBox1->layout()->setMargin(11);
|
||||
|
||||
// san -- modification of an exisitng object by offset is not allowed
|
||||
GroupPoints->CheckButton1->hide();
|
||||
TextLabel1 = new QLabel (GroupBox1, "TextLabel1");
|
||||
TextLabel1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, TextLabel1->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
Layout1->addWidget(GroupPoints, 2, 0);
|
||||
/***************************************************************/
|
||||
TextLabel2 = new QLabel (GroupBox1, "TextLabel2");
|
||||
TextLabel2->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, TextLabel2->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
PushButton1 = new QPushButton(GroupBox1, "PushButton1");
|
||||
PushButton1->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, PushButton1->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
PushButton2 = new QPushButton( GroupBox1, "PushButton2" );
|
||||
PushButton2->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, PushButton2->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
LineEdit1 = new QLineEdit (GroupBox1, "LineEdit1");
|
||||
LineEdit2 = new QLineEdit (GroupBox1, "LineEdit2");
|
||||
|
||||
TextLabel3 = new QLabel (GroupBox1, "TextLabel3");
|
||||
TextLabel3->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, TextLabel3->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
TextLabel4 = new QLabel (GroupBox1, "TextLabel4");
|
||||
TextLabel4->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, TextLabel3->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
TextLabel5 = new QLabel (GroupBox1, "TextLabel5");
|
||||
TextLabel5->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0,
|
||||
0, 0, TextLabel3->sizePolicy().hasHeightForWidth()));
|
||||
|
||||
SpinBox_FX = new DlgRef_SpinBox(GroupBox1, "SpinBox_FX");
|
||||
SpinBox_FY = new DlgRef_SpinBox(GroupBox1, "SpinBox_FY");
|
||||
SpinBox_FZ = new DlgRef_SpinBox(GroupBox1, "SpinBox_FZ");
|
||||
|
||||
CheckBoxCopy = new QCheckBox (GroupBox1, "CheckBoxCopy");
|
||||
|
||||
QSpacerItem* spacer = new QSpacerItem(0, 316, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
|
||||
// Layouting
|
||||
OwnLayout = new QGridLayout (0, 1, 1, 0, 6, "Layout1");
|
||||
|
||||
OwnLayout->addWidget(TextLabel1, 0, 0);
|
||||
OwnLayout->addWidget(TextLabel2, 1, 0);
|
||||
|
||||
OwnLayout->addWidget(PushButton1, 0, 1);
|
||||
OwnLayout->addWidget(PushButton2, 1, 1);
|
||||
|
||||
OwnLayout->addMultiCellWidget(LineEdit1, 0, 0, 2, 3);
|
||||
OwnLayout->addMultiCellWidget(LineEdit2, 1, 1, 2, 3);
|
||||
|
||||
OwnLayout->addWidget(TextLabel3, 2, 0);
|
||||
OwnLayout->addWidget(TextLabel4, 3, 0);
|
||||
OwnLayout->addWidget(TextLabel5, 4, 0);
|
||||
|
||||
OwnLayout->addWidget(SpinBox_FX, 2, 2);
|
||||
OwnLayout->addWidget(SpinBox_FY, 3, 2);
|
||||
OwnLayout->addWidget(SpinBox_FZ, 4, 2);
|
||||
|
||||
OwnLayout->addMultiCellWidget(CheckBoxCopy, 5, 5, 0, 3);
|
||||
|
||||
OwnLayout->addItem(spacer, 6, 2);
|
||||
|
||||
GroupBox1Layout = new QGridLayout (GroupBox1->layout());
|
||||
GroupBox1Layout->setAlignment(Qt::AlignTop);
|
||||
GroupBox1Layout->addLayout(OwnLayout, 0, 0);
|
||||
|
||||
Layout1->addWidget(GroupBox1, 2, 0);
|
||||
|
||||
// Text and pictures for own widgets
|
||||
TextLabel1->setText(tr("GEOM_OBJECTS"));
|
||||
TextLabel2->setText(tr("GEOM_CENTRAL_POINT"));
|
||||
|
||||
PushButton1->setPixmap(image3);
|
||||
PushButton2->setPixmap(image3);
|
||||
|
||||
LineEdit1->setReadOnly( true );
|
||||
LineEdit2->setReadOnly( true );
|
||||
|
||||
TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
|
||||
TextLabel4->setText(tr("GEOM_SCALE_FACTOR_Y"));
|
||||
TextLabel5->setText(tr("GEOM_SCALE_FACTOR_Z"));
|
||||
|
||||
// Min, max, step and decimals for spin boxes & initial values
|
||||
double aFactor = 2.0;
|
||||
double SpecificStep = 0.5;
|
||||
/* min, max, step and decimals for spin boxes & initial values */
|
||||
GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
|
||||
GroupPoints->SpinBox_DX->SetValue(aFactor);
|
||||
SpinBox_FX->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
|
||||
SpinBox_FY->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
|
||||
SpinBox_FZ->RangeStepAndValidator(COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
|
||||
SpinBox_FX->SetValue(aFactor);
|
||||
SpinBox_FY->SetValue(aFactor);
|
||||
SpinBox_FZ->SetValue(aFactor);
|
||||
|
||||
// Tab order
|
||||
setTabOrder(PushButton1, LineEdit1);
|
||||
setTabOrder(LineEdit1, PushButton2);
|
||||
setTabOrder(PushButton2, LineEdit2);
|
||||
setTabOrder(LineEdit2 , SpinBox_FX);
|
||||
setTabOrder(SpinBox_FX, SpinBox_FY);
|
||||
setTabOrder(SpinBox_FY, SpinBox_FZ);
|
||||
setTabOrder(SpinBox_FZ, CheckBoxCopy);
|
||||
setTabOrder(CheckBoxCopy, CheckBoxRestoreSS);
|
||||
|
||||
// Modification of an existing object by offset is not allowed
|
||||
CheckBoxCopy->hide();
|
||||
|
||||
// Activate Create a Copy mode
|
||||
GroupPoints->CheckButton1->setChecked(true);
|
||||
CheckBoxCopy->setText(tr("GEOM_CREATE_COPY"));
|
||||
CheckBoxCopy->setChecked(true);
|
||||
CreateCopyModeChanged(true);
|
||||
|
||||
// Allowed inheritance of children and visual properties by the scaling result
|
||||
GroupBoxPublish->show();
|
||||
|
||||
/* signals and slots connections */
|
||||
// Signals and slots connections
|
||||
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
|
||||
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
|
||||
connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
|
||||
|
||||
connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||
connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||
connect(PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||
connect(PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
|
||||
|
||||
connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
||||
connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
||||
connect(LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
||||
connect(LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
|
||||
|
||||
connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
|
||||
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
|
||||
connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
|
||||
connect(SpinBox_FX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
|
||||
connect(SpinBox_FY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
|
||||
connect(SpinBox_FZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
|
||||
|
||||
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), SpinBox_FX, SLOT(SetStep(double)));
|
||||
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), SpinBox_FY, SLOT(SetStep(double)));
|
||||
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), SpinBox_FZ, SLOT(SetStep(double)));
|
||||
|
||||
connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
|
||||
|
||||
connect(myGeomGUI->getApp()->selectionMgr(),
|
||||
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
|
||||
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ;
|
||||
|
||||
setHelpFileName("scale_operation_page.html");
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ~TransformationGUI_ScaleDlg()
|
||||
// purpose : Destroys the object and frees any allocated resources
|
||||
@ -132,21 +234,57 @@ TransformationGUI_ScaleDlg::~TransformationGUI_ScaleDlg()
|
||||
/* no need to delete child widgets, Qt does it all for us */
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : Init()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::Init()
|
||||
{
|
||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
GroupPoints->LineEdit2->clear();
|
||||
myEditCurrentArgument = LineEdit1;
|
||||
LineEdit2->clear();
|
||||
|
||||
myPoint = GEOM::GEOM_Object::_nil();
|
||||
|
||||
initName( tr( "GEOM_SCALE" ) );
|
||||
initName(tr("GEOM_SCALE"));
|
||||
|
||||
ConstructorsClicked(0);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ConstructorsClicked()
|
||||
// purpose : Radio button management
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::ConstructorsClicked(int constructorId)
|
||||
{
|
||||
erasePreview();
|
||||
|
||||
switch (constructorId)
|
||||
{
|
||||
case 0: /* translation an object by dx, dy, dz */
|
||||
TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
|
||||
TextLabel4->hide();
|
||||
TextLabel5->hide();
|
||||
SpinBox_FY->hide();
|
||||
SpinBox_FZ->hide();
|
||||
resize(0,0);
|
||||
break;
|
||||
case 1: /* translation an object by 2 points */
|
||||
TextLabel3->setText(tr("GEOM_SCALE_FACTOR_X"));
|
||||
TextLabel4->show();
|
||||
TextLabel5->show();
|
||||
SpinBox_FY->show();
|
||||
SpinBox_FZ->show();
|
||||
resize(0,0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//qApp->processEvents();
|
||||
//updateGeometry();
|
||||
//resize(minimumSize());
|
||||
displayPreview();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnOk()
|
||||
@ -154,100 +292,98 @@ void TransformationGUI_ScaleDlg::Init()
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::ClickOnOk()
|
||||
{
|
||||
if ( ClickOnApply() )
|
||||
if (ClickOnApply())
|
||||
ClickOnCancel();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnApply()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_ScaleDlg::ClickOnApply()
|
||||
{
|
||||
if ( !onAccept(GroupPoints->CheckButton1->isChecked()) )
|
||||
if (!onAccept(CheckBoxCopy->isChecked()))
|
||||
return false;
|
||||
|
||||
Init();
|
||||
//Init();
|
||||
initName(tr("GEOM_SCALE"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : SelectionIntoArgument()
|
||||
// purpose : Called when selection as changed or other case
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::SelectionIntoArgument()
|
||||
{
|
||||
erasePreview();
|
||||
myEditCurrentArgument->setText("");
|
||||
QString aName;
|
||||
|
||||
if(myEditCurrentArgument == GroupPoints->LineEdit1)
|
||||
if (myEditCurrentArgument == LineEdit1)
|
||||
{
|
||||
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aName);
|
||||
if (aNbSel < 1)
|
||||
{
|
||||
int aNbSel = GEOMBase::GetNameOfSelectedIObjects(selectedIO(), aName);
|
||||
if(aNbSel < 1)
|
||||
{
|
||||
myObjects.length(0);
|
||||
return;
|
||||
}
|
||||
GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myObjects);
|
||||
if (!myObjects.length())
|
||||
return;
|
||||
myObjects.length(0);
|
||||
return;
|
||||
}
|
||||
else if(myEditCurrentArgument == GroupPoints->LineEdit2)
|
||||
GEOMBase::ConvertListOfIOInListOfGO(selectedIO(), myObjects);
|
||||
if (!myObjects.length())
|
||||
return;
|
||||
}
|
||||
else if (myEditCurrentArgument == LineEdit2)
|
||||
{
|
||||
GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();
|
||||
if (IObjectCount() == 1)
|
||||
{
|
||||
if(IObjectCount() != 1)
|
||||
{
|
||||
myPoint = GEOM::GEOM_Object::_nil();
|
||||
return;
|
||||
}
|
||||
Standard_Boolean testResult = Standard_False;
|
||||
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult );
|
||||
aName = GEOMBase::GetName( aSelectedObject );
|
||||
aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult);
|
||||
if (testResult)
|
||||
{
|
||||
aName = GEOMBase::GetName(aSelectedObject);
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
|
||||
{
|
||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
TColStd_IndexedMapOfInteger aMap;
|
||||
aSelMgr->GetIndexes( firstIObject(), aMap );
|
||||
if ( aMap.Extent() == 1 )
|
||||
{
|
||||
int anIndex = aMap( 1 );
|
||||
aName += QString(":vertex_%1").arg(anIndex);
|
||||
TopoDS_Shape aShape;
|
||||
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
|
||||
{
|
||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
TColStd_IndexedMapOfInteger aMap;
|
||||
aSelMgr->GetIndexes(firstIObject(), aMap);
|
||||
if (aMap.Extent() == 1)
|
||||
{
|
||||
int anIndex = aMap( 1 );
|
||||
aName += QString(":vertex_%1").arg(anIndex);
|
||||
|
||||
//Find SubShape Object in Father
|
||||
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
|
||||
|
||||
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp =
|
||||
getGeomEngine()->GetIShapesOperations( getStudyId() );
|
||||
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
|
||||
aSelMgr->clearSelected();
|
||||
}
|
||||
else
|
||||
aSelectedObject = aFindedObject; // get Object from study
|
||||
}
|
||||
else {
|
||||
if (aShape.ShapeType() != TopAbs_VERTEX) {
|
||||
aSelectedObject = GEOM::GEOM_Object::_nil();
|
||||
aName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myPoint = aSelectedObject;
|
||||
|
||||
if(!testResult || CORBA::is_nil( myPoint ))
|
||||
return;
|
||||
//Find SubShape Object in Father
|
||||
GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
|
||||
|
||||
if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
|
||||
GEOM::GEOM_IShapesOperations_var aShapesOp =
|
||||
getGeomEngine()->GetIShapesOperations( getStudyId() );
|
||||
aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
|
||||
aSelMgr->clearSelected();
|
||||
}
|
||||
else
|
||||
aSelectedObject = aFindedObject; // get Object from study
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aShape.ShapeType() != TopAbs_VERTEX) {
|
||||
aSelectedObject = GEOM::GEOM_Object::_nil();
|
||||
aName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myEditCurrentArgument->setText( aName );
|
||||
|
||||
myPoint = aSelectedObject;
|
||||
}
|
||||
|
||||
myEditCurrentArgument->setText(aName);
|
||||
displayPreview();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : LineEditReturnPressed()
|
||||
// purpose :
|
||||
@ -255,15 +391,13 @@ void TransformationGUI_ScaleDlg::SelectionIntoArgument()
|
||||
void TransformationGUI_ScaleDlg::LineEditReturnPressed()
|
||||
{
|
||||
QLineEdit* send = (QLineEdit*)sender();
|
||||
if(send == GroupPoints->LineEdit1 ||
|
||||
send == GroupPoints->LineEdit2)
|
||||
{
|
||||
myEditCurrentArgument = send;
|
||||
GEOMBase_Skeleton::LineEditReturnPressed();
|
||||
}
|
||||
if (send == LineEdit1 || send == LineEdit2)
|
||||
{
|
||||
myEditCurrentArgument = send;
|
||||
GEOMBase_Skeleton::LineEditReturnPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : SetEditCurrentArgument()
|
||||
// purpose :
|
||||
@ -273,19 +407,18 @@ void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
|
||||
QPushButton* send = (QPushButton*)sender();
|
||||
globalSelection();
|
||||
|
||||
if(send == GroupPoints->PushButton1) {
|
||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
if (send == PushButton1) {
|
||||
myEditCurrentArgument = LineEdit1;
|
||||
}
|
||||
else if(send == GroupPoints->PushButton2) {
|
||||
myEditCurrentArgument = GroupPoints->LineEdit2;
|
||||
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
|
||||
else if (send == PushButton2) {
|
||||
myEditCurrentArgument = LineEdit2;
|
||||
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
|
||||
}
|
||||
|
||||
myEditCurrentArgument->setFocus();
|
||||
SelectionIntoArgument();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ActivateThisDialog()
|
||||
// purpose :
|
||||
@ -293,25 +426,26 @@ void TransformationGUI_ScaleDlg::SetEditCurrentArgument()
|
||||
void TransformationGUI_ScaleDlg::ActivateThisDialog()
|
||||
{
|
||||
GEOMBase_Skeleton::ActivateThisDialog();
|
||||
connect(myGeomGUI->getApp()->selectionMgr(),
|
||||
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
|
||||
globalSelection();
|
||||
GroupPoints->LineEdit1->setFocus();
|
||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
}
|
||||
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
|
||||
this, SLOT(SelectionIntoArgument()));
|
||||
|
||||
globalSelection();
|
||||
myEditCurrentArgument->setFocus();
|
||||
if (myEditCurrentArgument == LineEdit2) {
|
||||
localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : enterEvent()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::enterEvent(QEvent* e)
|
||||
void TransformationGUI_ScaleDlg::enterEvent (QEvent* e)
|
||||
{
|
||||
if( !GroupConstructors->isEnabled() )
|
||||
if (!GroupConstructors->isEnabled())
|
||||
ActivateThisDialog();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ValueChangedInSpinBox()
|
||||
// purpose :
|
||||
@ -321,54 +455,101 @@ void TransformationGUI_ScaleDlg::ValueChangedInSpinBox()
|
||||
displayPreview();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : createOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation()
|
||||
GEOM::GEOM_IOperations_ptr TransformationGUI_ScaleDlg::createOperation()
|
||||
{
|
||||
return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
|
||||
return myGeomGUI->GetGeomGen()->GetITransformOperations(getStudyId());
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : isValid
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_ScaleDlg::isValid( QString& msg )
|
||||
bool TransformationGUI_ScaleDlg::isValid (QString& msg)
|
||||
{
|
||||
return !(myObjects.length() == 0 || myPoint->_is_nil() || fabs(GetFactor()) <= 0.00001);
|
||||
if (myObjects.length() > 0 && fabs(SpinBox_FX->GetValue()) > 0.00001)
|
||||
{
|
||||
// && !myPoint->_is_nil()
|
||||
if (getConstructorId() == 0)
|
||||
return true;
|
||||
if (fabs(SpinBox_FY->GetValue()) > 0.00001 &&
|
||||
fabs(SpinBox_FZ->GetValue()) > 0.00001)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : execute
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool TransformationGUI_ScaleDlg::execute( ObjectList& objects )
|
||||
bool TransformationGUI_ScaleDlg::execute (ObjectList& objects)
|
||||
{
|
||||
bool res = false;
|
||||
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
|
||||
|
||||
GEOM::GEOM_Object_var anObj;
|
||||
|
||||
if (GroupPoints->CheckButton1->isChecked() || IsPreview())
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
switch (getConstructorId())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (toCreateCopy)
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
|
||||
ScaleShapeCopy( myObjects[i], myPoint, GetFactor() );
|
||||
if ( !anObj->_is_nil() )
|
||||
objects.push_back( anObj._retn() );
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
|
||||
ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->GetValue());
|
||||
if (!anObj->_is_nil())
|
||||
objects.push_back(anObj._retn());
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
else
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
|
||||
ScaleShape( myObjects[i], myPoint, GetFactor() );
|
||||
if ( !anObj->_is_nil() )
|
||||
objects.push_back( anObj._retn() );
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
|
||||
ScaleShape(myObjects[i], myPoint, SpinBox_FX->GetValue());
|
||||
if (!anObj->_is_nil())
|
||||
objects.push_back(anObj._retn());
|
||||
}
|
||||
}
|
||||
res = true;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
if (toCreateCopy)
|
||||
{
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
|
||||
ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->GetValue(),
|
||||
SpinBox_FY->GetValue(), SpinBox_FZ->GetValue());
|
||||
if (!anObj->_is_nil())
|
||||
objects.push_back(anObj._retn());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < myObjects.length(); i++)
|
||||
{
|
||||
anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
|
||||
ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->GetValue(),
|
||||
SpinBox_FY->GetValue(), SpinBox_FZ->GetValue());
|
||||
if (!anObj->_is_nil())
|
||||
objects.push_back(anObj._retn());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
res = true;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -387,37 +568,29 @@ void TransformationGUI_ScaleDlg::restoreSubShapes (SALOMEDS::Study_ptr theStud
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GetFactor()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
double TransformationGUI_ScaleDlg::GetFactor() const
|
||||
{
|
||||
return GroupPoints->SpinBox_DX->GetValue();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : CreateCopyModeChanged()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::CreateCopyModeChanged(bool isCreateCopy)
|
||||
void TransformationGUI_ScaleDlg::CreateCopyModeChanged (bool isCreateCopy)
|
||||
{
|
||||
this->GroupBoxName->setEnabled(isCreateCopy);
|
||||
GroupBoxName->setEnabled(isCreateCopy);
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : addSubshapeToStudy
|
||||
// function : addSubshapesToStudy
|
||||
// purpose : virtual method to add new SubObjects if local selection
|
||||
//=================================================================================
|
||||
void TransformationGUI_ScaleDlg::addSubshapesToStudy()
|
||||
{
|
||||
bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
|
||||
if (toCreateCopy) {
|
||||
QMap<QString, GEOM::GEOM_Object_var> objMap;
|
||||
|
||||
objMap[GroupPoints->LineEdit2->text()] = myPoint;
|
||||
|
||||
addSubshapesToFather( objMap );
|
||||
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
|
||||
if (toCreateCopy)
|
||||
{
|
||||
if (!myPoint->_is_nil())
|
||||
{
|
||||
QMap<QString, GEOM::GEOM_Object_var> objMap;
|
||||
objMap[LineEdit2->text()] = myPoint;
|
||||
addSubshapesToFather(objMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@
|
||||
// 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
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//
|
||||
@ -29,8 +29,14 @@
|
||||
#define DIALOGBOX_SCALE_H
|
||||
|
||||
#include "GEOMBase_Skeleton.h"
|
||||
#include "DlgRef_2Sel1Spin2Check.h"
|
||||
|
||||
class QGridLayout;
|
||||
class QCheckBox;
|
||||
class QGroupBox;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class DlgRef_SpinBox;
|
||||
|
||||
//=================================================================================
|
||||
// class : TransformationGUI_ScaleDlg
|
||||
@ -42,26 +48,47 @@ class TransformationGUI_ScaleDlg : public GEOMBase_Skeleton
|
||||
|
||||
public:
|
||||
TransformationGUI_ScaleDlg(GeometryGUI* theGeometryGUI, QWidget* parent = 0,
|
||||
const char* name = 0, bool modal = FALSE, WFlags fl = 0);
|
||||
const char* name = 0, bool modal = FALSE, WFlags fl = 0);
|
||||
~TransformationGUI_ScaleDlg();
|
||||
|
||||
protected:
|
||||
// redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
virtual bool isValid( QString& );
|
||||
virtual bool execute( ObjectList& objects );
|
||||
virtual bool isValid (QString&);
|
||||
virtual bool execute (ObjectList& objects);
|
||||
virtual void addSubshapesToStudy();
|
||||
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
|
||||
|
||||
private :
|
||||
void Init();
|
||||
void enterEvent(QEvent* e);
|
||||
double GetFactor() const;
|
||||
void enterEvent (QEvent* e);
|
||||
|
||||
GEOM::ListOfGO myObjects;
|
||||
GEOM::GEOM_Object_var myPoint; /* Central Point */
|
||||
|
||||
DlgRef_2Sel1Spin2Check* GroupPoints;
|
||||
QGroupBox* GroupBox1;
|
||||
|
||||
QLabel* TextLabel1;
|
||||
QLabel* TextLabel2;
|
||||
|
||||
QPushButton* PushButton1;
|
||||
QPushButton* PushButton2;
|
||||
|
||||
QLineEdit* LineEdit1;
|
||||
QLineEdit* LineEdit2;
|
||||
|
||||
QLabel* TextLabel3;
|
||||
QLabel* TextLabel4;
|
||||
QLabel* TextLabel5;
|
||||
|
||||
DlgRef_SpinBox* SpinBox_FX;
|
||||
DlgRef_SpinBox* SpinBox_FY;
|
||||
DlgRef_SpinBox* SpinBox_FZ;
|
||||
|
||||
QCheckBox* CheckBoxCopy;
|
||||
|
||||
QGridLayout* GroupBox1Layout;
|
||||
QGridLayout* OwnLayout;
|
||||
|
||||
private slots:
|
||||
void ClickOnOk();
|
||||
@ -70,8 +97,9 @@ private slots:
|
||||
void LineEditReturnPressed();
|
||||
void SelectionIntoArgument();
|
||||
void SetEditCurrentArgument();
|
||||
void ConstructorsClicked (int constructorId);
|
||||
void ValueChangedInSpinBox();
|
||||
void CreateCopyModeChanged(bool isCreateCopy);
|
||||
void CreateCopyModeChanged (bool isCreateCopy);
|
||||
};
|
||||
|
||||
#endif // DIALOGBOX_SCALE_H
|
||||
|
Loading…
Reference in New Issue
Block a user