if( myCurve->getSectionName(mySection) != aName.toStdString() )
myCurve->setSectionName( mySection , aName.toStdString() );
- if( myCurve->getSectionType(mySection) != aSectType )
+ bool isGeomModified = false;
+
+ if( myCurve->getSectionType(mySection) != aSectType ) {
myCurve->setSectionType( mySection, aSectType );
+ isGeomModified = true;
+ }
- if( myCurve->isClosed(mySection) != isClosed )
+ if( myCurve->isClosed(mySection) != isClosed ) {
myCurve->setClosed( mySection, isClosed );
+ isGeomModified = true;
+ }
mySectionView->sectionChanged(mySection);
updateUndoRedo();
onCancelSection();
+
+ emit curveModified();
}
void CurveCreator_Widget::onJoin()
if( aNewSectSize != aMainSectSize )
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onRemove()
mySectionView->reset();
updateActionsStates();
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onJoinAll()
mySectionView->reset();
updateActionsStates();
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onUndoSettings()
mySectionView->sectionChanged(aSelSections[i]);
}
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onSetPolyline()
mySectionView->sectionChanged( aSelSections[i] );
}
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onCloseSections()
mySectionView->sectionChanged(aSelSections[i]);
}
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onUncloseSections()
mySectionView->sectionChanged(aSelSections[i]);
}
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::onUndo()
{
- if( !myCurve )
- return;
+ if( !myCurve )
+ return;
+
+ CurveCreator_ICurve::SectionToPointList aPoints;
+ startCurveModification( aPoints, false );
+ myCurve->undo();
+ finishCurveModification();
+ mySectionView->reset();
- CurveCreator_ICurve::SectionToPointList aPoints;
- startCurveModification( aPoints, false );
- myCurve->undo();
- finishCurveModification();
- mySectionView->reset();
+ emit curveModified();
}
void CurveCreator_Widget::onRedo()
{
- if( !myCurve )
- return;
- CurveCreator_ICurve::SectionToPointList aPoints;
- startCurveModification( aPoints, false );
- myCurve->redo();
- finishCurveModification();
- mySectionView->reset();
+ if( !myCurve )
+ return;
+ CurveCreator_ICurve::SectionToPointList aPoints;
+ startCurveModification( aPoints, false );
+ myCurve->redo();
+ finishCurveModification();
+ mySectionView->reset();
+
+ emit curveModified();
}
void CurveCreator_Widget::updateUndoRedo()
// updates the input panel table to show the selected point coordinates
updateLocalPointView();
updateUndoRedo();
+
+ emit curveModified();
}
/**
myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos );
finishCurveModification( aSelPoints );
+
+ emit curveModified();
}
/**
}
mySectionView->clearSelection();
updateUndoRedo();
+
+ emit curveModified();
}
/**
myCurve->removeSeveralPoints( aPoints );
finishCurveModification( CurveCreator_ICurve::SectionToPointList() );
+
+ emit curveModified();
}
void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords)
mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) );
updateActionsStates();
updateUndoRedo();
+
+ emit curveModified();
}
void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
finishCurveModification( aSelPoints );
setSelectedPoints();
+
+ emit curveModified();
}
void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
myDragged = true;
finishCurveModification( myDragPoints );
+
+ emit curveModified();
}
void CurveCreator_Widget::updateLocalPointView()
(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
{
- QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_VECTOR_2P" ) ) );
+ QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_CC_POLYLINE" ) ) );
+
+ setWindowTitle(tr("POLYLINE_DLG_TITLE"));
/***************************************************************/
- mainFrame()->GroupConstructors->setTitle(tr("GEOM_VECTOR"));
+ mainFrame()->GroupConstructors->setTitle(tr("POLYLINE_TITLE"));
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton2->close();
myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
myEditorWidget = new CurveCreator_Widget (centralWidget(), myCurve);
- myAddElementBox = new QGroupBox (tr("ADD_ELEMENT"), centralWidget());
+ myAddElementBox = new QGroupBox (tr("POLYLINE_ADD_SECTION"), centralWidget());
QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
/***************************************************************/
- setHelpFileName( "create_vector_page.html" );
+ setHelpFileName( "create_polyline_page.html" );
/* Initialisations */
Init();
//=================================================================================
void EntityGUI_PolylineDlg::Init()
{
+ initName(tr("POLYLINE_NAME"));
+
SalomeApp_Application *anApp = myGeomGUI->getApp();
OCCViewer_ViewManager *aViewManager = dynamic_cast<OCCViewer_ViewManager*>
(anApp->getViewManager(OCCViewer_Viewer::Type(), true));
this, SLOT(processStartedSubOperation(QWidget*, bool)));
connect(myEditorWidget, SIGNAL(subOperationFinished(QWidget*)),
this, SLOT(processFinishedSubOperation(QWidget*)));
+ connect(myEditorWidget, SIGNAL(curveModified()),
+ this, SLOT(onUpdatePreview()));
+ connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
myAddElementBox->hide();
+
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : Clear
+// purpose :
+//=================================================================================
+void EntityGUI_PolylineDlg::Clear()
+{
+ delete myCurve;
+
+ myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
+ myEditorWidget->setCurve(myCurve);
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+void EntityGUI_PolylineDlg::GetCurveParams(GEOM::ListOfListOfDouble &theCoords,
+ GEOM::string_array &theNames,
+ GEOM::short_array &theTypes,
+ GEOM::ListOfBool &theCloseds)
+{
+ const int aNbSec = myCurve->getNbSections();
+ int i;
+ int j;
+
+ theCoords.length(aNbSec);
+ theNames.length(aNbSec);
+ theTypes.length(aNbSec);
+ theCloseds.length(aNbSec);
+
+ for (i = 0; i < aNbSec; ++i) {
+ // Set coordinates
+ CurveCreator::Coordinates aCoords = myCurve->getPoints(i);
+ const int aNbPoints = aCoords.size();
+
+ theCoords[i].length(aNbPoints);
+
+ for (j = 0; j < aNbPoints; ++j) {
+ theCoords[i][j] = aCoords[j];
+ }
+
+ // Set section type
+ const CurveCreator::SectionType aType = myCurve->getSectionType(i);
+
+ switch (aType) {
+ case CurveCreator::Spline:
+ theTypes[i] = GEOM::Interpolation;
+ break;
+ case CurveCreator::Polyline:
+ default:
+ theTypes[i] = GEOM::Polyline;
+ break;
+ }
+
+ // Set section names and closed flags.
+ theNames[i] = CORBA::string_dup(myCurve->getSectionName(i).c_str());
+ theCloseds[i] = myCurve->isClosed(i);
+ }
}
//=================================================================================
//=================================================================================
bool EntityGUI_PolylineDlg::execute( ObjectList& objects )
{
+ GEOM::GEOM_ICurvesOperations_var anOper =
+ GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
+
+ // Get the polyline creation parameters.
+ GEOM::ListOfListOfDouble aCoords;
+ GEOM::string_array aNames;
+ GEOM::short_array aTypes;
+ GEOM::ListOfBool aCloseds;
+
+ GetCurveParams(aCoords, aNames, aTypes, aCloseds);
+
+ // Temporary code: get Working Plane.
+ GEOM::GEOM_IBasicOperations_var aBasicOp = getGeomEngine()->GetIBasicOperations( getStudyId() );
+ GEOM::GEOM_Object_var aWPlane = aBasicOp->MakeMarker( 0,0,0,
+ 1,0,0,
+ 0,1,0 );
+
+ // Perform operation
+ GEOM::GEOM_Object_var anObj = anOper->MakePolyline2DOnPlane
+ (aCoords, aNames, aTypes, aCloseds, aWPlane);
+
+ if (!anObj->_is_nil()) {
+ objects.push_back(anObj._retn());
+ }
+
return true;
}
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void EntityGUI_PolylineDlg::ClickOnOk()
+{
+ setIsApplyAndClose( true );
+
+ if (ClickOnApply())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnApply()
+// purpose :
+//=================================================================================
+bool EntityGUI_PolylineDlg::ClickOnApply()
+{
+ if (!onAccept())
+ return false;
+
+ initName();
+
+ return true;
+}
+
+//=================================================================================
+// function : processStartedSubOperation
+// purpose :
+//=================================================================================
void EntityGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
{
myEditorWidget->setEnabled( false );
- myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
+ myAddElementBox->setTitle( theIsEdit ? tr( "POLYLINE_EDIT_SECTION" ) : tr( "POLYLINE_ADD_SECTION" ) );
QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
anAddElementLayout->addWidget( theWidget );
myAddElementBox->show();
}
+
+//=================================================================================
+// function : processFinishedSubOperation
+// purpose :
+//=================================================================================
void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
{
myEditorWidget->setEnabled( true );
myAddElementBox->hide();
}
-/**
- * Redirect the delete action to editor widget
- */
+//=================================================================================
+// function : execute
+// purpose : Redirect the delete action to editor widget
+//=================================================================================
void EntityGUI_PolylineDlg::deleteSelected()
{
myEditorWidget->removeSelected();
}
-/**
- * Checks whether there are some to delete
- */
+//=================================================================================
+// function : deleteEnabled
+// purpose : Checks whether there are some to delete
+//=================================================================================
bool EntityGUI_PolylineDlg::deleteEnabled()
{
return myEditorWidget->removeEnabled();
}
+
+//=================================================================================
+// function : SelectionIntoArgument
+// purpose : Called when selection is changed
+//=================================================================================
+void EntityGUI_PolylineDlg::SelectionIntoArgument()
+{
+/*
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_SHAPE );
+ TopoDS_Shape aShape;
+
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ if (aShape.ShapeType() == TopAbs_FACE) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myGroup->LineEdit1->setText( aName );
+
+ // clear selection
+ disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myGeomGUI->getApp()->selectionMgr()->clearSelected();
+ connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
+ this, SLOT(SelectionIntoArgument()));
+
+ myFace = aSelectedObject;
+ }
+ }
+
+ displayPreview(true);
+*/
+}
+
+//=================================================================================
+// function : ActivateThisDialog
+// purpose :
+//=================================================================================
+void EntityGUI_PolylineDlg::ActivateThisDialog()
+{
+ GEOMBase_Skeleton::ActivateThisDialog();
+
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void EntityGUI_PolylineDlg::enterEvent (QEvent*)
+{
+ if (!mainFrame()->GroupConstructors->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : onUpdatePreview
+// purpose :
+//=================================================================================
+void EntityGUI_PolylineDlg::onUpdatePreview()
+{
+ displayPreview(true);
+}