Added 2 new operations:

- Extruded cut, allows to add material an existing shape by extrusion of a profile
- Extruded boss, allows to remove material from an existing shape by extrusion od a profile

Modified the sketcher dialog in order to use MakeSketcherOnPLane API instead of MakeSketcher. It is now possible to make a skecth directly on the face of a shape without creating a local coordinate system.

Code refactoring in the sketcher dialog
This commit is contained in:
rnc 2012-03-01 14:35:25 +00:00
parent 6175043630
commit cb32f89e64
30 changed files with 1451 additions and 308 deletions

View File

@ -1311,6 +1311,23 @@ module GEOM
in double theDX, in double theDY, in double theDZ, in double theDX, in double theDY, in double theDZ,
in double theScaleFactor); in double theScaleFactor);
/*!
* \brief Add / Remove material to / from a solid by extrusion of the base shape on the given distance.
* \param theInitShape Initial shape on which to perform the feature.It has to be a solid or
* a compound made of a single solid
* \param theBase Edge or wire defining the base shape to be extruded.
* \param theHeight Prism dimension along the normal of the face.
* \param theAngle Draft angel in degrees
* \param theFuse If true material is added else material is removed
* \return New GEOM_Object, containing the modified shape
*/
GEOM_Object MakeDraftPrism (in GEOM_Object theInitShape,
in GEOM_Object theBase,
in double theHeight,
in double theAngle,
in boolean theFuse);
/*! /*!
* \brief Create a shape by extrusion of the base shape along * \brief Create a shape by extrusion of the base shape along
* the path shape. The path shape can be a wire or an edge. * the path shape. The path shape can be a wire or an edge.

View File

@ -78,8 +78,11 @@ disk_r.png \
display.png \ display.png \
displayonly.png \ displayonly.png \
displayall.png \ displayall.png \
draft.png \
erase.png \ erase.png \
eraseall.png \ eraseall.png \
extruded_boss.png \
extruded_cut.png \
face_hw.png \ face_hw.png \
face_vechw.png \ face_vechw.png \
feature_detect.png \ feature_detect.png \

BIN
resources/draft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

BIN
resources/extruded_boss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

BIN
resources/extruded_cut.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 778 B

View File

@ -428,6 +428,20 @@ DlgRef_2Sel2Spin::~DlgRef_2Sel2Spin()
{ {
} }
//////////////////////////////////////////
// DlgRef_2Sel2Spin1Push
//////////////////////////////////////////
DlgRef_2Sel2Spin1Push::DlgRef_2Sel2Spin1Push( QWidget* parent, Qt::WindowFlags f )
: QWidget( parent, f )
{
setupUi( this );
}
DlgRef_2Sel2Spin1Push::~DlgRef_2Sel2Spin1Push()
{
}
////////////////////////////////////////// //////////////////////////////////////////
// DlgRef_2Sel3Spin2Rb // DlgRef_2Sel3Spin2Rb
////////////////////////////////////////// //////////////////////////////////////////

View File

@ -499,6 +499,22 @@ public:
~DlgRef_2Sel2Spin(); ~DlgRef_2Sel2Spin();
}; };
//////////////////////////////////////////
// DlgRef_2Sel2Spin1Push
//////////////////////////////////////////
#include "ui_DlgRef_2Sel2Spin1Push_QTD.h"
class DLGREF_EXPORT DlgRef_2Sel2Spin1Push : public QWidget,
public Ui::DlgRef_2Sel2Spin1Push_QTD
{
Q_OBJECT
public:
DlgRef_2Sel2Spin1Push( QWidget* = 0, Qt::WindowFlags = 0 );
~DlgRef_2Sel2Spin1Push();
};
////////////////////////////////////////// //////////////////////////////////////////
// DlgRef_2Sel3Spin2Rb // DlgRef_2Sel3Spin2Rb
////////////////////////////////////////// //////////////////////////////////////////

View File

@ -94,6 +94,7 @@ HEADERS += DlgRef_1Sel3Spin1Check.h
HEADERS += DlgRef_1Sel4Spin2Check.h HEADERS += DlgRef_1Sel4Spin2Check.h
HEADERS += DlgRef_2Sel1Spin2Check.h HEADERS += DlgRef_2Sel1Spin2Check.h
HEADERS += DlgRef_2Sel2Spin1Check.h HEADERS += DlgRef_2Sel2Spin1Check.h
HEADERS += DlgRef_2Sel2Spin1Push.h
HEADERS += DlgRef_2Sel2Spin3Check.h HEADERS += DlgRef_2Sel2Spin3Check.h
HEADERS += DlgRef_2Sel4Spin1Check.h HEADERS += DlgRef_2Sel4Spin1Check.h
HEADERS += DlgRef_3Sel4Spin2Check.h HEADERS += DlgRef_3Sel4Spin2Check.h

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DlgRef_2Sel2Spin1Push_QTD</class>
<widget class="QWidget" name="DlgRef_2Sel2Spin1Push_QTD">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>281</width>
<height>150</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="GroupBox1">
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="TextLabel1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TL1</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="PushButton1">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="LineEdit1"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="TextLabel2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TL2</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="PushButton2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="LineEdit2"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="TextLabel3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TL3</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DX"/>
</item>
<item row="3" column="2">
<widget class="SalomeApp_DoubleSpinBox" name="SpinBox_DY"/>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="PushButton3">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>SalomeApp_DoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">SalomeApp_DoubleSpinBox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>PushButton1</tabstop>
<tabstop>LineEdit1</tabstop>
<tabstop>PushButton2</tabstop>
<tabstop>LineEdit2</tabstop>
<tabstop>SpinBox_DX</tabstop>
<tabstop>SpinBox_DY</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -65,6 +65,7 @@ UIC_FILES = \
ui_DlgRef_2Sel2Spin1Check_QTD.h \ ui_DlgRef_2Sel2Spin1Check_QTD.h \
ui_DlgRef_2Sel2Spin3Check_QTD.h \ ui_DlgRef_2Sel2Spin3Check_QTD.h \
ui_DlgRef_2Sel2Spin_QTD.h \ ui_DlgRef_2Sel2Spin_QTD.h \
ui_DlgRef_2Sel2Spin1Push_QTD.h \
ui_DlgRef_2Sel3Spin2Rb_QTD.h \ ui_DlgRef_2Sel3Spin2Rb_QTD.h \
ui_DlgRef_2Sel3Spin_QTD.h \ ui_DlgRef_2Sel3Spin_QTD.h \
ui_DlgRef_2Sel4Spin1Check_QTD.h \ ui_DlgRef_2Sel4Spin1Check_QTD.h \

View File

@ -100,6 +100,7 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) ); QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) ); QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_LINE_2P" ) ) );
QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) ); QPixmap image4( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_ARC" ) ) );
QPixmap image5 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) ); setWindowTitle( tr( "GEOM_SKETCHER_TITLE" ) );
@ -116,18 +117,28 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
/***************************************************************/ /***************************************************************/
GroupBox1 = new QGroupBox(tr("GEOM_CS"), this); GroupBox1 = new QGroupBox(tr("GEOM_CS"), this);
QHBoxLayout* planeLayout = new QHBoxLayout(GroupBox1); QGridLayout* planeLayout = new QGridLayout(GroupBox1);
planeLayout->setSpacing(6); planeLayout->setSpacing(6);
planeLayout->setMargin(11); planeLayout->setMargin(11);
ComboBox1 = new QComboBox(GroupBox1); ComboBox1 = new QComboBox(GroupBox1);
ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) ); //ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
planeLayout->addWidget(ComboBox1); planeLayout->addWidget(ComboBox1,0,0,1,2);
planeButton = new QPushButton (GroupBox1); planeButton = new QPushButton (GroupBox1);
planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed)); //planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) ); planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
planeLayout->addWidget(planeButton); planeLayout->addWidget(planeButton,0,2);
selButton = new QPushButton (GroupBox1);
selButton->setIcon(image5);
planeLayout->addWidget(selButton,1,0);
WPlaneLineEdit = new QLineEdit (GroupBox1);
WPlaneLineEdit->setReadOnly(true);
planeLayout->addWidget(WPlaneLineEdit,1,1,1,2);
planeLayout->setColumnStretch(1,1);
topLayout->addWidget(GroupBox1); topLayout->addWidget(GroupBox1);
topLayout->addWidget( MainWidget ); topLayout->addWidget( MainWidget );
@ -311,8 +322,9 @@ EntityGUI_SketcherDlg::EntityGUI_SketcherDlg( GeometryGUI* GUI, QWidget* parent,
connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) ); connect( Group2Sel->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) ); connect( Group1Sel1Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( SelectionIntoArgument() ) ); connect( ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ActivateLocalCS() ) );
connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) ); connect( planeButton, SIGNAL( clicked() ), this, SLOT( ActivateLocalCS() ) );
connect( selButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( myGeometryGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
@ -394,12 +406,14 @@ void EntityGUI_SketcherDlg::Init()
{ {
/* init variables */ /* init variables */
autoApply = false; autoApply = false;
myEditCurrentArgument = Group1Sel->LineEdit1;
myEditCurrentArgument = WPlaneLineEdit; // Initiate the parameters selection with the first WPlaneLineEdit
myCommand.append( "Sketcher" ); myCommand.append( "Sketcher" );
myUndoCommand.append( "Sketcher" ); myUndoCommand.append( "Sketcher" );
mySketchState = FIRST_POINT; mySketchState = FIRST_POINT;
globalSelection( GEOM_POINT ); globalSelection( GEOM_FACE );
myCheckFlag = 0; myCheckFlag = 0;
@ -410,6 +424,13 @@ void EntityGUI_SketcherDlg::Init()
myHelpFileName = "create_sketcher_page.html"; myHelpFileName = "create_sketcher_page.html";
GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
0,0,1,
1,0,0 );
myWPlane = myGlobalCS;
myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
/* Get setting of step value from file configuration */ /* Get setting of step value from file configuration */
double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 ); double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
@ -435,11 +456,16 @@ void EntityGUI_SketcherDlg::Init()
MainWidget->RadioButton1->setChecked( true ); MainWidget->RadioButton1->setChecked( true );
TypeClicked( 0 );
FindLocalCS(); FindLocalCS();
TypeClicked( 0 );
// If a face has already been selected use it. Placed after FindLocalCS to avoid clearing the combobox
// that should be filled with the possibly selected face
SelectionIntoArgument();
resize(100,100); resize(100,100);
setPrefix(tr("GEOM_SKETCH"));
ActivateLocalCS(); ActivateLocalCS();
GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
} }
@ -451,6 +477,7 @@ void EntityGUI_SketcherDlg::Init()
//================================================================================= //=================================================================================
void EntityGUI_SketcherDlg::InitClick() void EntityGUI_SketcherDlg::InitClick()
{ {
MESSAGE("EntityGUI_SketcherDlg::InitClick()")
disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 ); disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
myCheckFlag = 0; myCheckFlag = 0;
@ -1007,6 +1034,8 @@ bool EntityGUI_SketcherDlg::ClickOnApply()
if ( sender() && sender()->inherits( "QPushButton" ) ) if ( sender() && sender()->inherits( "QPushButton" ) )
( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948) ( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
// addSubshapesToStudy();
QString aParameters; QString aParameters;
myCommand.append( GetNewCommand( aParameters ) ); myCommand.append( GetNewCommand( aParameters ) );
mySketchState = NEXT_POINT; mySketchState = NEXT_POINT;
@ -1168,210 +1197,163 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
{ {
MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument") MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
myEditCurrentArgument->setText( "" ); myEditCurrentArgument->setText( "" );
double tmpX = myX;
double tmpY = myY;
myX = myLastX1;
myY = myLastY1;
// printf ("\nmyX = %f myY = %f", myX, myY);
// printf ("\nmyLastX1 = %f myLastY1 = %f", myLastX1, myLastY1);
// printf ("\nmyLastX2 = %f myLastY2 = %f", myLastX2, myLastY2);
if ( sender() == ComboBox1 )
ActivateLocalCS();
LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr(); LightApp_SelectionMgr* aSelMgr = myGeometryGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList; SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList); aSelMgr->selectedObjects(aSelList);
int nbSel = aSelList.Extent(); this->activateWindow();
MESSAGE("NbSel = "<<nbSel)
if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !CORBA::is_nil(aSelectedObject) ) {
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
gp_Trsf aTrans;
gp_Ax3 aWPlane = GetActiveLocalCS();
aTrans.SetTransformation(aWPlane); if (aSelList.Extent() == 0)
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); {
aShape = aTransformation.Shape(); selButton->setDown(false);
WPlaneLineEdit->setEnabled(false);
gp_Pnt aPnt; WPlaneLineEdit->setText(tr("GEOM_SKETCHER_WPLANE"));
if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { return;
myX = aPnt.X();
myY = aPnt.Y();
Group1Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
if( Group2Spin->isVisible() && mySketchType == PT_ABS ) {
disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
Group2Spin->SpinBox_DX->setValue(myX);
Group2Spin->SpinBox_DY->setValue(myY);
connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
} else if ( Group2Spin->isVisible() && mySketchType == PT_RELATIVE ) {
if ( myLastX1 && myLastY1 ) {
Group2Spin->SpinBox_DX->setValue(myX - myLastX1);
Group2Spin->SpinBox_DY->setValue(myY - myLastY1);
} else {
if ( mySketchState != FIRST_POINT ) {
Group2Spin->SpinBox_DX->setValue(myX - tmpX);
Group2Spin->SpinBox_DY->setValue(myY - tmpY);
} else {
Group2Spin->SpinBox_DX->setValue(myX);
Group2Spin->SpinBox_DY->setValue(myY);
}
}
}
}
}
}
} }
else if (aSelList.Extent() != 1)
return;
if (nbSel == 1 && myEditCurrentArgument == Group1Sel1Spin->LineEdit1) { double tmpX = myX;
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() ); double tmpY = myY;
if ( !CORBA::is_nil(aSelectedObject) ) { myX = myLastX1;
TopoDS_Shape aShape; myY = myLastY1;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
gp_Trsf aTrans;
gp_Ax3 aWPlane = GetActiveLocalCS();
aTrans.SetTransformation(aWPlane); TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); if (myEditCurrentArgument == WPlaneLineEdit)
aShape = aTransformation.Shape(); aNeedType = TopAbs_FACE;
gp_Pnt aPnt;
if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) { GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
myX = aPnt.X(); TopoDS_Shape aShape;
myY = aPnt.Y();
Group1Sel1Spin->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) ); if(aSelectedObject && GEOMBase::GetShape(aSelectedObject.get(), aShape)
if( Group3Spin->isVisible() && mySketchType == PT_ABS ) { && !aShape.IsNull())
{
QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText(aName);
if (myEditCurrentArgument==WPlaneLineEdit)
{
AddLocalCS(aSelectedObject.get());
selButton->setDown(false);
WPlaneLineEdit->setEnabled(false);
TypeClicked( 0 );
}
else
{
gp_Trsf aTrans;
gp_Ax3 aWPlane = GetActiveLocalCS();
aTrans.SetTransformation(aWPlane);
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
aShape = aTransformation.Shape();
gp_Pnt aPnt;
if ( GEOMBase::VertexToPoint( aShape, aPnt ) )
{
myX = aPnt.X();
myY = aPnt.Y();
double Xcoord = myX;
double Ycoord = myY;
switch (mySketchType)
{
case PT_ABS:
disconnect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
disconnect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
Group2Spin->SpinBox_DX->setValue(Xcoord);
Group2Spin->SpinBox_DY->setValue(Ycoord);
connect( Group2Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group2Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
break;
case PT_RELATIVE:
if (myLastX1 && myLastY1)
{
Xcoord = myX - myLastX1;
Ycoord = myY - myLastY1;
}
else if (mySketchState != FIRST_POINT)
{
Xcoord = myX - tmpX;
Ycoord = myY - tmpY;
}
Group2Spin->SpinBox_DX->setValue(Xcoord);
Group2Spin->SpinBox_DY->setValue(Ycoord);
break;
case PT_ABS_RADIUS:
disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); disconnect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); disconnect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
Group3Spin->SpinBox_DX->setValue(myX);
Group3Spin->SpinBox_DY->setValue(myY); Group3Spin->SpinBox_DX->setValue(Xcoord);
Group3Spin->SpinBox_DY->setValue(Ycoord);
connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
} else if ( Group3Spin->isVisible() && mySketchType == PT_RELATIVE ) { break;
if ( myLastX1 && myLastY1 ) {
Group3Spin->SpinBox_DX->setValue(myX - myLastX1); case PT_REL_RADIUS:
Group3Spin->SpinBox_DY->setValue(myY - myLastY1); if (myLastX1 && myLastY1)
} else { {
if ( mySketchState != FIRST_POINT ) { Xcoord = myX - myLastX1;
Group3Spin->SpinBox_DX->setValue(myX - tmpX); Ycoord = myY - myLastY1;
Group3Spin->SpinBox_DY->setValue(myY - tmpY);
} else {
Group3Spin->SpinBox_DX->setValue(myX);
Group3Spin->SpinBox_DY->setValue(myY);
}
} }
} else if (mySketchState != FIRST_POINT)
} {
} Xcoord = myX - tmpX;
} Ycoord = myY - tmpY;
} }
Group3Spin->SpinBox_DX->setValue(Xcoord);
Group3Spin->SpinBox_DY->setValue(Ycoord);
break;
if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit1) { case PT_ABS_CENTER:
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !CORBA::is_nil(aSelectedObject) ) {
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
gp_Trsf aTrans;
gp_Ax3 aWPlane = GetActiveLocalCS();
aTrans.SetTransformation(aWPlane);
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
aShape = aTransformation.Shape();
gp_Pnt aPnt;
if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
myXc = aPnt.X();
myYc = aPnt.Y();
Group2Sel->LineEdit1->setText( GEOMBase::GetName( aSelectedObject ) );
if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); disconnect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); disconnect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
Group4Spin->SpinBox_DX->setValue(myXc);
Group4Spin->SpinBox_DY->setValue(myYc); Group4Spin->SpinBox_DX->setValue(Xcoord);
Group4Spin->SpinBox_DY->setValue(Ycoord);
connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group4Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
} else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) { break;
if ( myLastX1 && myLastY1 ) {
Group4Spin->SpinBox_DX->setValue(myXc - myLastX1); case PT_REL_CENTER:
Group4Spin->SpinBox_DY->setValue(myYc - myLastY1); if (myLastX1 && myLastY1)
} else { {
if ( mySketchState != FIRST_POINT ) { Xcoord = myXc - myLastX1;
Group4Spin->SpinBox_DX->setValue(myXc - tmpX); Ycoord = myYc - myLastY1;
Group4Spin->SpinBox_DY->setValue(myYc - tmpY);
} else {
Group4Spin->SpinBox_DX->setValue(myXc);
Group4Spin->SpinBox_DY->setValue(myYc);
}
} }
} else if (mySketchState != FIRST_POINT)
{
Xcoord = myXc - tmpX;
Ycoord = myYc - tmpY;
}
else
{
Xcoord = myXc;
Ycoord = myYc;
}
Group4Spin->SpinBox_DX->setValue(Xcoord);
Group4Spin->SpinBox_DY->setValue(Ycoord);
break;
} }
} }
} }
} }
if (nbSel == 1 && myEditCurrentArgument == Group2Sel->LineEdit2) { if(!autoApply){
if (!Group2Sel->LineEdit1->text().isEmpty()){ //Check wether or not Linedit2 has been modified
myX=tmpX; // If yes keep the old values of X and Y
myY=tmpY;
}
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
if ( !CORBA::is_nil(aSelectedObject) ) {
TopoDS_Shape aShape;
if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX)) {
gp_Trsf aTrans;
gp_Ax3 aWPlane = GetActiveLocalCS();
aTrans.SetTransformation(aWPlane);
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False);
aShape = aTransformation.Shape();
gp_Pnt aPnt;
if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
myX = aPnt.X();
myY = aPnt.Y();
Group2Sel->LineEdit2->setText( GEOMBase::GetName( aSelectedObject ) );
if( Group4Spin->isVisible() && mySketchType == PT_ABS ) {
disconnect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
disconnect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
Group4Spin->SpinBox_DZ->setValue(myX);
Group4Spin->SpinBox_DS->setValue(myY);
connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
} else if ( Group4Spin->isVisible() && mySketchType == PT_RELATIVE ) {
if ( myLastX1 && myLastY1 ) {
Group4Spin->SpinBox_DZ->setValue(myX - myLastX1);
Group4Spin->SpinBox_DS->setValue(myY - myLastY1);
} else {
if ( mySketchState != FIRST_POINT ) {
Group4Spin->SpinBox_DZ->setValue(myX - tmpX);
Group4Spin->SpinBox_DS->setValue(myY - tmpY);
} else {
Group4Spin->SpinBox_DZ->setValue(myX);
Group4Spin->SpinBox_DS->setValue(myY);
}
}
}
}
}
}
}
if (nbSel == 0){ // If no object selected
myX=tmpX; // Don't change the point coordinates
myY=tmpY; // and don't redisplay the preview
}
else if(!autoApply){
GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth ); GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
} }
if ( autoApply ){ else {
ClickOnApply(); ClickOnApply();
autoApply = false; autoApply = false;
} }
this->activateWindow();
} }
@ -1382,6 +1364,7 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
//================================================================================= //=================================================================================
void EntityGUI_SketcherDlg::SetEditCurrentArgument() void EntityGUI_SketcherDlg::SetEditCurrentArgument()
{ {
TopAbs_ShapeEnum myNeedType = TopAbs_VERTEX;
if ( sender() == Group1Sel->PushButton1 ) { if ( sender() == Group1Sel->PushButton1 ) {
myEditCurrentArgument = Group1Sel->LineEdit1; myEditCurrentArgument = Group1Sel->LineEdit1;
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
@ -1406,7 +1389,14 @@ void EntityGUI_SketcherDlg::SetEditCurrentArgument()
Group2Sel->LineEdit2->setEnabled(true); Group2Sel->LineEdit2->setEnabled(true);
// myEditCurrentArgument->setFocus(); // myEditCurrentArgument->setFocus();
} }
SelectionIntoArgument(); else if ( sender() == selButton ) {
myNeedType = TopAbs_FACE;
myEditCurrentArgument = WPlaneLineEdit;
WPlaneLineEdit->setEnabled(true);
selButton->setDown(true);
}
globalSelection(); // close local selection to clear it
localSelection(GEOM::GEOM_Object::_nil(), myNeedType);
} }
@ -1470,9 +1460,9 @@ void EntityGUI_SketcherDlg::ActivateThisDialog()
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
//myGeometryGUI->SetState( 0 ); //myGeometryGUI->SetState( 0 );
globalSelection( GEOM_POINT ); // globalSelection( GEOM_POINT );
myEditCurrentArgument = Group1Sel->LineEdit1; myEditCurrentArgument = WPlaneLineEdit;
myEditCurrentArgument->setFocus(); myEditCurrentArgument->setFocus();
if ( sender() == Group1Sel->LineEdit1 ) { if ( sender() == Group1Sel->LineEdit1 ) {
@ -2235,24 +2225,14 @@ bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
} }
} }
gp_Ax3 myWPlane = GetActiveLocalCS();
GEOM::ListOfDouble_var WPlane = new GEOM::ListOfDouble;
WPlane->length( 9 );
WPlane[0] = myWPlane.Location().X();
WPlane[1] = myWPlane.Location().Y();
WPlane[2] = myWPlane.Location().Z();
WPlane[3] = myWPlane.Direction().X();
WPlane[4] = myWPlane.Direction().Y();
WPlane[5] = myWPlane.Direction().Z();
WPlane[6] = myWPlane.XDirection().X();
WPlane[7] = myWPlane.XDirection().Y();
WPlane[8] = myWPlane.XDirection().Z();
GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation()); GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
GEOM::GEOM_Object_var anObj = anOper->MakeSketcher( cmd.toLatin1().constData(), WPlane ); GEOM::GEOM_Object_var anObj = NULL;
int index = ComboBox1->currentIndex();
if(index != -1 && !myWPlane->_is_nil()) // The combobox is not empty
{
anObj = anOper->MakeSketcherOnPlane( cmd.toLatin1().constData(), myWPlane );
}
if ( !anObj->_is_nil() ) if ( !anObj->_is_nil() )
{ {
if( !IsPreview() ) { if( !IsPreview() ) {
@ -2325,7 +2305,7 @@ void EntityGUI_SketcherDlg::displayPntPreview(const double x,
) )
{ {
// Get globalCS and working plane // Get globalCS and working plane
gp_Ax3 globalCS = myLCSList.first(); //gp_Ax3(aOrigin, aDirZ, aDirX); gp_Ax3 globalCS = WPlaneToLCS( myGlobalCS );
gp_Ax3 aWPlane = GetActiveLocalCS(); gp_Ax3 aWPlane = GetActiveLocalCS();
// Build point in localCS // Build point in localCS
@ -2392,6 +2372,16 @@ bool EntityGUI_SketcherDlg::createShapes( GEOM::GEOM_Object_ptr theObject,
return true; return true;
} }
//=================================================================================
// function : acceptMouseEvent()
// purpose :
//=================================================================================
bool EntityGUI_SketcherDlg::acceptMouseEvent() const
{
return ( (getPnt1ConstructorId() == 1 || getPnt1ConstructorId() == 0) //accept mouse event only on absolute and relative selection mode
&& !WPlaneLineEdit->isEnabled()); // called by EntityGUI::OnMousePress()
}
//================================================================================= //=================================================================================
// function : keyPressEvent() // function : keyPressEvent()
// purpose : // purpose :
@ -2457,14 +2447,43 @@ void EntityGUI_SketcherDlg::SetDoubleSpinBoxStep( double step )
//Group4Spin->SpinBox_DS->setSingleStep(step); //Group4Spin->SpinBox_DS->setSingleStep(step);
} }
//=================================================================================
// function : AddLocalCS()
// purpose : Add All Coordinates systems in study
//=================================================================================
void EntityGUI_SketcherDlg::AddLocalCS(GEOM::GEOM_Object_var aSelectedObject)
{
MESSAGE("EntityGUI_SketcherDlg::AddLocalCS")
QString aName = GEOMBase::GetName( aSelectedObject );
int index = ComboBox1->findText(aName, Qt::MatchExactly);
if (index==-1) // If the working plane hasn't been added yet
{
myWPlaneList.push_back(aSelectedObject);
myWPlane = aSelectedObject;
addSubshapesToStudy();
myLCSList.push_back(WPlaneToLCS(aSelectedObject));
ComboBox1->addItem(aName);
index = ComboBox1->count();
ComboBox1->setCurrentIndex(index-1);
}
else
{
ComboBox1->setCurrentIndex(index);
}
ActivateLocalCS();
}
//================================================================================= //=================================================================================
// function : FindLocalCS() // function : FindLocalCS()
// purpose : Find All Coordinates systems in study // purpose : Find All Coordinates systems in study
//================================================================================= //=================================================================================
void EntityGUI_SketcherDlg::FindLocalCS() void EntityGUI_SketcherDlg::FindLocalCS()
{ {
MESSAGE("EntityGUI_SketcherDlg::FindLocalCS")
ComboBox1->clear(); ComboBox1->clear();
myLCSList.clear(); myWPlaneList.clear();
SalomeApp_Application* app = SalomeApp_Application* app =
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) if ( !app )
@ -2478,11 +2497,7 @@ void EntityGUI_SketcherDlg::FindLocalCS()
//add Global CS //add Global CS
ComboBox1->addItem(tr("GEOM_GCS")); ComboBox1->addItem(tr("GEOM_GCS"));
gp_Pnt aOrigin = gp_Pnt(0, 0, 0); myWPlaneList.push_back(myGlobalCS);
gp_Dir aDirZ = gp_Dir(0, 0, 1);
gp_Dir aDirX = gp_Dir(1, 0, 0);
gp_Ax3 globalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
myLCSList.push_back(globalCS);
// get GEOM component // get GEOM component
CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() ); CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
@ -2497,31 +2512,55 @@ void EntityGUI_SketcherDlg::FindLocalCS()
// browse through all GEOM data tree // browse through all GEOM data tree
_PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) ); _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
for ( it->InitEx( true ); it->More(); it->Next() ) { for ( it->InitEx( true ); it->More(); it->Next() )
{
_PTR(SObject) child( it->Value() ); _PTR(SObject) child( it->Value() );
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child ); CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( child );
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj ); GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
if( CORBA::is_nil( geomObj ) ) if( CORBA::is_nil( geomObj ) )
continue; continue;
if (geomObj->GetType() == GEOM_MARKER) { if (geomObj->GetType() == GEOM_MARKER)
{
myWPlaneList.push_back(geomObj);
myLCSList.push_back(WPlaneToLCS(geomObj));
ComboBox1->addItem(geomObj->GetName()); ComboBox1->addItem(geomObj->GetName());
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj); MESSAGE("ComboBox1->addItem() in EntityGUI_SketcherDlg::FindLocalCS()")
gp_Ax3 aLCS;
aLCS.Transform(aShape.Location().Transformation());
if (aShape.ShapeType() == TopAbs_FACE) {
Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aShape));
if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
gp_Pln aPln = aGPlane->Pln();
aLCS = aPln.Position();
}
}
myLCSList.push_back(aLCS);
} }
} }
} }
//=================================================================================
// function : WPlaneToLCS ( aWPlane )
// purpose :
//=================================================================================
gp_Ax3 EntityGUI_SketcherDlg::WPlaneToLCS( GEOM::GEOM_Object_var geomObj )
{
TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
gp_Ax3 aLCS;
if (CORBA::is_nil( geomObj ) || aShape.IsNull())
{
MESSAGE("CORBA::is_nil( geomObj ) || aShape.IsNull()")
}
aLCS.Transform(aShape.Location().Transformation());
if (aShape.ShapeType() == TopAbs_FACE)
{
GEOM::GEOM_IMeasureOperations_ptr aMeasureOp =
myGeometryGUI->GetGeomGen()->GetIMeasureOperations( getStudyId() );
double Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz;
aMeasureOp->GetPosition( geomObj, Ox, Oy, Oz, Zx, Zy, Zz, Xx, Xy, Xz);
if ( aMeasureOp->IsDone() )
{
gp_Pnt aPnt ( Ox, Oy, Oz );
gp_Dir aDirN ( Zx, Zy, Zz );
gp_Dir aDirX ( Xx, Xy, Xz );
aLCS = gp_Ax3( aPnt, aDirN, aDirX );
}
}
return aLCS;
}
//================================================================================= //=================================================================================
// function : getPnt1ConstructorId() // function : getPnt1ConstructorId()
// purpose : // purpose :
@ -2550,11 +2589,13 @@ int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
//================================================================================= //=================================================================================
gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS() gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
{ {
MESSAGE("EntityGUI_SketcherDlg::GetActiveLocalCS()")
int ind = ComboBox1->currentIndex(); int ind = ComboBox1->currentIndex();
if (ind == -1) if (ind == -1)
return myGeometryGUI->GetWorkingPlane(); return myGeometryGUI->GetWorkingPlane();
gp_Ax3 aLCS = myLCSList.at(ind); gp_Ax3 aLCS = myLCSList.at(ind);
myWPlane = myWPlaneList.at(ind);
return aLCS; return aLCS;
} }
@ -2565,6 +2606,17 @@ gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
//================================================================================= //=================================================================================
void EntityGUI_SketcherDlg::ActivateLocalCS() void EntityGUI_SketcherDlg::ActivateLocalCS()
{ {
myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() ); MESSAGE("EntityGUI_SketcherDlg::ActivateLocalCS")
myGeometryGUI->ActiveWorkingPlane(); myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
myGeometryGUI->ActiveWorkingPlane();
}
//=================================================================================
// function : addSubshapeToStudy
// purpose : virtual method to add new SubObjects if local selection
//=================================================================================
void EntityGUI_SketcherDlg::addSubshapesToStudy()
{
MESSAGE("EntityGUI_SketcherDlg::addSubshapesToStudy()")
GEOMBase::PublishSubObject(myWPlane);
} }

View File

@ -73,9 +73,8 @@ public:
bool eventFilter (QObject* object, QEvent* event); bool eventFilter (QObject* object, QEvent* event);
bool acceptMouseEvent() const { return ( getPnt1ConstructorId() == 1 bool acceptMouseEvent() const; // called by EntityGUI::OnMousePress()
|| getPnt1ConstructorId() == 0 ); } //accept mouse event only on absolute and relative selection mode void OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& );
void OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& ); // called by EntityGUI::OnMousePress()
protected: protected:
void initSpinBox( SalomeApp_DoubleSpinBox*, void initSpinBox( SalomeApp_DoubleSpinBox*,
@ -86,6 +85,7 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation(); virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& ); virtual bool isValid( QString& );
virtual bool execute( ObjectList& ); virtual bool execute( ObjectList& );
virtual void addSubshapesToStudy();
void closeEvent( QCloseEvent* ); void closeEvent( QCloseEvent* );
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
@ -170,6 +170,9 @@ private:
QGroupBox* GroupBox1; QGroupBox* GroupBox1;
QComboBox* ComboBox1; QComboBox* ComboBox1;
QPushButton* planeButton; QPushButton* planeButton;
QPushButton* selButton;
QLineEdit* WPlaneLineEdit;
GeometryGUI* myGeometryGUI; GeometryGUI* myGeometryGUI;
@ -178,6 +181,9 @@ private:
double myLineWidth; double myLineWidth;
QList<gp_Ax3> myLCSList; QList<gp_Ax3> myLCSList;
GEOM::GEOM_Object_var myGlobalCS;
GEOM::GEOM_Object_var myWPlane;
QList< GEOM::GEOM_Object_var > myWPlaneList;
int myCheckFlag; int myCheckFlag;
@ -215,8 +221,10 @@ private slots:
void CheckBoxClicked( int ); void CheckBoxClicked( int );
void ValueChangedInSpinBox( double ); void ValueChangedInSpinBox( double );
void SetDoubleSpinBoxStep( double ); void SetDoubleSpinBoxStep( double );
void AddLocalCS( GEOM::GEOM_Object_var );
void FindLocalCS(); void FindLocalCS();
gp_Ax3 GetActiveLocalCS(); gp_Ax3 GetActiveLocalCS();
gp_Ax3 WPlaneToLCS( GEOM::GEOM_Object_var );
void ActivateLocalCS(); void ActivateLocalCS();
}; };

View File

@ -779,7 +779,7 @@
<source>ICO_DELETE</source> <source>ICO_DELETE</source>
<translation>delete.png</translation> <translation>delete.png</translation>
</message> </message>
<message> <message>
<source>ICO_DISK</source> <source>ICO_DISK</source>
<translation>disk.png</translation> <translation>disk.png</translation>
</message> </message>
@ -795,6 +795,14 @@
<source>ICO_DISPLAY_ONLY</source> <source>ICO_DISPLAY_ONLY</source>
<translation>displayonly.png</translation> <translation>displayonly.png</translation>
</message> </message>
<message>
<source>ICO_DRAFT</source>
<translation>draft.png</translation>
</message>
<message>
<source>ICO_DISPLAY_ONLY</source>
<translation>displayonly.png</translation>
</message>
<message> <message>
<source>ICO_EDGE</source> <source>ICO_EDGE</source>
<translation>build_edge.png</translation> <translation>build_edge.png</translation>
@ -822,6 +830,14 @@
<message> <message>
<source>ICO_EXPLODE_BLOCKS</source> <source>ICO_EXPLODE_BLOCKS</source>
<translation>subshape.png</translation> <translation>subshape.png</translation>
</message>
<message>
<source>ICO_EXTRUDED_BOSS</source>
<translation>extruded_boss.png</translation>
</message>
<message>
<source>ICO_EXTRUDED_CUT</source>
<translation>extruded_cut.png</translation>
</message> </message>
<message> <message>
<source>ICO_EXTRUSION</source> <source>ICO_EXTRUSION</source>

View File

@ -585,6 +585,19 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_EXTRUSION</source> <source>GEOM_EXTRUSION</source>
<translation>Extrusion</translation> <translation>Extrusion</translation>
</message> </message>
<message>
<source>GEOM_EXTRUDED_CUT</source>
<translation>Extruded cut</translation>
</message>
<message>
<source>GEOM_EXTRUDED_BOSS</source>
<translation>Extruded boss</translation>
</message>
<message>
<source>GEOM_EXTRUSION</source>
<translation>Extrusion</translation>
</message>
<message> <message>
<source>GEOM_EXTRUSION_BSV</source> <source>GEOM_EXTRUSION_BSV</source>
<translation>Base Shapes + Vector</translation> <translation>Base Shapes + Vector</translation>
@ -806,6 +819,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_HOLES</source> <source>GEOM_HOLES</source>
<translation>Holes</translation> <translation>Holes</translation>
</message> </message>
<message>
<source>GEOM_INIT_SHAPE</source>
<translation>Initial shape</translation>
</message>
<message> <message>
<source>GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE</source> <source>GEOM_IDENTICAL_NAMES_SELECT_BY_MOUSE</source>
<translation>Identical names : select by mouse !</translation> <translation>Identical names : select by mouse !</translation>
@ -1566,6 +1583,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_SHELL_TITLE</source> <source>GEOM_SHELL_TITLE</source>
<translation>Shell Construction</translation> <translation>Shell Construction</translation>
</message> </message>
<message>
<source>GEOM_SKETCH</source>
<translation>Sketch</translation>
</message>
<message> <message>
<source>GEOM_SKETCHER_ABS</source> <source>GEOM_SKETCHER_ABS</source>
<translation>Absolute</translation> <translation>Absolute</translation>
@ -1726,6 +1747,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_SKETCHER_VXVY</source> <source>GEOM_SKETCHER_VXVY</source>
<translation>VX-VY</translation> <translation>VX-VY</translation>
</message> </message>
<message>
<source>GEOM_SKETCHER_WPLANE</source>
<translation>Select a planar face or a plane</translation>
</message>
<message> <message>
<source>GEOM_SKETCHER_VY2</source> <source>GEOM_SKETCHER_VY2</source>
<translation>VY :</translation> <translation>VY :</translation>
@ -2370,6 +2395,14 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_EXTRUSION</source> <source>MEN_EXTRUSION</source>
<translation>Extrusion</translation> <translation>Extrusion</translation>
</message> </message>
<message>
<source>MEN_EXTRUDED_CUT</source>
<translation>Extruded cut</translation>
</message>
<message>
<source>MEN_EXTRUDED_BOSS</source>
<translation>Extruded boss</translation>
</message>
<message> <message>
<source>MEN_FACE</source> <source>MEN_FACE</source>
<translation>Face</translation> <translation>Face</translation>

View File

@ -1717,6 +1717,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
<source>GEOM_SKETCHER_VXVY</source> <source>GEOM_SKETCHER_VXVY</source>
<translation>VX-VY</translation> <translation>VX-VY</translation>
</message> </message>
<message>
<source>GEOM_SKETCHER_WPLANE</source>
<translation>Sélectionnez une face plane ou un plan</translation>
</message>
<message> <message>
<source>GEOM_SKETCHER_VY2</source> <source>GEOM_SKETCHER_VY2</source>
<translation>VY :</translation> <translation>VY :</translation>

View File

@ -512,6 +512,8 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D case GEOMOp::OpFillet2d: // MENU OPERATION - FILLET 2D
case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D case GEOMOp::OpFillet1d: // MENU OPERATION - FILLET 1D
case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
libName = "OperationGUI"; libName = "OperationGUI";
break; break;
case GEOMOp::OpSewing: // MENU REPAIR - SEWING case GEOMOp::OpSewing: // MENU REPAIR - SEWING
@ -785,6 +787,8 @@ void GeometryGUI::initialize( CAM_Application* app )
//createGeomAction( GEOMOp::OpClipping, "CLIPPING" ); //createGeomAction( GEOMOp::OpClipping, "CLIPPING" );
createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" ); createGeomAction( GEOMOp::OpShapesOnShape, "GET_SHAPES_ON_SHAPE" );
createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" ); createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" ); createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" ); createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
@ -1001,6 +1005,8 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( GEOMOp::OpFillet2d, operId, -1 ); createMenu( GEOMOp::OpFillet2d, operId, -1 );
createMenu( GEOMOp::OpFillet3d, operId, -1 ); createMenu( GEOMOp::OpFillet3d, operId, -1 );
createMenu( GEOMOp::OpChamfer, operId, -1 ); createMenu( GEOMOp::OpChamfer, operId, -1 );
createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
//createMenu( GEOMOp::OpClipping, operId, -1 ); //createMenu( GEOMOp::OpClipping, operId, -1 );
int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 ); int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
@ -1078,33 +1084,43 @@ void GeometryGUI::initialize( CAM_Application* app )
// ---- create toolbars -------------------------- // ---- create toolbars --------------------------
int basicTbId = createTool( tr( "TOOL_BASIC" ) ); int basicTbId = createTool( tr( "TOOL_BASIC" ) );
createTool( GEOMOp::OpPoint, basicTbId ); createTool( GEOMOp::OpPoint, basicTbId );
createTool( GEOMOp::OpLine, basicTbId ); createTool( GEOMOp::OpLine, basicTbId );
createTool( GEOMOp::OpCircle, basicTbId ); createTool( GEOMOp::OpCircle, basicTbId );
createTool( GEOMOp::OpEllipse, basicTbId ); createTool( GEOMOp::OpEllipse, basicTbId );
createTool( GEOMOp::OpArc, basicTbId ); createTool( GEOMOp::OpArc, basicTbId );
createTool( GEOMOp::OpCurve, basicTbId ); createTool( GEOMOp::OpCurve, basicTbId );
createTool( GEOMOp::OpVector, basicTbId ); createTool( GEOMOp::OpVector, basicTbId );
createTool( GEOMOp::OpPlane, basicTbId ); createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
createTool( GEOMOp::OpLCS, basicTbId ); createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
createTool( GEOMOp::OpPlane, basicTbId );
createTool( GEOMOp::OpLCS, basicTbId );
createTool( GEOMOp::OpOriginAndVectors, basicTbId ); createTool( GEOMOp::OpOriginAndVectors, basicTbId );
// int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
// createTool( GEOMOp::Op2dSketcher, sketchTbId );
// createTool( GEOMOp::Op3dSketcher, sketchTbId );
int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) ); int primTbId = createTool( tr( "TOOL_PRIMITIVES" ) );
createTool( GEOMOp::OpBox, primTbId ); createTool( GEOMOp::OpBox, primTbId );
createTool( GEOMOp::OpCylinder, primTbId ); createTool( GEOMOp::OpCylinder, primTbId );
createTool( GEOMOp::OpSphere, primTbId ); createTool( GEOMOp::OpSphere, primTbId );
createTool( GEOMOp::OpTorus, primTbId ); createTool( GEOMOp::OpTorus, primTbId );
createTool( GEOMOp::OpCone, primTbId ); createTool( GEOMOp::OpCone, primTbId );
createTool( GEOMOp::OpRectangle, primTbId ); createTool( GEOMOp::OpRectangle, primTbId );
createTool( GEOMOp::OpDisk, primTbId ); createTool( GEOMOp::OpDisk, primTbId );
createTool( GEOMOp::OpPipeTShape, primTbId ); //rnc
// int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); //rnc
// createTool( GEOMOp::OpPipeTShape, advancedTbId );
int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) ); int boolTbId = createTool( tr( "TOOL_BOOLEAN" ) );
createTool( GEOMOp::OpFuse, boolTbId ); createTool( GEOMOp::OpFuse, boolTbId );
createTool( GEOMOp::OpCommon, boolTbId ); createTool( GEOMOp::OpCommon, boolTbId );
createTool( GEOMOp::OpCut, boolTbId ); createTool( GEOMOp::OpCut, boolTbId );
createTool( GEOMOp::OpSection, boolTbId ); createTool( GEOMOp::OpSection, boolTbId );
int genTbId = createTool( tr( "TOOL_GENERATION" ) ); int genTbId = createTool( tr( "TOOL_GENERATION" ) );
createTool( GEOMOp::OpPrism, genTbId ); createTool( GEOMOp::OpPrism, genTbId );
createTool( GEOMOp::OpRevolution, genTbId ); createTool( GEOMOp::OpRevolution, genTbId );
createTool( GEOMOp::OpFilling, genTbId ); createTool( GEOMOp::OpFilling, genTbId );
@ -1123,26 +1139,19 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( GEOMOp::OpMultiRotate, transTbId ); createTool( GEOMOp::OpMultiRotate, transTbId );
int operTbId = createTool( tr( "TOOL_OPERATIONS" ) ); int operTbId = createTool( tr( "TOOL_OPERATIONS" ) );
createTool( GEOMOp::Op2dSketcher, operTbId );
createTool( GEOMOp::Op3dSketcher, operTbId );
createTool( separator(), operTbId );
createTool( GEOMOp::OpExplode, operTbId ); createTool( GEOMOp::OpExplode, operTbId );
createTool( separator(), operTbId );
#ifdef WITH_OPENCV
createTool( GEOMOp::OpFeatureDetect, operTbId );
#endif
createTool( GEOMOp::OpPictureImport, operTbId );
createTool( separator(), operTbId );
createTool( GEOMOp::OpPartition, operTbId ); createTool( GEOMOp::OpPartition, operTbId );
createTool( GEOMOp::OpArchimede, operTbId ); createTool( GEOMOp::OpArchimede, operTbId );
createTool( GEOMOp::OpShapesOnShape, operTbId ); createTool( GEOMOp::OpShapesOnShape, operTbId );
createTool( GEOMOp::OpSharedShapes, operTbId ); createTool( GEOMOp::OpSharedShapes, operTbId );
createTool( separator(), operTbId );
createTool( GEOMOp::OpFillet1d, operTbId ); int featTbId = createTool( tr( "TOOL_FEATURES" ) );
createTool( GEOMOp::OpFillet2d, operTbId ); createTool( GEOMOp::OpFillet1d, featTbId );
createTool( GEOMOp::OpFillet3d, operTbId ); createTool( GEOMOp::OpFillet2d, featTbId );
createTool( GEOMOp::OpChamfer, operTbId ); createTool( GEOMOp::OpFillet3d, featTbId );
createTool( GEOMOp::OpChamfer, featTbId );
createTool( GEOMOp::OpExtrudedBoss, featTbId );
createTool( GEOMOp::OpExtrudedCut, featTbId );
int buildTbId = createTool( tr( "TOOL_BUILD" ) ); int buildTbId = createTool( tr( "TOOL_BUILD" ) );
createTool( GEOMOp::OpEdge, buildTbId ); createTool( GEOMOp::OpEdge, buildTbId );
@ -1172,8 +1181,12 @@ void GeometryGUI::initialize( CAM_Application* app )
createTool( GEOMOp::OpCheckCompound, measureTbId ); createTool( GEOMOp::OpCheckCompound, measureTbId );
createTool( GEOMOp::OpCheckSelfInters, measureTbId ); createTool( GEOMOp::OpCheckSelfInters, measureTbId );
int advancedTbId = createTool( tr( "TOOL_ADVANCED" ) ); int picturesTbId = createTool( tr( "TOOL_PICTURES" ) );
createTool( GEOMOp::OpPipeTShape, advancedTbId ); createTool( GEOMOp::OpPictureImport, picturesTbId );
#ifdef WITH_OPENCV
createTool( GEOMOp::OpFeatureDetect, picturesTbId );
#endif
//@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
// ---- create popup menus -------------------------- // ---- create popup menus --------------------------

View File

@ -136,6 +136,8 @@ namespace GEOMOp {
OpFillet1d = 3706, // MENU OPERATION - FILLET 1D OpFillet1d = 3706, // MENU OPERATION - FILLET 1D
OpClipping = 3707, // MENU OPERATION - CLIPPING RANGE OpClipping = 3707, // MENU OPERATION - CLIPPING RANGE
OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
// RepairGUI -----------------//-------------------------------- // RepairGUI -----------------//--------------------------------
OpSewing = 4000, // MENU REPAIR - SEWING OpSewing = 4000, // MENU REPAIR - SEWING
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES

View File

@ -1293,6 +1293,88 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
return aPrism; return aPrism;
} }
//=============================================================================
/*!
* MakeDraftPrism
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
(Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
{
SetErrorCode(KO);
if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
Handle(GEOM_Object) aPrism = NULL;
if ( theFuse )
{
//Add a new Extruded Boss object
aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
}
else
{
//Add a new Extruded Cut object
aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
}
//Add a new Prism function for the creation of a Draft Prism feature
Handle(GEOM_Function) aFunction =
aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
GEOMImpl_IPrism aCI (aFunction);
Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
// Set parameters
aCI.SetBase(aRefBase);
aCI.SetInitShape(aRefInit);
aCI.SetH(theHeight);
aCI.SetDraftAngle(theAngle);
if ( theFuse )
aCI.SetFuseFlag(1);
else
aCI.SetFuseFlag(0);
//Compute the Draft Prism Feature value
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Extrusion can not be created, check input data");
return NULL;
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
//Make a Python command
if(theFuse)
{
GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
<< theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
}
else
{
GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
<< theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
}
SetErrorCode(OK);
return aPrism;
}
//============================================================================= //=============================================================================
/*! /*!
* MakePipe * MakePipe

View File

@ -90,6 +90,9 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) MakePrismDXDYDZ2Ways (Handle(GEOM_Object) theBase, Standard_EXPORT Handle(GEOM_Object) MakePrismDXDYDZ2Ways (Handle(GEOM_Object) theBase,
double theDX, double theDY, double theDZ); double theDX, double theDY, double theDZ);
Standard_EXPORT Handle(GEOM_Object) MakeDraftPrism (Handle(GEOM_Object) theInitShape, Handle(GEOM_Object) theBase,
double theHeight, double theAngle, bool theFuse);
Standard_EXPORT Handle(GEOM_Object) MakePipe (Handle(GEOM_Object) theBase, Standard_EXPORT Handle(GEOM_Object) MakePipe (Handle(GEOM_Object) theBase,
Handle(GEOM_Object) thePath); Handle(GEOM_Object) thePath);

View File

@ -23,16 +23,21 @@
//NOTE: This is an intreface to a function for the Prism creation. //NOTE: This is an intreface to a function for the Prism creation.
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
// #include <GEOMImpl_Mode.hxx> TEST
#define PRISM_ARG_H 1 #define PRISM_ARG_H 1
#define PRISM_ARG_VEC 2 #define PRISM_ARG_VEC 2
#define PRISM_ARG_BASE 3 #define PRISM_ARG_BASE 3
#define PRISM_ARG_PNT_F 4 #define PRISM_ARG_PNT_F 4
#define PRISM_ARG_PNT_L 5 #define PRISM_ARG_PNT_L 5
#define PRISM_ARG_DX 6 #define PRISM_ARG_DX 6
#define PRISM_ARG_DY 7 #define PRISM_ARG_DY 7
#define PRISM_ARG_DZ 8 #define PRISM_ARG_DZ 8
#define PRISM_ARG_SCALE 9 #define PRISM_ARG_SCALE 9
#define PRISM_ARG_DRAFT 10
#define PRISM_ARG_FUSE 11
#define PRISM_ARG_INIT 12
#define PRISM_ARG_MODE 13
class GEOMImpl_IPrism class GEOMImpl_IPrism
{ {
@ -40,15 +45,17 @@ class GEOMImpl_IPrism
GEOMImpl_IPrism(Handle(GEOM_Function) theFunction): _func(theFunction) {} GEOMImpl_IPrism(Handle(GEOM_Function) theFunction): _func(theFunction) {}
void SetBase (Handle(GEOM_Function) theRefBase ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); } void SetBase (Handle(GEOM_Function) theRefBase ) { _func->SetReference(PRISM_ARG_BASE, theRefBase); }
void SetVector(Handle(GEOM_Function) theRefVector) { _func->SetReference(PRISM_ARG_VEC , theRefVector); } void SetVector(Handle(GEOM_Function) theRefVector ) { _func->SetReference(PRISM_ARG_VEC , theRefVector); }
void SetFirstPoint(Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_F, thePoint); } void SetFirstPoint(Handle(GEOM_Function) thePoint ) { _func->SetReference(PRISM_ARG_PNT_F, thePoint); }
void SetLastPoint (Handle(GEOM_Function) thePoint) { _func->SetReference(PRISM_ARG_PNT_L, thePoint); } void SetLastPoint (Handle(GEOM_Function) thePoint ) { _func->SetReference(PRISM_ARG_PNT_L, thePoint); }
void SetInitShape (Handle(GEOM_Function) theInitShape) { _func->SetReference(PRISM_ARG_INIT, theInitShape); }
Handle(GEOM_Function) GetBase () { return _func->GetReference(PRISM_ARG_BASE); } Handle(GEOM_Function) GetBase () { return _func->GetReference(PRISM_ARG_BASE); }
Handle(GEOM_Function) GetVector() { return _func->GetReference(PRISM_ARG_VEC ); } Handle(GEOM_Function) GetVector() { return _func->GetReference(PRISM_ARG_VEC ); }
Handle(GEOM_Function) GetFirstPoint() { return _func->GetReference(PRISM_ARG_PNT_F ); } Handle(GEOM_Function) GetFirstPoint() { return _func->GetReference(PRISM_ARG_PNT_F ); }
Handle(GEOM_Function) GetLastPoint () { return _func->GetReference(PRISM_ARG_PNT_L ); } Handle(GEOM_Function) GetLastPoint () { return _func->GetReference(PRISM_ARG_PNT_L ); }
Handle(GEOM_Function) GetInitShape () { return _func->GetReference(PRISM_ARG_INIT ); }
void SetDX(double theDX) { _func->SetReal(PRISM_ARG_DX, theDX); } void SetDX(double theDX) { _func->SetReal(PRISM_ARG_DX, theDX); }
void SetDY(double theDY) { _func->SetReal(PRISM_ARG_DY, theDY); } void SetDY(double theDY) { _func->SetReal(PRISM_ARG_DY, theDY); }
@ -58,13 +65,19 @@ class GEOMImpl_IPrism
double GetDY() { return _func->GetReal(PRISM_ARG_DY); } double GetDY() { return _func->GetReal(PRISM_ARG_DY); }
double GetDZ() { return _func->GetReal(PRISM_ARG_DZ); } double GetDZ() { return _func->GetReal(PRISM_ARG_DZ); }
void SetH(double theH) { _func->SetReal(PRISM_ARG_H, theH); } void SetH (double theH ) { _func->SetReal(PRISM_ARG_H, theH); }
void SetScale (double theH ) { _func->SetReal(PRISM_ARG_SCALE, theH); }
double GetH() { return _func->GetReal(PRISM_ARG_H); } void SetDraftAngle(double theAngle) { _func->SetReal(PRISM_ARG_DRAFT, theAngle); }
void SetScale(double theH) { _func->SetReal(PRISM_ARG_SCALE, theH); }
double GetH() { return _func->GetReal(PRISM_ARG_H); }
double GetScale() { return _func->GetReal(PRISM_ARG_SCALE); } double GetScale() { return _func->GetReal(PRISM_ARG_SCALE); }
double GetDraftAngle() { return _func->GetReal(PRISM_ARG_DRAFT); }
void SetFuseFlag(int theFlag) { _func->SetInteger(PRISM_ARG_FUSE, theFlag); }
// void SetMode(GEOMImpl_Mode theMode) { _func->SetInteger(PRISM_ARG_MODE, theMode); } //TEST
int GetFuseFlag() { return _func->GetInteger(PRISM_ARG_FUSE); }
// GEOMImpl_Mode GetMode() { return _func->GetInteger(PRISM_ARG_MODE); } //TEST
private: private:

View File

@ -31,16 +31,19 @@
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <BRepPrimAPI_MakePrism.hxx> #include <BRepPrimAPI_MakePrism.hxx>
#include <BRepFeat_MakeDPrism.hxx>
#include <BRep_Builder.hxx> #include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx> #include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx> #include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx> #include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_Sewing.hxx> #include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_Transform.hxx> #include <BRepBuilderAPI_Transform.hxx>
#include <BRepCheck_Shell.hxx> #include <BRepCheck_Shell.hxx>
#include <BRepClass3d_SolidClassifier.hxx> #include <BRepClass3d_SolidClassifier.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
@ -65,6 +68,8 @@
#include <Standard_ConstructionError.hxx> #include <Standard_ConstructionError.hxx>
#include "utilities.h"
//======================================================================= //=======================================================================
//function : GetID //function : GetID
//purpose : //purpose :
@ -181,10 +186,142 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
} }
} }
else if (aType == DRAFT_PRISM_FEATURE) {
Handle(GEOM_Function) aRefInit = aCI.GetInitShape();
Handle(GEOM_Function) aRefBase = aCI.GetBase();
TopoDS_Shape anInitShape = aRefInit->GetValue(); // Initial shape
TopoDS_Shape aSketch = aRefBase->GetValue();
Standard_Real aHeight = aCI.GetH(); // Height of the extrusion
Standard_Real anAngle = aCI.GetDraftAngle(); // Draft angle
Standard_Boolean isProtrusion = (aCI.GetFuseFlag()==1);
// Flag to know wether the feature is a protrusion (fuse) or a depression (cut)
if (anInitShape.ShapeType() == TopAbs_COMPOUND)
{
TopExp_Explorer anExp(anInitShape, TopAbs_SOLID);
int solidCount = 0;
for(;anExp.More();anExp.Next())
{
solidCount++;
}
if (solidCount == 0)
{
Standard_ConstructionError::Raise("The input shape is a compound without any solid");
}
else if (solidCount > 1)
{
Standard_ConstructionError::Raise("The input shape is a compound with more than one solid");
}
}
TopoDS_Wire aWire = TopoDS_Wire();
if (aSketch.ShapeType() == TopAbs_EDGE)
{
aWire = BRepBuilderAPI_MakeWire(TopoDS::Edge(aSketch));
}
else if (aSketch.ShapeType() == TopAbs_WIRE)
{
aWire = TopoDS::Wire(aSketch);
}
else
{
Standard_ConstructionError::Raise("The input sketch is neither a wire nor an edge");
}
if (!aWire.Closed())
Standard_ConstructionError::Raise("The wire has to be closed");
// history of the Base wire (RefBase)
Handle(GEOM_Object) aSuppObj;
TDF_LabelSequence aLabelSeq;
aRefBase->GetDependency(aLabelSeq);
// If the base wire has only one dependency we use it
// to determine the right normal of the face which
// must be oriented towards outside of the solid (like the support face)
if (aLabelSeq.Length()==1)
{
TDF_Label anArgumentRefLabel = aLabelSeq.Value(1);
aSuppObj = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
}
// Construction of the face if the wire hasn't any support face
TopoDS_Face aFaceBase = BRepBuilderAPI_MakeFace(aWire);
if(!aSuppObj.IsNull()) // If the wire has a support
{
TopoDS_Shape aSupport = aSuppObj->GetValue();
if (aSupport.ShapeType() == TopAbs_FACE)
{
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aSupport));
TopoDS_Face aTempFace = BRepBuilderAPI_MakeFace(aSurf, aWire);
if(aTempFace.Orientation() != TopoDS::Face(aSupport).Orientation())
{
aFaceBase=TopoDS::Face(aTempFace.Reversed());
}
else
aFaceBase=aTempFace;
}
}
// Invert height and angle if the operation is an extruded cut
bool invert = !isProtrusion;
// If the face has a reverse orientation invert for extruded boss operations
if(aFaceBase.Orientation() == TopAbs_REVERSED)
invert = isProtrusion;
if(invert)
{
anAngle = -anAngle; // Invert angle and height
aHeight = -aHeight;
}
BRepFeat_MakeDPrism thePrism(anInitShape, aFaceBase, TopoDS_Face(),
anAngle*PI180, isProtrusion, Standard_True);
thePrism.Perform(aHeight);
aShape = thePrism.Shape();
}
if (aShape.IsNull()) return 0; if (aShape.IsNull()) return 0;
TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
aFunction->SetValue(aRes); if (aType == DRAFT_PRISM_FEATURE)
{
TopoDS_Shape aRes = aShape;
// If the result is a compound with only one solid,
// return the solid
if (aShape.ShapeType() == TopAbs_COMPOUND)
{
TopExp_Explorer anExp(aShape, TopAbs_SOLID);
int solidNb = 0;
TopoDS_Solid aSolid;
for(;anExp.More();anExp.Next())
{
aSolid = TopoDS::Solid(anExp.Current());
solidNb++;
}
if (solidNb == 1)
{
aRes = aSolid;
}
}
aFunction->SetValue(aRes);
}
else
{
TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
aFunction->SetValue(aRes);
}
log.SetTouched(Label()); log.SetTouched(Label());

View File

@ -96,6 +96,10 @@
#define GEOM_PROJECTION 45 #define GEOM_PROJECTION 45
#define GEOM_EXTRUDED_CUT 46
#define GEOM_EXTRUDED_BOSS 47
//GEOM_Function types //GEOM_Function types
#define COPY_WITH_REF 1 #define COPY_WITH_REF 1
@ -198,6 +202,7 @@
#define PRISM_BASE_TWO_PNT_2WAYS 4 #define PRISM_BASE_TWO_PNT_2WAYS 4
#define PRISM_BASE_DXDYDZ 5 #define PRISM_BASE_DXDYDZ 5
#define PRISM_BASE_DXDYDZ_2WAYS 6 #define PRISM_BASE_DXDYDZ_2WAYS 6
#define DRAFT_PRISM_FEATURE 7
#define REVOLUTION_BASE_AXIS_ANGLE 1 #define REVOLUTION_BASE_AXIS_ANGLE 1
#define REVOLUTION_BASE_AXIS_ANGLE_2WAYS 2 #define REVOLUTION_BASE_AXIS_ANGLE_2WAYS 2

View File

@ -705,6 +705,37 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakePrismDXDYDZWithScaling
return GetObject(anObject); return GetObject(anObject);
} }
//=============================================================================
/*!
* MakeDraftPrism
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeDraftPrism
(GEOM::GEOM_Object_ptr theInitShape, GEOM::GEOM_Object_ptr theBase,
CORBA::Double theHeight,
CORBA::Double theAngle,
CORBA::Boolean theFuse)
{
GEOM::GEOM_Object_var aGEOMObject;
//Set a not done flag
GetOperations()->SetNotDone();
//Get the reference objects
Handle(GEOM_Object) aInit = GetObjectImpl(theInitShape);
Handle(GEOM_Object) aBase = GetObjectImpl(theBase);
if (aBase.IsNull() || aInit.IsNull()) return aGEOMObject._retn();
//Create the Prism
Handle(GEOM_Object) anObject = GetOperations()->MakeDraftPrism(aInit, aBase, theHeight, theAngle, theFuse);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//============================================================================= //=============================================================================
/*! /*!
* MakePipe * MakePipe

View File

@ -139,6 +139,12 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i :
CORBA::Double theDZ, CORBA::Double theDZ,
CORBA::Double theScaleFactor); CORBA::Double theScaleFactor);
GEOM::GEOM_Object_ptr MakeDraftPrism (GEOM::GEOM_Object_ptr theInitShape,
GEOM::GEOM_Object_ptr theBase,
CORBA::Double theHeight,
CORBA::Double theAngle,
CORBA::Boolean theFuse);
GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase, GEOM::GEOM_Object_ptr MakePipe (GEOM::GEOM_Object_ptr theBase,
GEOM::GEOM_Object_ptr thePath); GEOM::GEOM_Object_ptr thePath);

View File

@ -63,7 +63,7 @@
## @defgroup l3_basic_op Basic Operations ## @defgroup l3_basic_op Basic Operations
## @defgroup l3_boolean Boolean Operations ## @defgroup l3_boolean Boolean Operations
## @defgroup l3_transform Transformation Operations ## @defgroup l3_transform Transformation Operations
## @defgroup l3_local Local Operations (Fillet and Chamfer) ## @defgroup l3_local Local Operations (Fillet, Chamfer and other Features)
## @defgroup l3_blocks_op Blocks Operations ## @defgroup l3_blocks_op Blocks Operations
## @defgroup l3_healing Repairing Operations ## @defgroup l3_healing Repairing Operations
## @defgroup l3_restore_ss Restore presentation parameters and a tree of sub-shapes ## @defgroup l3_restore_ss Restore presentation parameters and a tree of sub-shapes
@ -6223,6 +6223,64 @@ class geompyDC(GEOM._objref_GEOM_Gen):
anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape) anObj = self.MakeChamferFaces(aShape,d1,d2,ListShape)
return anObj return anObj
## Remove material from a solid by extrusion of the base shape on the given distance.
# @param theInit Shape to remove material from. It must be a solid or
# a compound made of a single solid.
# @param theBase Closed edge or wire defining the base shape to be extruded.
# @param theH Prism dimension along the normal to theBase
# @param theAngle Draft angle in degrees.
# @return New GEOM.GEOM_Object, containing the initial shape with removed material
#
# @ref tui_creation_prism "Example"
def MakeExtrudedCut(self, theInit, theBase, theH, theAngle):
"""
Add material to a solid by extrusion of the base shape on the given distance.
Parameters:
theInit Shape to remove material from. It must be a solid or a compound made of a single solid.
theBase Closed edge or wire defining the base shape to be extruded.
theH Prism dimension along the normal to theBase
theAngle Draft angle in degrees.
Returns:
New GEOM.GEOM_Object, containing the initial shape with removed material.
"""
# Example: see GEOM_TestAll.py
#theH,Parameters = ParseParameters(theH)
anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, False)
RaiseIfFailed("MakeExtrudedBoss", self.PrimOp)
#anObj.SetParameters(Parameters)
return anObj
## Add material to a solid by extrusion of the base shape on the given distance.
# @param theInit Shape to add material to. It must be a solid or
# a compound made of a single solid.
# @param theBase Closed edge or wire defining the base shape to be extruded.
# @param theH Prism dimension along the normal to theBase
# @param theAngle Draft angle in degrees.
# @return New GEOM.GEOM_Object, containing the initial shape with added material
#
# @ref tui_creation_prism "Example"
def MakeExtrudedBoss(self, theInit, theBase, theH, theAngle):
"""
Add material to a solid by extrusion of the base shape on the given distance.
Parameters:
theInit Shape to add material to. It must be a solid or a compound made of a single solid.
theBase Closed edge or wire defining the base shape to be extruded.
theH Prism dimension along the normal to theBase
theAngle Draft angle in degrees.
Returns:
New GEOM.GEOM_Object, containing the initial shape with added material.
"""
# Example: see GEOM_TestAll.py
#theH,Parameters = ParseParameters(theH)
anObj = self.PrimOp.MakeDraftPrism(theInit, theBase, theH, theAngle, True)
RaiseIfFailed("MakeExtrudedBoss", self.PrimOp)
#anObj.SetParameters(Parameters)
return anObj
# end of l3_local # end of l3_local
## @} ## @}

View File

@ -32,6 +32,7 @@ salomeinclude_HEADERS = \
OperationGUI_ChamferDlg.h \ OperationGUI_ChamferDlg.h \
OperationGUI_GetShapesOnShapeDlg.h \ OperationGUI_GetShapesOnShapeDlg.h \
OperationGUI_GetSharedShapesDlg.h \ OperationGUI_GetSharedShapesDlg.h \
OperationGUI_ExtrudedFeatureDlg.h \
OperationGUI_ClippingDlg.h OperationGUI_ClippingDlg.h
# Libraries targets # Libraries targets
@ -46,6 +47,7 @@ dist_libOperationGUI_la_SOURCES = \
OperationGUI_FilletDlg.cxx \ OperationGUI_FilletDlg.cxx \
OperationGUI_Fillet1d2dDlg.cxx \ OperationGUI_Fillet1d2dDlg.cxx \
OperationGUI_ChamferDlg.cxx \ OperationGUI_ChamferDlg.cxx \
OperationGUI_ExtrudedFeatureDlg.cxx \
OperationGUI_ClippingDlg.cxx OperationGUI_ClippingDlg.cxx
MOC_FILES = \ MOC_FILES = \
@ -56,6 +58,7 @@ MOC_FILES = \
OperationGUI_FilletDlg_moc.cxx \ OperationGUI_FilletDlg_moc.cxx \
OperationGUI_Fillet1d2dDlg_moc.cxx \ OperationGUI_Fillet1d2dDlg_moc.cxx \
OperationGUI_ChamferDlg_moc.cxx \ OperationGUI_ChamferDlg_moc.cxx \
OperationGUI_ExtrudedFeatureDlg_moc.cxx \
OperationGUI_ClippingDlg_moc.cxx OperationGUI_ClippingDlg_moc.cxx
nodist_libOperationGUI_la_SOURCES = \ nodist_libOperationGUI_la_SOURCES = \
@ -81,6 +84,7 @@ libOperationGUI_la_CPPFLAGS = \
-I$(srcdir)/../GEOMClient \ -I$(srcdir)/../GEOMClient \
-I$(srcdir)/../GEOMImpl \ -I$(srcdir)/../GEOMImpl \
-I$(srcdir)/../GEOMAlgo \ -I$(srcdir)/../GEOMAlgo \
-I$(srcdir)/../GEOM \
-I$(top_builddir)/src/DlgRef \ -I$(top_builddir)/src/DlgRef \
-I$(top_builddir)/idl -I$(top_builddir)/idl

View File

@ -43,6 +43,7 @@
#include "OperationGUI_ClippingDlg.h" // Clipping dialog box #include "OperationGUI_ClippingDlg.h" // Clipping dialog box
#include "OperationGUI_GetShapesOnShapeDlg.h" #include "OperationGUI_GetShapesOnShapeDlg.h"
#include "OperationGUI_GetSharedShapesDlg.h" #include "OperationGUI_GetSharedShapesDlg.h"
#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT
//======================================================================= //=======================================================================
// function : OperationGUI() // function : OperationGUI()
@ -81,6 +82,8 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
case GEOMOp::OpClipping: (new OperationGUI_ClippingDlg (getGeometryGUI(), parent))->show(); break; case GEOMOp::OpClipping: (new OperationGUI_ClippingDlg (getGeometryGUI(), parent))->show(); break;
case GEOMOp::OpShapesOnShape: (new OperationGUI_GetShapesOnShapeDlg(getGeometryGUI(), parent))->show(); break; case GEOMOp::OpShapesOnShape: (new OperationGUI_GetShapesOnShapeDlg(getGeometryGUI(), parent))->show(); break;
case GEOMOp::OpSharedShapes: (new OperationGUI_GetSharedShapesDlg (getGeometryGUI(), parent))->show(); break; case GEOMOp::OpSharedShapes: (new OperationGUI_GetSharedShapesDlg (getGeometryGUI(), parent))->show(); break;
case GEOMOp::OpExtrudedBoss: (new OperationGUI_ExtrudedFeatureDlg (BOSS, getGeometryGUI(), parent))->show(); break;
case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break;
case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break; case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break;
case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break; case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break;
default: default:

View File

@ -36,6 +36,8 @@
class OperationGUI : public GEOMGUI class OperationGUI : public GEOMGUI
{ {
public : public :
enum ExtrudedFeatOperation { CUT = 1, BOSS = 2 };
OperationGUI( GeometryGUI* ); OperationGUI( GeometryGUI* );
~OperationGUI(); ~OperationGUI();

View File

@ -0,0 +1,382 @@
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : OperationGUI_ExtrudedFeatureDlg.cxx
// Author : Renaud NEDELEC, Open CASCADE S.A.S.
#include "OperationGUI.h"
#include "OperationGUI_ExtrudedFeatureDlg.h"
#include <SUIT_Session.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <DlgRef.h>
#include <GEOM_Object.hxx>
// OCCT Includes
// #include <TopoDS_Shape.hxx>
// #include <TopoDS_Edge.hxx>
// #include <TopoDS.hxx>
// #include <TopExp.hxx>
// #include <TColStd_IndexedMapOfInteger.hxx>
// #include <TopTools_IndexedMapOfShape.hxx>
// #include <Precision.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <GEOMImpl_Types.hxx>
//=================================================================================
// class : OperationGUI_ExtrudedFeatureDlg()
// purpose : Constructs a OperationGUI_ExtrudedCutDlg which is a child of 'parent',
// with the name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
OperationGUI_ExtrudedFeatureDlg::OperationGUI_ExtrudedFeatureDlg(const int theOperation,
GeometryGUI* theGeometryGUI,
QWidget* parent,bool modal,
Qt::WindowFlags fl)
: GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
myOperation(theOperation)
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QPixmap image0;
QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICO_DRAFT")));
QString aTitle;
switch (myOperation)
{
case OperationGUI::BOSS:
image0 = QPixmap(aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_BOSS")));
aTitle = tr("GEOM_EXTRUDED_BOSS");
break;
case OperationGUI::CUT:
image0 = QPixmap( aResMgr->loadPixmap("GEOM", tr("ICO_EXTRUDED_CUT")));
aTitle = tr("GEOM_EXTRUDED_CUT");
break;
}
setWindowTitle(aTitle);
mainFrame()->GroupConstructors->setTitle(aTitle);
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->close();
mainFrame()->RadioButton1->setChecked(true);
myGroup = new DlgRef_2Sel2Spin1Push(centralWidget());
myGroup->PushButton1->setIcon(image1);
myGroup->PushButton2->setIcon(image1);
myGroup->PushButton3->setIcon(image2);
myGroup->LineEdit1->setReadOnly(true);
myGroup->LineEdit2->setReadOnly(true);
myGroup->TextLabel1->setText(tr("GEOM_INIT_SHAPE"));
myGroup->TextLabel2->setText(tr("GEOM_SKETCH"));
myGroup->TextLabel3->setText(tr("GEOM_HEIGHT"));
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0);
layout->setSpacing(6);
layout->addWidget(myGroup);
Init();
}
//=================================================================================
// function : ~OperationGUI_ExtrudedFeatureDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
OperationGUI_ExtrudedFeatureDlg::~OperationGUI_ExtrudedFeatureDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::Init()
{
// init variables
myEditCurrentArgument = myGroup->LineEdit1;
// Get setting of step value from file configuration
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
initSpinBox(myGroup->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
initSpinBox(myGroup->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
myGroup->LineEdit1->setText("");
myGroup->LineEdit2->setText("");
myGroup->SpinBox_DX->setValue(10.0);
myGroup->SpinBox_DY->setValue(10.0);
myGroup->SpinBox_DY->setEnabled(false);
myObject1.nullify();
myObject2.nullify();
// signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
connect(myGroup->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(myGroup->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(myGroup->PushButton3, SIGNAL(clicked(bool)), this, SLOT(ButtonClicked(bool)));
connect(myGroup->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(myGroup->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
initName(mainFrame()->GroupConstructors->title());
mainFrame()->RadioButton1->setFocus();
globalSelection(GEOM_ALLSHAPES); //TODO à changer
myGroup->PushButton1->click();
SelectionIntoArgument();
resize(minimumSizeHint());
}
//=================================================================================
// function : ClickOnOk()
// purpose :
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::ClickOnOk()
{
setIsApplyAndClose( true );
if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool OperationGUI_ExtrudedFeatureDlg::ClickOnApply()
{
if (!onAccept())
return false;
initName();
// activate selection and connect selection manager
myGroup->PushButton1->click();
return true;
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
if (send == myGroup->PushButton1) {
myEditCurrentArgument = myGroup->LineEdit1;
myGroup->PushButton2->setDown(false);
myGroup->LineEdit2->setEnabled(false);
}
else if (send == myGroup->PushButton2) {
myEditCurrentArgument = myGroup->LineEdit2;
myGroup->PushButton1->setDown(false);
myGroup->LineEdit1->setEnabled(false);
}
// enable line edit
myEditCurrentArgument->setEnabled(true);
myEditCurrentArgument->setFocus();
// after setFocus(), because it will be setDown(false) when loses focus
send->setDown(true);
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection is changed or on dialog initialization or activation
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("");
QList<TopAbs_ShapeEnum> types;
types<<TopAbs_SHAPE;
if (myEditCurrentArgument == myGroup->LineEdit1)
{
types.clear();
types<<TopAbs_COMPOUND<<TopAbs_SOLID;
}
if (myEditCurrentArgument == myGroup->LineEdit2)
{
types.clear();
types << TopAbs_EDGE << TopAbs_WIRE;
}
GEOM::GeomObjPtr aSelectedObject = getSelected( types );
TopoDS_Shape aShape;
if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
QString aName = GEOMBase::GetName( aSelectedObject.get() );
myEditCurrentArgument->setText( aName );
// clear selection
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
myGeomGUI->getApp()->selectionMgr()->clearSelected();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
if (myEditCurrentArgument == myGroup->LineEdit1) {
myObject1 = aSelectedObject;
if (!myObject2)
myGroup->PushButton2->click();
}
else if (myEditCurrentArgument == myGroup->LineEdit2) {
myObject2 = aSelectedObject;
if (!myObject1)
myGroup->PushButton1->click();
}
displayPreview(true);
}
else {
if (myEditCurrentArgument == myGroup->LineEdit1) myObject1.nullify();
else if (myEditCurrentArgument == myGroup->LineEdit2) myObject2.nullify();
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
this, SLOT( SelectionIntoArgument() ) );
processPreview();
}
//=================================================================================
// function : enterEvent()
// purpose : when mouse enter onto the QWidget
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::enterEvent (QEvent*)
{
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
// function : ValueChangedInSpinBox()
// purpose :
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::ValueChangedInSpinBox()
{
displayPreview(true);
}
//=================================================================================
// function : ButtonClicked(bool checked)
// purpose :
//=================================================================================
void OperationGUI_ExtrudedFeatureDlg::ButtonClicked(bool checked)
{
myGroup->SpinBox_DY->setEnabled(checked);
displayPreview(true);
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr OperationGUI_ExtrudedFeatureDlg::createOperation()
{
return getGeomEngine()->GetI3DPrimOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool OperationGUI_ExtrudedFeatureDlg::isValid (QString&)
{
return myObject1 && myObject2;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool OperationGUI_ExtrudedFeatureDlg::execute (ObjectList& objects)
{
// GEOM::GEOM_Object_var anObj;
GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());
double angle=0.0;
if (myGroup->PushButton3->isChecked())
angle=myGroup->SpinBox_DY->value();
bool isProtrusion = (myOperation == OperationGUI::BOSS);
GEOM::GEOM_Object_var anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),
myGroup->SpinBox_DX->value(),
angle,
isProtrusion);
// switch (myOperation)
// {
// case OperationGUI::BOSS:
// anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, true);
// break;
// case OperationGUI::CUT:
// anObj = anOper->MakeDraftPrism(myObject1.get(), myObject2.get(),myGroup->SpinBox_DX->value(),angle, false);
// break;
// }
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
return true;
}

View File

@ -0,0 +1,88 @@
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// 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
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : OperationGUI_ExtrudedFeatureDlg.h
// Author : Renaud NEDELEC, Open CASCADE S.A.S.
#ifndef BASICGUI_EXTRUDEDFEATUREDLG_H
#define BASICGUI_EXTRUDEDFEATUREDLG_H
#include "GEOMBase_Skeleton.h"
#include "GEOM_GenericObjPtr.h"
#include <QMap>
// class DlgRef_2Sel1Spin;
// class DlgRef_3Spin;
// class DlgRef_2Sel;
// class DlgRef_1Sel3Spin;
// class DlgRef_1Sel2Spin;
class DlgRef_2Sel2Spin1Push;
// class QLineEdit;
// class QGroupBox;
// class QButtonGroup;
// class QMenu;
class QAction;
//=================================================================================
// class : OperationGUI_ExtrudedFeatureDlg
// purpose :
//=================================================================================
class OperationGUI_ExtrudedFeatureDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
OperationGUI_ExtrudedFeatureDlg( const int, GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0 );
~OperationGUI_ExtrudedFeatureDlg();
protected:
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& );
private:
void Init();
void enterEvent( QEvent* );
private:
int myOperation;
GEOM::GeomObjPtr myObject1;
GEOM::GeomObjPtr myObject2;
DlgRef_2Sel2Spin1Push* myGroup;
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void SetEditCurrentArgument();
void SelectionIntoArgument();
void ValueChangedInSpinBox();
void ButtonClicked(bool);
};
#endif // BASICGUI_EXTRUDEDFEATUREDLG_H