mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-07 15:54:19 +05:00
Implementation of polyline dialog (not complete)
This commit is contained in:
parent
0f38ceb7f9
commit
37fd7c3872
@ -604,14 +604,22 @@ void CurveCreator_Widget::onModifySection()
|
||||
if( myCurve->getSectionName(mySection) != aName.toStdString() )
|
||||
myCurve->setSectionName( mySection , aName.toStdString() );
|
||||
|
||||
if( myCurve->getSectionType(mySection) != aSectType )
|
||||
myCurve->setSectionType( mySection, aSectType );
|
||||
bool isGeomModified = false;
|
||||
|
||||
if( myCurve->isClosed(mySection) != isClosed )
|
||||
if( myCurve->getSectionType(mySection) != aSectType ) {
|
||||
myCurve->setSectionType( mySection, aSectType );
|
||||
isGeomModified = true;
|
||||
}
|
||||
|
||||
if( myCurve->isClosed(mySection) != isClosed ) {
|
||||
myCurve->setClosed( mySection, isClosed );
|
||||
isGeomModified = true;
|
||||
}
|
||||
mySectionView->sectionChanged(mySection);
|
||||
updateUndoRedo();
|
||||
onCancelSection();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onJoin()
|
||||
@ -645,6 +653,8 @@ void CurveCreator_Widget::onJoin()
|
||||
if( aNewSectSize != aMainSectSize )
|
||||
mySectionView->pointsAdded( aMainSect, aMainSectSize, aNewSectSize-aMainSectSize );*/
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onRemove()
|
||||
@ -673,6 +683,8 @@ void CurveCreator_Widget::onClearAll()
|
||||
mySectionView->reset();
|
||||
updateActionsStates();
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onJoinAll()
|
||||
@ -690,6 +702,8 @@ void CurveCreator_Widget::onJoinAll()
|
||||
mySectionView->reset();
|
||||
updateActionsStates();
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onUndoSettings()
|
||||
@ -708,6 +722,8 @@ void CurveCreator_Widget::onSetSpline()
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onSetPolyline()
|
||||
@ -721,6 +737,8 @@ void CurveCreator_Widget::onSetPolyline()
|
||||
mySectionView->sectionChanged( aSelSections[i] );
|
||||
}
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onCloseSections()
|
||||
@ -734,6 +752,8 @@ void CurveCreator_Widget::onCloseSections()
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onUncloseSections()
|
||||
@ -747,6 +767,8 @@ void CurveCreator_Widget::onUncloseSections()
|
||||
mySectionView->sectionChanged(aSelSections[i]);
|
||||
}
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onUndo()
|
||||
@ -759,6 +781,8 @@ void CurveCreator_Widget::onUndo()
|
||||
myCurve->undo();
|
||||
finishCurveModification();
|
||||
mySectionView->reset();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onRedo()
|
||||
@ -770,6 +794,8 @@ void CurveCreator_Widget::onRedo()
|
||||
myCurve->redo();
|
||||
finishCurveModification();
|
||||
mySectionView->reset();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::updateUndoRedo()
|
||||
@ -1075,6 +1101,8 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEven
|
||||
// updates the input panel table to show the selected point coordinates
|
||||
updateLocalPointView();
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1142,6 +1170,8 @@ void CurveCreator_Widget::onCellChanged( int theRow, int theColumn )
|
||||
myCurve->setPoint( aCurrSect, aPntIndex, aChangedPos );
|
||||
|
||||
finishCurveModification( aSelPoints );
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1159,6 +1189,8 @@ void CurveCreator_Widget::removeSection()
|
||||
}
|
||||
mySectionView->clearSelection();
|
||||
updateUndoRedo();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1176,6 +1208,8 @@ void CurveCreator_Widget::removePoint()
|
||||
|
||||
myCurve->removeSeveralPoints( aPoints );
|
||||
finishCurveModification( CurveCreator_ICurve::SectionToPointList() );
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::addNewPoint(const CurveCreator::Coordinates& theCoords)
|
||||
@ -1191,6 +1225,8 @@ 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,
|
||||
@ -1257,6 +1293,8 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
|
||||
finishCurveModification( aSelPoints );
|
||||
|
||||
setSelectedPoints();
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
|
||||
@ -1304,6 +1342,8 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
|
||||
|
||||
myDragged = true;
|
||||
finishCurveModification( myDragPoints );
|
||||
|
||||
emit curveModified();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::updateLocalPointView()
|
||||
|
@ -97,6 +97,7 @@ signals:
|
||||
void selectionChanged();
|
||||
void subOperationStarted( QWidget*, bool );
|
||||
void subOperationFinished( QWidget* );
|
||||
void curveModified();
|
||||
|
||||
public slots:
|
||||
|
||||
|
@ -43,10 +43,12 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
|
||||
(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();
|
||||
@ -55,7 +57,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
|
||||
|
||||
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 );
|
||||
|
||||
@ -71,7 +73,7 @@ EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
setHelpFileName( "create_vector_page.html" );
|
||||
setHelpFileName( "create_polyline_page.html" );
|
||||
|
||||
/* Initialisations */
|
||||
Init();
|
||||
@ -92,6 +94,8 @@ EntityGUI_PolylineDlg::~EntityGUI_PolylineDlg()
|
||||
//=================================================================================
|
||||
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));
|
||||
@ -102,8 +106,74 @@ void EntityGUI_PolylineDlg::Init()
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -130,14 +200,69 @@ bool EntityGUI_PolylineDlg::isValid( QString& msg )
|
||||
//=================================================================================
|
||||
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 );
|
||||
|
||||
@ -145,6 +270,11 @@ void EntityGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool
|
||||
myAddElementBox->show();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : processFinishedSubOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
|
||||
{
|
||||
myEditorWidget->setEnabled( true );
|
||||
@ -156,18 +286,79 @@ void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
|
||||
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);
|
||||
}
|
||||
|
@ -60,11 +60,39 @@ protected:
|
||||
private:
|
||||
|
||||
void Init();
|
||||
void Clear();
|
||||
void enterEvent(QEvent *);
|
||||
|
||||
/**
|
||||
* This method converts the curve into curve parameters required to
|
||||
* construct an object using the interface
|
||||
* GEOM_ICurvesOperations::MakePolyline2DOnPlane.
|
||||
*
|
||||
* \param theCurve a curve object, that contains data.
|
||||
* \param theCoordsList the list of coordinates list. theCoordsList[0]
|
||||
* is the coordinates list of the first section. theCoordsList[1]
|
||||
* is for the second section etc. Output parameter.
|
||||
* \param theNamesList the list of names. The order corresponds to
|
||||
* theCoordsList. Output parameter.
|
||||
* \param theTypesList the list of curve types. The order corresponds to
|
||||
* theCoordsList. Output parameter.
|
||||
* \param theClosedList the list of Closed flags. The order corresponds to
|
||||
* theCoordsList. Output parameter.
|
||||
*/
|
||||
void GetCurveParams(GEOM::ListOfListOfDouble &theCoords,
|
||||
GEOM::string_array &theNames,
|
||||
GEOM::short_array &theTypes,
|
||||
GEOM::ListOfBool &theCloseds);
|
||||
|
||||
protected slots:
|
||||
|
||||
void ClickOnOk();
|
||||
bool ClickOnApply();
|
||||
void processStartedSubOperation( QWidget*, bool );
|
||||
void processFinishedSubOperation( QWidget* );
|
||||
void SelectionIntoArgument();
|
||||
void ActivateThisDialog();
|
||||
void onUpdatePreview();
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user