EDF 1337 : Sketch 3D, allow definition of a point by angle

+ Added a global coordinate system mode for angles.
+ Added a cylindrical coordinates definition (with an optional height in angle widget)
+ Did some refactoring

Doc and translations to be done soon
This commit is contained in:
rnc 2012-10-08 10:16:55 +00:00
parent 72423aa832
commit f1f709067a
10 changed files with 855 additions and 431 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,12 +28,15 @@
class QButtonGroup;
class QDoubleSpinBox;
class EntityGUI_3Spin;
class EntityGUI_Type;
class EntityGUI_Angles;
class EntityGUI_Controls;
class DlgRef_3Radio;
class SOCC_Prs;
class gp_Dir;
#include <AIS_ListOfInteractive.hxx>
#include <AIS_AngleDimension.hxx>
#include <AIS_LengthDimension.hxx>
#ifndef COORD_MIN
# define COORD_MIN -1e+15
@ -52,11 +55,20 @@ class EntityGUI_3DSketcherDlg : public GEOMBase_Skeleton
struct XYZ
{
XYZ() { x = y = z = 0.0; command = params = ""; }
XYZ() { x = y = z = 0.0; command = params = ""; L=A=0; }
double x, y, z; // for preview only
int L, A; // for preview only
QString command;
QString params;
};
struct prsType
{
prsType(){L=A=0;}
int L;
int A;
};
typedef QList<XYZ> XYZList;
public:
@ -82,10 +94,30 @@ private:
const int = -1,
const int = -1);
Handle(AIS_LengthDimension) createAISLengthDimension(double theLength,
gp_Pnt P1,
gp_Pnt P2,
gp_Dir theNormal);
Handle(AIS_AngleDimension) createAISAngleDimension(double theAngle,
gp_Pnt P0,
gp_Pnt P1,
gp_Pnt P2);
void displayAngle(double theAngle,
gp_Pnt P0,
gp_Pnt P1,
gp_Pnt P2,
bool store = false);
void displayLength(gp_Pnt P1,
gp_Pnt P2,
gp_Dir theNormal,
bool store = false);
void displayTrihedron( int );
void displayAngle( double, double, double, int, bool store = false );
void displayLength( double theLength = -1.0, bool store = false, int type = 1);
void displayDimensions(bool store = false);
bool createShapes( GEOM::GEOM_Object_ptr,
TopoDS_Shape&,
@ -95,27 +127,29 @@ private:
XYZ getPenultimatePoint() const;
XYZ getCurrentPoint() const;
gp_Dir getPresentationPlane() const;
std::string doubleToString( double );
void removeLastIOFromPrs( int );
void restoreLastIOToPrs( int );
void removeLastIOFromPrs();
void restoreLastIOToPrs();
private:
XYZList myPointsList;
XYZList myRedoList;
AIS_ListOfInteractive myLengthIORedoList;
AIS_ListOfInteractive myAngleIORedoList;
int myPrsType;
std::list<int> myPrsTypeList;
std::list<int> myPrsTypeRedoList;
prsType myPrsType;
EntityGUI_3Spin* Group3Spin;
EntityGUI_Angles* GroupAngles;
EntityGUI_Controls* GroupControls;
DlgRef_3Radio* GroupType;
QButtonGroup* myTypeGroup;
EntityGUI_Type* GroupType;
QButtonGroup* myTypeGroup1;
QButtonGroup* myTypeGroup2;
int myMode;
int myCoordType;
int myOrientation;
bool myOK;
bool isLengthVisible;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>351</width>
<height>148</height>
<width>488</width>
<height>172</height>
</rect>
</property>
<property name="windowTitle">
@ -42,10 +42,10 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="1" colspan="2">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DL"/>
</item>
<item row="0" column="2">
<item row="0" column="3">
<widget class="QPushButton" name="buttonApply">
<property name="text">
<string>Create</string>
@ -68,10 +68,10 @@
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="1" colspan="2">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DA"/>
</item>
<item row="1" column="2">
<item row="1" column="3">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
@ -95,7 +95,27 @@
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DA2"/>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DH"/>
</item>
<item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radioButton_1">
@ -120,16 +140,6 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DA2"/>
</item>
</layout>
</widget>
</item>

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EntityGUI_Type_QTD</class>
<widget class="QWidget" name="EntityGUI_Type_QTD">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>315</width>
<height>92</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="GroupType1">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="RadioButton1">
<property name="text">
<string>RadioButton1</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="RadioButton2">
<property name="text">
<string>RadioButton2</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="GroupType2">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="RadioButton3">
<property name="text">
<string>RadioButton3</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="RadioButton4">
<property name="text">
<string>RadioButton4</string>
</property>
<property name="autoExclusive">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<tabstops>
<tabstop>RadioButton1</tabstop>
<tabstop>RadioButton2</tabstop>
<tabstop>RadioButton3</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -210,6 +210,20 @@ EntityGUI_Point::~EntityGUI_Point()
{
}
//////////////////////////////////////////
// EntityGUI_Type
//////////////////////////////////////////
EntityGUI_Type::EntityGUI_Type( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
EntityGUI_Type::~EntityGUI_Type()
{
}
//////////////////////////////////////////
// EntityGUI_Angles
//////////////////////////////////////////

View File

@ -222,6 +222,22 @@ public:
QButtonGroup* ButtonGroup;
};
//////////////////////////////////////////
// EntityGUI_Type
//////////////////////////////////////////
#include "ui_EntityGUI_Type_QTD.h"
class EntityGUI_Type : public QWidget,
public Ui::EntityGUI_Type_QTD
{
Q_OBJECT
public:
EntityGUI_Type( QWidget* = 0, Qt::WindowFlags = 0 );
~EntityGUI_Type();
};
//////////////////////////////////////////
// EntityGUI_Angles
//////////////////////////////////////////

View File

@ -85,6 +85,7 @@ UIC_FILES = \
ui_EntityGUI_Dir2_QTD.h \
ui_EntityGUI_Point_QTD.h \
ui_EntityGUI_Skeleton_QTD.h \
ui_EntityGUI_Type_QTD.h \
ui_EntityGUI_Angles_QTD.h \
ui_EntityGUI_Controls_QTD.h

View File

@ -1101,9 +1101,18 @@ bool ProcessFunction(Handle(GEOM_Function)& theFunction,
else if (aCMDpref == "WW") {
aNewDescr += "sk.close()";
}
else {
aNewDescr += "sk.addPointAnglesLength(\"";
aNewDescr += aCMDpref + "\", " +
else if (aCMDpref.Value(1) == 'O'){
TCollection_AsciiString aCMDtrunc = aStrVals.Value(1);
aCMDtrunc.Trunc(3);
if (aCMDpref.Value(4) == 'C')
aNewDescr += "sk.addPointAngleHRad";
else
aNewDescr += "sk.addPointAnglesRad";
if (aCMDpref.Value(5) == 'A')
aNewDescr += "Absolute(\"";
else
aNewDescr += "Relative(\"";
aNewDescr += aCMDtrunc + "\", " +
aStrVals.Value(2) + ", " + aStrVals.Value(3) + ", " + aStrVals.Value(4) + ")";
}
}

View File

@ -39,6 +39,8 @@
#include <Standard_ConstructionError.hxx>
#include <utilities.h>
//=======================================================================
//function : GetID
//purpose :
@ -214,9 +216,19 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
if (aStrVals.Length() != 4)
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
char type = aStrVals.Value(1).Value(4);
char mode = aStrVals.Value(1).Value(5);
double anAngle = aStrVals.Value(2).RealValue() * M_PI/180.0;
double anAngle2 = aStrVals.Value(3).RealValue() * M_PI/180.0;
double anAngle2 = aStrVals.Value(3).RealValue() * M_PI/180.0;
double aLength = aStrVals.Value(4).RealValue();
double aHeight = aLength * sin(anAngle2);
if (type == 'C')
{
aHeight = aStrVals.Value(3).RealValue();
anAngle2 = 0.0;
}
double aProjectedLength = aLength * cos(anAngle2);
@ -224,21 +236,28 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
vp.SetX(aStrVals.Value(2).RealValue());
vp.SetY(aStrVals.Value(3).RealValue());
vp.SetZ(aStrVals.Value(4).RealValue());
if (aStrVals.Value(1) == "OXY") {
vp.SetX(p.X() + aProjectedLength * cos(anAngle));
vp.SetY(p.Y() + aProjectedLength * sin(anAngle));
vp.SetZ(p.Z() + aLength * sin(anAngle2));
gp_XYZ pref = gp::Origin().XYZ();
if(mode == 'R')
pref = p;
TCollection_AsciiString aTruncatedCommand = aStrVals.Value(1);
aTruncatedCommand.Trunc(3);
if (aTruncatedCommand == "OXY") {
vp.SetX(pref.X() + aProjectedLength * cos(anAngle));
vp.SetY(pref.Y() + aProjectedLength * sin(anAngle));
vp.SetZ(pref.Z() + aHeight);
}
else if (aStrVals.Value(1) == "OYZ") {
vp.SetX(p.X() + aLength * sin(anAngle2));
vp.SetY(p.Y() + aProjectedLength * cos(anAngle));
vp.SetZ(p.Z() + aProjectedLength * sin(anAngle));
else if (aTruncatedCommand == "OYZ") {
vp.SetX(pref.X() + aHeight);
vp.SetY(pref.Y() + aProjectedLength * cos(anAngle));
vp.SetZ(pref.Z() + aProjectedLength * sin(anAngle));
}
else if (aStrVals.Value(1) == "OXZ") {
vp.SetX(p.X() + aProjectedLength * cos(anAngle));
vp.SetY(p.Y() + aLength * sin(anAngle2));
vp.SetZ(p.Z() + aProjectedLength * sin(anAngle));
else if (aTruncatedCommand == "OXZ") {
vp.SetX(pref.X() + aProjectedLength * cos(anAngle));
vp.SetY(pref.Y() + aHeight);
vp.SetZ(pref.Z() + aProjectedLength * sin(anAngle));
}
else
Standard_ConstructionError::Raise("3D Sketcher error: Bad format of command.");
@ -295,7 +314,7 @@ Standard_Integer GEOMImpl_3DSketcherDriver::Execute(TFunction_Logbook& log) cons
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);

View File

@ -121,11 +121,14 @@ class Sketcher3D:
## Add one straight segment, defined by two angles and length.
# If the first point of sketcher is not yet defined, the
# origin (0, 0, 0) will become the first sketcher point.
# The radius and angles coordinates are defined
# in a local coordinate system which origin is the last point of the sketch
#
# @param axes can be: "OXY", "OYZ" or "OXZ"
# @param angle1 angle in a plane, defined by the \a axes
# @param angle2 angle from the plane, defined by the \a axes
# @param length length of the segment
def addPointAnglesLength (self, axes, angle1, angle2, length):
def addPointAnglesRadRelative (self, axes, angle1, angle2, length):
"""
Add one straight segment, defined by two angles and length.
If the first point of sketcher is not yet defined, the
@ -139,10 +142,100 @@ class Sketcher3D:
Example of usage:
sk = geompy.Sketcher3D()
sk.addPointAnglesLength("OXY", 50, 0, 100)
sk.addPointAnglesRadRelative("OXY", 50, 0, 100)
a3D_Sketcher_1 = sk.wire()
"""
self.myCommand = self.myCommand + ":%s %s %s %s" % (axes, printVar(angle1), printVar(angle2), printVar(length))
self.myCommand = self.myCommand + ":%s"%axes+"SR"+" %s %s %s" % (printVar(angle1), printVar(angle2), printVar(length))
pass
## Add one straight segment, defined by two angles and radius.
# If the first point of sketcher is not yet defined, the
# origin (0, 0, 0) will become the first sketcher point.
# The radius and angles coordinates are defined
# in a coordinate system which origin is the global coordinate system origin
#
# @param axes can be: "OXY", "OYZ" or "OXZ"
# @param angle1 angle in a plane, defined by the \a axes
# @param angle2 angle from the plane, defined by the \a axes
# @param radius distance to the coordinate system origin
def addPointAnglesRadAbsolute (self, axes, angle1, angle2, radius):
"""
Add one straight segment, defined by two angles and length.
If the first point of sketcher is not yet defined, the
origin (0, 0, 0) will become the first sketcher point.
Parameters:
axes can be: "OXY", "OYZ" or "OXZ"
angle1 angle in a plane, defined by the \a axes
angle2 angle from the plane, defined by the \a axes
radius distance to the coordinate system origin
Example of usage:
sk = geompy.Sketcher3D()
sk.addPointAnglesRadAbsolute("OXY", 50, 0, 100)
a3D_Sketcher_1 = sk.wire()
"""
self.myCommand = self.myCommand + ":%s"%axes+"SA"+" %s %s %s" % (printVar(angle1), printVar(angle2), printVar(radius))
pass
## Add one straight segment, defined by an angle, a height and a radius.
# If the first point of sketcher is not yet defined, the
# origin (0, 0, 0) will become the first sketcher point.
# The radius height and angle coordinates are defined
# in a local coordinate system which origin is the last point of the sketch
#
# @param axes can be: "OXY", "OYZ" or "OXZ"
# @param angle angle in a plane, defined by the \a axes
# @param height height from the plane, defined by the \a axes
# @param radius distance to the coordinate system origin
def addPointAngleHRadRelative (self, axes, angle, height, length):
"""
Add one straight segment, defined by two angles and length.
If the first point of sketcher is not yet defined, the
origin (0, 0, 0) will become the first sketcher point.
Parameters:
axes can be: "OXY", "OYZ" or "OXZ"
angle1 angle in a plane, defined by the \a axes
height height from the plane, defined by the \a axes
radius distance to the coordinate system origin
Example of usage:
sk = geompy.Sketcher3D()
sk.addPointAngleHRadRelative("OXY", 50, 40, 100)
a3D_Sketcher_1 = sk.wire()
"""
self.myCommand = self.myCommand + ":%s"%axes+"CR"+" %s %s %s" % (printVar(angle), printVar(height), printVar(length))
pass
## Add one straight segment, defined by an angle, a height and a radius.
# If the first point of sketcher is not yet defined, the
# origin (0, 0, 0) will become the first sketcher point.
# The radius height and angle coordinates are defined
# in a coordinate system which origin is the global coordinate system origin
#
# @param axes can be: "OXY", "OYZ" or "OXZ"
# @param angle angle in a plane, defined by the \a axes
# @param height height from the plane, defined by the \a axes
# @param radius distance to the coordinate system origin
def addPointAngleHRadAbsolute (self, axes, angle, height, radius):
"""
Add one straight segment, defined by two angles and length.
If the first point of sketcher is not yet defined, the
origin (0, 0, 0) will become the first sketcher point.
Parameters:
axes can be: "OXY", "OYZ" or "OXZ"
angle1 angle in a plane, defined by the \a axes
height height from the plane, defined by the \a axes
radius distance to the coordinate system origin
Example of usage:
sk = geompy.Sketcher3D()
sk.addPointAngleHRadAbsolute("OXY", 50, 40, 100)
a3D_Sketcher_1 = sk.wire()
"""
self.myCommand = self.myCommand + ":%s"%axes+"CA"+" %s %s %s" % (printVar(angle), printVar(height), printVar(radius))
pass
## Set to close the wire