-// GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// GEOM GEOMGUI : GUI for Geometry component
// File : BasicGUI_WorkingPlaneDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
//
-
#include "BasicGUI_WorkingPlaneDlg.h"
-#include <GEOM_DlgRef.h>
+#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <TColStd_MapOfInteger.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
// QT Includes
#include <QCheckBox>
//=================================================================================
BasicGUI_WorkingPlaneDlg::BasicGUI_WorkingPlaneDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
bool modal, Qt::WindowFlags fl )
- : GEOMBase_Skeleton( theGeometryGUI, parent, "BasicGUI_WorkingPlaneDlg", modal, fl )
+ : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_WPLANE_FACE" ) ) );
Group2->PushButton2->setIcon( image0 );
Group2->LineEdit1->setReadOnly( true );
Group2->LineEdit2->setReadOnly( true );
+ Group2->PushButton1->setDown( true );
+ Group2->LineEdit1->setEnabled( true );
+ Group2->LineEdit2->setEnabled( false );
Group3 = new DlgRef_3Check( centralWidget() );
/***************************************************************/
QGroupBox* aReverseGroupBox = new QGroupBox( centralWidget() );
QHBoxLayout* aReverseGroupBoxLayout = new QHBoxLayout( aReverseGroupBox );
- aReverseGroupBoxLayout->setMargin( 9 );
+ aReverseGroupBoxLayout->setMargin( 9 );
aReverseGroupBoxLayout->setSpacing( 6 );
-
+
myReverseCB = new QCheckBox( aReverseGroupBox );
myReverseCB->setText( tr( "GEOM_REVERSE_PLANE" ) );
aReverseGroupBoxLayout->addWidget( myReverseCB );
-
+
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( Group1 );
layout->addWidget( Group2 );
layout->addWidget( Group3 );
layout->addWidget( aReverseGroupBox );
-
- setHelpFileName( "working_plane.htm" );
+
+ setHelpFileName( "create_wplane_page.html" );
Init();
}
initName( tr( "GEOM_WPLANE" ) );
- ConstructorsClicked( 0 );
+ setConstructorId( 2 ); // simplest constructor
+ ConstructorsClicked( 2 );
}
//=================================================================================
switch ( constructorId ) {
case 0:
{
- //globalSelection( GEOM_PLANE );
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_PLANE );
aMap.Add( GEOM_MARKER );
globalSelection( aMap );
-
Group2->hide();
Group3->hide();
Group1->show();
-
+ Group1->PushButton1->setDown(true);
myEditCurrentArgument = Group1->LineEdit1;
Group1->LineEdit1->setText( "" );
myFace = GEOM::GEOM_Object::_nil();
-
+
connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break;
}
case 1:
{
globalSelection( GEOM_LINE );
-
Group1->hide();
Group3->hide();
Group2->show();
-
myEditCurrentArgument = Group2->LineEdit1;
Group2->LineEdit1->setText( "" );
Group2->LineEdit2->setText( "" );
+ Group2->PushButton1->setDown( true );
+ Group2->PushButton2->setDown( false );
+ Group2->LineEdit1->setEnabled( true );
+ Group2->LineEdit2->setEnabled( false );
myVectX = GEOM::GEOM_Object::_nil();
myVectZ = GEOM::GEOM_Object::_nil();
-
+
connect( aSelMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
break;
}
Group1->hide();
Group2->hide();
Group3->show();
-
Group3->RadioButton1->setChecked( true );
aOriginType = 1;
break;
}
}
-
+
qApp->processEvents();
updateGeometry();
resize( minimumSize() );
{
buttonApply()->setFocus();
myGeomGUI->application()->putInfo( "" );
-
+
if ( updateWPlane( false ) ) {
myGeomGUI->SetWorkingPlane( myWPlane );
myGeomGUI->ActiveWorkingPlane();
}
-
+
return true;
}
void BasicGUI_WorkingPlaneDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText( "" );
+ QString aName;
+
+ LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
+ SALOME_ListIO aSelList;
+ aSelMgr->selectedObjects(aSelList);
const int id = getConstructorId();
- if ( IObjectCount() != 1 ) {
+ if (aSelList.Extent() != 1) {
if ( id == 0 )
myFace = GEOM::GEOM_Object::_nil();
else if ( id == 1 ) {
// nbSel == 1
Standard_Boolean aRes = Standard_False;
- GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), aRes );
+ GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aRes);
if ( !aRes || CORBA::is_nil( aSelectedObject ) )
return;
+ aName = GEOMBase::GetName(aSelectedObject);
+
if ( myEditCurrentArgument == Group1->LineEdit1 )
myFace = aSelectedObject;
- else if ( myEditCurrentArgument == Group2->LineEdit1 )
+ else if ( myEditCurrentArgument == Group2->LineEdit1 ||
+ myEditCurrentArgument == Group2->LineEdit2 ) {
+ if ( aRes && !aSelectedObject->_is_nil() ) {
+ TopoDS_Shape aShape;
+ if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) {
+ TColStd_IndexedMapOfInteger aMap;
+ aSelMgr->GetIndexes(aSelList.First(), aMap);
+ if ( aMap.Extent() == 1 ) {
+ int anIndex = aMap( 1 );
+ aName = aName + ":edge_" + QString::number( anIndex );
+
+ GEOM::GEOM_IShapesOperations_var aShapesOp =
+ getGeomEngine()->GetIShapesOperations( getStudyId() );
+ if ( myEditCurrentArgument == Group2->LineEdit1 )
+ myVectX = aShapesOp->GetSubShape( aSelectedObject, anIndex );
+ else
+ myVectZ = aShapesOp->GetSubShape( aSelectedObject, anIndex );
+ }
+ else {
+ if ( aShape.ShapeType() != TopAbs_EDGE ) {
+ aSelectedObject = GEOM::GEOM_Object::_nil();
+ aName = "";
+ }
+ }
+ aSelMgr->clearSelected();
+ }
+ }
+ }
+
+ myEditCurrentArgument->setText( aName );
+
+ if ( myEditCurrentArgument == Group2->LineEdit1 ) {
myVectX = aSelectedObject;
- else if ( myEditCurrentArgument == Group2->LineEdit2 )
+ if ( !myVectX->_is_nil() && myVectZ->_is_nil() )
+ Group2->PushButton2->click();
+ }
+ else {
myVectZ = aSelectedObject;
+ if ( !myVectZ->_is_nil() && myVectX->_is_nil() )
+ Group2->PushButton1->click();
+ }
- myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
-
updateWPlane();
}
}
else if ( send == Group2->PushButton1 ) {
myEditCurrentArgument = Group2->LineEdit1;
+ GEOM::GEOM_Object_var anObj;
+ // localSelection( anObj, TopAbs_EDGE );
globalSelection( GEOM_LINE );
+ Group2->PushButton2->setDown( false );
+ Group2->LineEdit1->setEnabled( true );
+ Group2->LineEdit2->setEnabled( false );
}
else if ( send == Group2->PushButton2 ) {
myEditCurrentArgument = Group2->LineEdit2;
+ GEOM::GEOM_Object_var anObj;
+ // localSelection( anObj, TopAbs_EDGE );
globalSelection( GEOM_LINE );
+ Group2->PushButton1->setDown( false );
+ Group2->LineEdit1->setEnabled( false );
+ Group2->LineEdit2->setEnabled( true );
}
myEditCurrentArgument->setFocus();
- SelectionIntoArgument();
+ // SelectionIntoArgument();
+ send->setDown(true);
+ displayPreview();
}
ActivateThisDialog();
}
-//=================================================================================
-// function : closeEvent
-// purpose :
-//=================================================================================
-void BasicGUI_WorkingPlaneDlg::closeEvent( QCloseEvent* e )
-{
- GEOMBase_Skeleton::closeEvent( e );
-}
-
-
//=================================================================================
// function : updateWPlane
// purpose :
bool BasicGUI_WorkingPlaneDlg::updateWPlane( const bool showPreview )
{
erasePreview();
-
+
const int id = getConstructorId();
if ( id == 0 ) { // by planar face selection
gp_Dir aDirN ( Zx, Zy, Zz );
gp_Dir aDirX ( Xx, Xy, Xz );
myWPlane = gp_Ax3( aPnt, aDirN, aDirX );
- }
+ }
else {
if ( !showPreview )
showError( "Wrong shape selected (has to be a planar face)" );
return false;
}
- }
+ }
else if ( id == 1 ) { // by two vectors (Ox & Oz)
if ( CORBA::is_nil( myVectX ) || CORBA::is_nil( myVectZ ) ) {
if ( !showPreview )
showError( "Two vectors have to be selected" );
return false;
}
-
+
TopoDS_Edge aVectX, aVectZ;
TopoDS_Vertex VX1, VX2, VZ1, VZ2;
gp_Vec aVX, aVZ;
myWPlane = gp_Ax3( BRep_Tool::Pnt( VX1 ), aDirZ, aDirX );
- }
+ }
else if ( id == 2 ) { // by selection from standard (OXY or OYZ, or OZX)
gp_Ax2 anAx2;
myWPlane = gp_Ax3( anAx2 );
- }
+ }
else {
return false;
}
-
+
if ( myReverseCB->isChecked() ) {
myWPlane.YReverse();
myWPlane.ZReverse();
}
-
+
if ( showPreview ) {
GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
- GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker( myWPlane.Location().X(), myWPlane.Location().Y(), myWPlane.Location().Z(),
- myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(),
- myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z() );
+ GEOM::GEOM_Object_var anObj = aBasicOp->MakeMarker
+ ( myWPlane.Location().X(), myWPlane.Location().Y(), myWPlane.Location().Z(),
+ myWPlane.XDirection().X(), myWPlane.XDirection().Y(), myWPlane.XDirection().Z(),
+ myWPlane.YDirection().X(), myWPlane.YDirection().Y(), myWPlane.YDirection().Z() );
displayPreview( anObj );
}
-
+
return true;
}