X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FCurveCreator%2FCurveCreator_Widget.cxx;h=8a7feb465f0b3c1df3bec85855ce94e5866a8435;hb=c4999d16551e5ac1eae8329faf1ab65cf023a844;hp=0bbccc6a12c610c234b88e21f13de5e25c214d8c;hpb=5488595c4524089e729eabd422c65185b4b0ad14;p=modules%2Fgeom.git diff --git a/src/CurveCreator/CurveCreator_Widget.cxx b/src/CurveCreator/CurveCreator_Widget.cxx index 0bbccc6a1..8a7feb465 100644 --- a/src/CurveCreator/CurveCreator_Widget.cxx +++ b/src/CurveCreator/CurveCreator_Widget.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -19,8 +19,6 @@ #include "CurveCreator_Widget.h" #include "CurveCreator_TreeView.h" -#include "CurveCreator_ICurve.hxx" -#include "CurveCreator.hxx" #include "CurveCreator_NewSectionDlg.h" #include "CurveCreator_Utils.hxx" #include "CurveCreator_UtilsICurve.hxx" @@ -48,6 +46,9 @@ #include #include #include +#include + +#include //#define MEASURE_TIME @@ -79,11 +80,10 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, CurveCreator_ICurve *theCurve, const int theActionFlags, const QStringList& theCoordTitles, - Qt::WindowFlags fl, - int theLocalPointRowLimit ) + Qt::WindowFlags fl ) : QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0), myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ), - myOCCViewer( 0 ), myLocalPointRowLimit( theLocalPointRowLimit ), + myOCCViewer( 0 ), myOld2DMode(OCCViewer_ViewWindow::No2dMode) { bool isToEnableClosed = !( theActionFlags & DisableClosedSection ); @@ -119,6 +119,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE"))); QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE"))); QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN"))); + QPixmap aBringTogetherPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_BRING_TOGETHER"))); QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP"))); QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN"))); @@ -161,9 +162,9 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, anAct->setCheckable(true); connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onDetectionMode(bool)) ); connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); - if ( !(theActionFlags & DisableDetectionMode) ) { - aTB->addAction(anAct); - } +// if ( !(theActionFlags & DisableDetectionMode) ) { +// aTB->addAction(anAct); +// } anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_W) ); @@ -182,18 +183,23 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, tr("SET_SECTIONS_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) ); connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) ); + aTB->addSeparator(); + anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) ); connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) ); aTB->addAction(anAct); - aTB->addSeparator(); - anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) ); connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) ); aTB->addAction(anAct); + anAct = createAction( BRING_TOGETHER_ID, tr("BRING_TOGETHER"), aBringTogetherPixmap, tr("BRING_TOGETHER_TLT"), + QKeySequence(Qt::ControlModifier|Qt::Key_Equal ) ); + connect( anAct, SIGNAL(triggered()), this, SLOT(onBringTogether()) ); + aTB->addAction(anAct); + anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) ); connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) ); @@ -206,8 +212,14 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, aSectLayout->setMargin( 5 ); aSectLayout->setSpacing( 5 ); aSectLayout->addWidget(aTB); - aSectLayout->addWidget(mySectionView); - aSectLayout->addWidget( myLocalPointView ); + + QSplitter* aSplitter = new QSplitter(aSectionGroup); + aSplitter->setOrientation(Qt::Vertical); + + aSplitter->addWidget(mySectionView); + aSplitter->addWidget( myLocalPointView ); + + aSectLayout->addWidget(aSplitter); aSectionGroup->setLayout(aSectLayout); QVBoxLayout* aLay = new QVBoxLayout(); aLay->setMargin( 0 ); @@ -378,7 +390,7 @@ void CurveCreator_Widget::updateActionsStates() if( aSectCnt > 1 ) anEnabledAct << JOIN_ALL_ID; if( aSelSections.size() > 1 ){ - anEnabledAct << JOIN_ID; + anEnabledAct << JOIN_ID << BRING_TOGETHER_ID; } } break; @@ -941,7 +953,7 @@ void CurveCreator_Widget::SetViewer2DMode(const bool To2D) //================================================================================= // function : GeometryGUI::addCoordsByClick() -// purpose : Manage mouse press events in Additon mode +// purpose : Manage mouse press events in Addition mode //================================================================================= void CurveCreator_Widget::addCoordsByClick( QMouseEvent* pe ) { @@ -969,6 +981,68 @@ void CurveCreator_Widget::addCoordsByClick( QMouseEvent* pe ) } } +/** + * Set the same coordinates on two section extremities. + * Usage: build a closed contour with several sections. + * Works with two points selected, at the extremities of different sections. + * The second point gets the coordinates of the first. + */ +void CurveCreator_Widget::onBringTogether() +{ + MESSAGE("onBringTogether"); + ActionMode aMode = getActionMode(); + if ( aMode != ModificationMode ) + return; + int nbPoints = myLocalPoints.size(); + MESSAGE("number of selected points: " << nbPoints); + if (nbPoints != 2) + { + MESSAGE("works only with two points taken at the extremities of different sections, nothing done"); + return; + } + + CurveCreator_ICurve::SectionToPointList::const_iterator anIt = myLocalPoints.begin(), + aLast = myLocalPoints.end(); + std::vector sections(nbPoints); + std::vector iPoints(nbPoints); + std::vector nbPtsSection(nbPoints); + std::vector x(nbPoints); + std::vector y(nbPoints); + int i = 0; + for ( ; anIt != aLast; anIt++, i++ ) + { + CurveCreator_ICurve::SectionToPoint aSPoint = *anIt; + sections[i] = aSPoint.first; + iPoints[i] = aSPoint.second; + nbPtsSection[i] = myCurve->getNbPoints(sections[i]); + if ((iPoints[i] != 0) && (iPoints[i] != nbPtsSection[i]-1)) + { + MESSAGE("a point is not on a section extremity, nothing done"); + return; + } + gp_Pnt aPoint; + CurveCreator_UtilsICurve::getPoint( myCurve, sections[i], iPoints[i], aPoint ); + x[i] = aPoint.X(); + y[i] = aPoint.Y(); + MESSAGE("point: " << sections[i] << " " << iPoints[i] << " " << x[i] << " " << y[i]); + } + if (sections[1] == sections[0]) + { + MESSAGE("the two points must be at the extremities of different sections, nothing done"); + return; + } + + CurveCreator_ICurve::SectionToPointList aSelPoints; + startCurveModification( aSelPoints ); + + CurveCreator::Coordinates aChangedPos; + aChangedPos.push_back( x[0] ); // apply the first point coordinates to the second point. + aChangedPos.push_back( y[0] ); + myCurve->setPoint( sections[1], iPoints[1], aChangedPos ); + + finishCurveModification( aSelPoints ); +} + /** * Manage mouse press events * \param theWindow an owner of the signal @@ -1015,7 +1089,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven { Handle(AIS_InteractiveContext) aCtx = getAISContext(); if ( !aCtx.IsNull() ) - aCtx->ClearSelected(); + aCtx->ClearSelected( Standard_True ); } return; } @@ -1046,11 +1120,11 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven // otherwise a rectangular selection. if ( myStartPoint == myEndPoint ) { - aCtx->MoveTo( myEndPoint.x(), myEndPoint.y(), aView3d ); + aCtx->MoveTo( myEndPoint.x(), myEndPoint.y(), aView3d, Standard_True ); if ( aHasShift ) - aCtx->ShiftSelect(); + aCtx->ShiftSelect( Standard_True ); else - aCtx->Select(); + aCtx->Select( Standard_True ); } else { @@ -1385,16 +1459,16 @@ void CurveCreator_Widget::updateLocalPointView() CurveCreator_Utils::getSelectedPoints( aContext, myCurve, myLocalPoints ); int aNbPoints = myLocalPoints.size(); - bool isRowLimit = aNbPoints > myLocalPointRowLimit; - myLocalPointView->setVisible( getActionMode() == ModificationMode && !isRowLimit ); + //bool isRowLimit = aNbPoints > myLocalPointRowLimit; + myLocalPointView->setVisible( getActionMode() == ModificationMode/* && !isRowLimit */); - if ( !isRowLimit ) { - bool isBlocked = myLocalPointView->blockSignals(true); + //if ( !isRowLimit ) { + bool isBlocked = myLocalPointView->blockSignals(true); - myLocalPointView->setLocalPointsToTable( myLocalPoints ); + myLocalPointView->setLocalPointsToTable( myLocalPoints ); - myLocalPointView->blockSignals( isBlocked ); - } + myLocalPointView->blockSignals( isBlocked ); + //} } /** @@ -1516,7 +1590,7 @@ void CurveCreator_Widget::convert( const CurveCreator_ICurve::SectionToPointList } /** - * Returns whethe the container has the value + * Returns whether the container has the value * \param theList a container of values * \param theValue a value */