#include <OCCViewer_ViewPort3d.h>
#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewSketcher.h>
#include <GEOMBase.h>
#include <GeometryGUI.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <DlgRef.h>
+
#include <QKeyEvent>
#include <BRep_Tool.hxx>
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
setModal( modal );
setAttribute( Qt::WA_DeleteOnClose );
-
+
+ // Disable rectangular selection
+// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
+// ((OCCViewer_ViewWindow*)theViewWindow)->setEnabledDrawMode( false );
+// MESSAGE("((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode();"<<((OCCViewer_ViewWindow*)theViewWindow)->isEnabledDrawMode())
+// OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
+// vp->setSketchingEnabled( false );
+// MESSAGE("vp->isSketchingEnabled()"<<vp->isSketchingEnabled())
+// ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
+// OCCViewer_ViewSketcher* aViewSketcher = ((OCCViewer_ViewWindow*)theViewWindow)->getSketcher( OCCViewer_ViewWindow::Rect );
+// aViewSketcher->deactivate()
+// aViewSketcher->setVisible(false);
+
+// this->setMouseTracking(false);
+
myGeometryGUI->SetActiveDialogBox(this);
MainWidget = new EntityGUI_Skeleton( this );
planeLayout->setMargin(11);
ComboBox1 = new QComboBox(GroupBox1);
- //ComboBox1->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed) );
planeLayout->addWidget(ComboBox1,0,0,1,2);
planeButton = new QPushButton (GroupBox1);
- //planeButton->setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed));
planeButton->setText( tr( "GEOM_SKETCHER_RESTORE" ) );
planeLayout->addWidget(planeButton,0,2);
Group4Spin->checkBox->setText( tr( "GEOM_REVERSE" ) );
Group4Spin->buttonUndo->setIcon( image1 );
Group4Spin->buttonRedo->setIcon( image2 );
+
+ GroupRect = new DlgRef_4Spin( MainWidget->SkeletonCnt );
+ GroupRect->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
+ GroupRect->TextLabel1->setText("X1:");
+ GroupRect->TextLabel2->setText("Y1:");
+ GroupRect->TextLabel3->setText("X2:");
+ GroupRect->TextLabel4->setText("Y2:");
// Defines a palette for the error message on Group4Spin and Group2Sel
QPalette palette;
SkeletonCntlayout->addWidget( Group2Spin, 0, 0 );
SkeletonCntlayout->addWidget( Group3Spin, 0, 0 );
SkeletonCntlayout->addWidget( Group4Spin, 0, 0 );
+ SkeletonCntlayout->addWidget( GroupRect, 0, 0 );
//SkeletonCntlayout->setStretch( 0, 1);
/***************************************************************/
connect( Group4Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group4Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group4Spin->SpinBox_DS, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( GroupRect->SpinBox_DX1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( GroupRect->SpinBox_DX2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( GroupRect->SpinBox_DY1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
+ connect( GroupRect->SpinBox_DY2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
connect( Group3Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
connect( Group4Spin->checkBox, SIGNAL( stateChanged( int ) ), this, SLOT( CheckBoxClicked( int ) ) );
//=================================================================================
EntityGUI_SketcherDlg::~EntityGUI_SketcherDlg()
{
+// SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
+
myGeometryGUI->SetActiveDialogBox( 0 );
+// ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
}
GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
myGlobalCS = aBasicOp->MakeMarker( 0,0,0,
- 0,0,1,
- 1,0,0 );
+ 1,0,0,
+ 0,1,0 );
myWPlane = myGlobalCS;
myLCSList.push_back( WPlaneToLCS(myGlobalCS) );
initSpinBox( Group4Spin->SpinBox_DX, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
initSpinBox( Group4Spin->SpinBox_DY, COORD_MIN, COORD_MAX, 0.1, "length_precision" );
initSpinBox( Group4Spin->SpinBox_DS, COORD_MIN, COORD_MAX, 5., "length_precision" );
-
+
+ initSpinBox( GroupRect->SpinBox_DX1, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( GroupRect->SpinBox_DY1, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( GroupRect->SpinBox_DX2, COORD_MIN, COORD_MAX, step, "length_precision" );
+ initSpinBox( GroupRect->SpinBox_DY2, COORD_MIN, COORD_MAX, step, "length_precision" );
+
/* displays Dialog */
- MainWidget->GroupConstructors->setEnabled( false );
- MainWidget->GroupDest1->setEnabled( false );
+
+// MainWidget->RadioButton1->setEnabled( false );
+// MainWidget->RadioButton2->setEnabled( false );
+// MainWidget->RadioButton3->setEnabled( true );
+// MainWidget->GroupDest1->setEnabled( false );
setEnabledUndo( false );
setEnabledRedo( false );
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
+
+ OnFirstPoint();
+
SelectionIntoArgument();
resize(100,100);
setPrefix(tr("GEOM_SKETCH"));
ActivateLocalCS();
+
+ setIsWaitCursorEnabled( false );
GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
}
Group2Spin->hide();
Group3Spin->hide();
Group4Spin->hide();
+ GroupRect->hide();
globalSelection(); // close local selection to clear it
localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
}
void EntityGUI_SketcherDlg::TypeClicked( int constructorId )
{
myConstructorId = constructorId;
+ MainWidget->buttonEnd->setText(tr("GEOM_BUT_CLOSE"));
+ MainWidget->buttonClose->setEnabled(true);
+
if ( myConstructorId == 0 ) { // SEGMENT
GroupPt2->RB_Point1->setChecked( true );
+ GroupPt ->setEnabled( true );
GroupPt2->setEnabled( false );
+ GroupD1->setEnabled( true );
GroupD2->setEnabled( true );
MainWidget->RB_Dest1->setEnabled( true );
MainWidget->RB_Dest1->setChecked( true );
+
+ MainWidget->GroupDest ->setEnabled( true );
+ MainWidget->GroupDest1->setEnabled( true );
+ MainWidget->GroupDest ->show();
+ MainWidget->GroupDest1->show();
DestClicked( 1 );
+ if (mySketchState == FIRST_POINT)
+ {
+ OnFirstPoint();
+ }
}
else if ( myConstructorId == 1 ) { // ARC
+ GroupPt ->setEnabled( true );
GroupPt2->setEnabled( true );
GroupD2->RB_Dir21->setChecked( true );
+ GroupD1->setEnabled( true );
GroupD2->setEnabled( false );
MainWidget->RB_Dest1->setEnabled( true );
MainWidget->RB_Dest1->setChecked( true );
+
+ MainWidget->GroupDest ->setEnabled( true );
+ MainWidget->GroupDest1->setEnabled( true );
+ MainWidget->GroupDest ->show();
+ MainWidget->GroupDest1->show();
DestClicked( 1 );
+ if (mySketchState == FIRST_POINT)
+ {
+ OnFirstPoint();
+ }
}
+ else if ( myConstructorId == 2 ) { // RECTANGLE
+ GroupPt ->setEnabled( false );
+ GroupPt2->setEnabled( false );
+ GroupD1 ->setEnabled( false );
+ GroupD2 ->setEnabled( false );
+ MainWidget->GroupDest ->setEnabled( false );
+ MainWidget->GroupDest1->setEnabled( false );
+
+ GroupPt ->hide();
+ GroupPt2->hide();
+ GroupD1 ->hide();
+ GroupD2 ->hide();
+ MainWidget->GroupDest ->hide();
+ MainWidget->GroupDest1->hide();
+
+ MainWidget->buttonEnd->setText(tr("Apply and Close"));
+ MainWidget->buttonClose->setEnabled(false);
+
+ GroupRect->setEnabled( true );
+ MainWidget->RadioButton1->setEnabled( true );
+ MainWidget->RadioButton2->setEnabled( true );
+
+ RectClicked();
+ }
+}
+
+//=================================================================================
+// function : RectClicked()
+// purpose : Radio button management
+//=================================================================================
+void EntityGUI_SketcherDlg::RectClicked()
+{
+ InitClick();
+ GroupRect->show();
+
+ myX1=0;
+ myX2=10;
+ myY1=0;
+ myY2=10;
+
+ GroupRect->SpinBox_DX1->setValue(myX1);
+ GroupRect->SpinBox_DY1->setValue(myY1);
+ GroupRect->SpinBox_DX2->setValue(myX2);
+ GroupRect->SpinBox_DY2->setValue(myY2);
+
+ resize( minimumSizeHint() );
+
+ GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
}
myConstructorPntId = constructorId;
GroupPt->RB_Point3->setEnabled( true );
int buttonId = GroupPt2->ButtonGroup->checkedId();
- MESSAGE("checkedId ="<< buttonId)
if (buttonId >= 0){ // = If a button is checked
Point2Clicked(buttonId);
}
{
myConstructorDirId = constructorId;
int dirButtonId = GroupD2->ButtonGroup->checkedId();
- MESSAGE("checkedId ="<< dirButtonId)
if (dirButtonId >= 0){ // = If a button is checked
Dir2Clicked(dirButtonId);
}
//=================================================================================
void EntityGUI_SketcherDlg::ClickOnEnd()
{
+ MESSAGE("EntityGUI_SketcherDlg::ClickOnEnd()")
if ( sender() == MainWidget->buttonClose ) {
// Verify validity of commands
if ( myCommand.count() <= 2 ) {
( Group1Sel1Spin->buttonApply->isEnabled() && Group1Sel1Spin->isVisible() ) ) {
ClickOnApply();
}*/
+// ClickOnApply(); // TEST remove then
myIsAllAdded = true;
}
+ if (myConstructorId == 2)
+ {
+ QString aParameters;
+ myCommand.append( GetNewCommand( aParameters ) );
+ mySketchState = NEXT_POINT;
+ if ( onAccept() )
+ ClickOnCancel();
+ }
if ( myCommand.size() > 2 )
+ {
if ( !onAccept() )
return;
+ }
close();
}
//=================================================================================
bool EntityGUI_SketcherDlg::ClickOnApply()
{
+ MESSAGE("EntityGUI_SketcherDlg::ClickOnApply()")
if ( sender() && sender()->inherits( "QPushButton" ) )
( (QPushButton*)sender() )->setFocus(); // to update value of currently edited spin-box (PAL11948)
QString aParameters;
myCommand.append( GetNewCommand( aParameters ) );
- mySketchState = NEXT_POINT;
+ if (mySketchState == FIRST_POINT)
+ {
+ mySketchState = NEXT_POINT;
+ OnNextPoint();
+ }
myUndoCommand.clear();
myUndoCommand.append( "Sketcher" );
myParameters.append( aParameters );
myUndoParameters.clear();
- MainWidget->GroupConstructors->setEnabled( true );
- MainWidget->GroupDest1->setEnabled( true );
setEnabledUndo( true );
setEnabledRedo( false );
connect( myGeometryGUI->getApp()->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
- MainWidget->GroupConstructors->setEnabled( false );
- MainWidget->GroupDest1->setEnabled( false );
+ OnFirstPoint();
+
setEnabledUndo( false );
}
myUndoParameters.pop_back();
mySketchState = NEXT_POINT;
-
- MainWidget->GroupConstructors->setEnabled( true );
- MainWidget->GroupDest1->setEnabled( true );
+
+ OnNextPoint();
+
setEnabledUndo( true );
if ( myUndoCommand.count() == 1 )
// function : OnPointSelected
// purpose :
//=================================================================================
-void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
+void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt,
+ bool isStart )
{
- MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
-
SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
+
QString theImgFileName;
vp->background().texture( theImgFileName ); ////////////// VSR: temporarily
Group4Spin->buttonApply->setFocus();
break;
}
+ if ( myConstructorId == 2 ) //RECTANGLE
+ {
+ if (isStart)
+ {
+ GroupRect->SpinBox_DX1->setValue( aTrsfPnt.X() );
+ GroupRect->SpinBox_DY1->setValue( aTrsfPnt.Y() );
+ GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
+ GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
+ }
+ else
+ {
+ GroupRect->SpinBox_DX2->setValue( aTrsfPnt.X() );
+ GroupRect->SpinBox_DY2->setValue( aTrsfPnt.Y() );
+ }
+ }
+}
+
+//=================================================================================
+// function : OnFirstPoint
+// purpose :
+//=================================================================================
+void EntityGUI_SketcherDlg::OnFirstPoint()
+{
+ MainWidget->RadioButton3->setEnabled( true );
+ MainWidget->GroupDest1->setEnabled( false );
+ GroupPt2->setEnabled( false );
+}
+
+//=================================================================================
+// function : OnNextPoint
+// purpose :
+//=================================================================================
+void EntityGUI_SketcherDlg::OnNextPoint()
+{
+ MainWidget->RadioButton3->setEnabled( false );
+ MainWidget->GroupDest1->setEnabled( true );
+ TypeClicked(myConstructorId);
}
//=================================================================================
//=================================================================================
void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
{
- MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
QObject* send = (QObject*)sender();
Standard_Real vx, vy, vz, vs, minRad, dx, dy;
vx = vy = vz = vs = minRad = dx = dy = 0.0;
myLengthStr = vsStr;
}
}
+ else if ( myConstructorId == 2 ) { // RECTANGLE
+ myX1 = GroupRect->SpinBox_DX1->value(); myX1Str = GroupRect->SpinBox_DX1->text();
+ myX2 = GroupRect->SpinBox_DX2->value(); myX2Str = GroupRect->SpinBox_DX2->text();
+ myY1 = GroupRect->SpinBox_DY1->value(); myY1Str = GroupRect->SpinBox_DY1->text();
+ myY2 = GroupRect->SpinBox_DY2->value(); myY2Str = GroupRect->SpinBox_DY2->text();
+ }
+
if (!autoApply)
GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
myNewCommand = myNewCommand + "F " + QString::number( myDX, Format, DigNum ) + " " + QString::number( myDY, Format, DigNum );
theParameters = myDXStr + ":" + myDYStr;
}
- return myNewCommand;
+ if (myConstructorId == 2 )
+ myNewCommand = ":";
+ else
+ return myNewCommand;
}
if ( myConstructorId == 0 ) { // SEGMENT
theParameters = myDXStr + ":" + myDYStr + ":" + myRadiusStr + ":" + myLengthStr;
}
}
+ else if ( myConstructorId == 2 ) { // RECTANGLE
+ myNewCommand = myNewCommand + "F " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
+ + ":TT " + QString::number( myX1, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
+ + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY2, Format, DigNum)
+ + ":TT " + QString::number( myX2, Format, DigNum) + " " + QString::number( myY1, Format, DigNum)
+ + ":WW";
+
+ theParameters = myX1Str + ":" + myY1Str + ":" + myX2Str + ":" + myY2Str ;
+ }
return myNewCommand;
}
//=================================================================================
bool EntityGUI_SketcherDlg::execute( ObjectList& objects )
{
+ MESSAGE("EntityGUI_SketcherDlg::execute")
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
int DigNum = qAbs(aPrecision); // options for the format of numbers in myNewCommand
return;
// Build prs
- getDisplayer()->SetColor( line_color );
+ if( myConstructorId != 2)
+ getDisplayer()->SetColor( line_color );
+ else
+ getDisplayer()->SetColor( Quantity_NOC_VIOLET );
+
SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
if ( aPrs != 0 && !aPrs->IsNull() )
GEOMBase_Helper::displayPreview( aPrs, append, update );
getDisplayer()->SetColor( Quantity_NOC_VIOLET );
+
aPrs = getDisplayer()->BuildPrs( aLastSegment );
if ( aPrs != 0 && !aPrs->IsNull() )
GEOMBase_Helper::displayPreview( aPrs, append, update );
//=================================================================================
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()
+ return ( (getPnt1ConstructorId() == 1
+ || getPnt1ConstructorId() == 0
+ || myConstructorId == 2) //accept mouse event only on absolute and relative selection mode
+ && !WPlaneLineEdit->isEnabled()); //or when the constructor is rectangle
+ //called by EntityGUI::OnMousePress()
}
//=================================================================================
//=================================================================================
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);
//=================================================================================
void EntityGUI_SketcherDlg::FindLocalCS()
{
- MESSAGE("EntityGUI_SketcherDlg::FindLocalCS")
ComboBox1->clear();
myWPlaneList.clear();
SalomeApp_Application* app =
myWPlaneList.push_back(geomObj);
myLCSList.push_back(WPlaneToLCS(geomObj));
ComboBox1->addItem(geomObj->GetName());
- MESSAGE("ComboBox1->addItem() in EntityGUI_SketcherDlg::FindLocalCS()")
}
}
}
//=================================================================================
gp_Ax3 EntityGUI_SketcherDlg::GetActiveLocalCS()
{
- MESSAGE("EntityGUI_SketcherDlg::GetActiveLocalCS()")
int ind = ComboBox1->currentIndex();
if (ind == -1)
return myGeometryGUI->GetWorkingPlane();
//=================================================================================
void EntityGUI_SketcherDlg::ActivateLocalCS()
{
- MESSAGE("EntityGUI_SketcherDlg::ActivateLocalCS")
myGeometryGUI->SetWorkingPlane( GetActiveLocalCS() );
myGeometryGUI->ActiveWorkingPlane();
}
//=================================================================================
void EntityGUI_SketcherDlg::addSubshapesToStudy()
{
- MESSAGE("EntityGUI_SketcherDlg::addSubshapesToStudy()")
GEOMBase::PublishSubObject(myWPlane);
-}
\ No newline at end of file
+}