mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-13 02:00:35 +05:00
curve creator: bring together two extremities of two sections of polylines
This commit is contained in:
parent
a9bed41d00
commit
9613091414
@ -281,6 +281,7 @@ SET( _res_files
|
|||||||
closedspline.png
|
closedspline.png
|
||||||
edit_points.png
|
edit_points.png
|
||||||
join2.png
|
join2.png
|
||||||
|
bringTogether.png
|
||||||
new_point.png
|
new_point.png
|
||||||
new_section.png
|
new_section.png
|
||||||
# ADVANCED_RESOURCES:
|
# ADVANCED_RESOURCES:
|
||||||
|
BIN
resources/bringTogether.png
Normal file
BIN
resources/bringTogether.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 645 B |
@ -50,6 +50,8 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
|
|
||||||
|
#include <utilities.h>
|
||||||
|
|
||||||
//#define MEASURE_TIME
|
//#define MEASURE_TIME
|
||||||
|
|
||||||
#ifdef MEASURE_TIME
|
#ifdef MEASURE_TIME
|
||||||
@ -120,6 +122,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
|||||||
QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
||||||
QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
|
QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
|
||||||
QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN")));
|
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 aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
|
||||||
QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
|
QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
|
||||||
|
|
||||||
@ -183,18 +186,23 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
|||||||
tr("SET_SECTIONS_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
tr("SET_SECTIONS_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
||||||
|
|
||||||
|
aTB->addSeparator();
|
||||||
|
|
||||||
anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"),
|
anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"),
|
||||||
QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
||||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
||||||
aTB->addAction(anAct);
|
aTB->addAction(anAct);
|
||||||
|
|
||||||
aTB->addSeparator();
|
|
||||||
|
|
||||||
anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
|
anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
|
||||||
QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
||||||
aTB->addAction(anAct);
|
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"),
|
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"),
|
||||||
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
||||||
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
||||||
@ -385,7 +393,7 @@ void CurveCreator_Widget::updateActionsStates()
|
|||||||
if( aSectCnt > 1 )
|
if( aSectCnt > 1 )
|
||||||
anEnabledAct << JOIN_ALL_ID;
|
anEnabledAct << JOIN_ALL_ID;
|
||||||
if( aSelSections.size() > 1 ){
|
if( aSelSections.size() > 1 ){
|
||||||
anEnabledAct << JOIN_ID;
|
anEnabledAct << JOIN_ID << BRING_TOGETHER_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -976,6 +984,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();
|
||||||
|
int sections[nbPoints];
|
||||||
|
int iPoints[nbPoints];
|
||||||
|
int nbPtsSection[nbPoints];
|
||||||
|
double x[nbPoints];
|
||||||
|
double 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) and (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
|
* Manage mouse press events
|
||||||
* \param theWindow an owner of the signal
|
* \param theWindow an owner of the signal
|
||||||
|
@ -115,6 +115,7 @@ protected slots:
|
|||||||
void onModifySection();
|
void onModifySection();
|
||||||
void onCancelSection();
|
void onCancelSection();
|
||||||
void onJoin();
|
void onJoin();
|
||||||
|
void onBringTogether();
|
||||||
void onRemove();
|
void onRemove();
|
||||||
void onClearAll();
|
void onClearAll();
|
||||||
void onJoinAll();
|
void onJoinAll();
|
||||||
@ -158,7 +159,8 @@ protected:
|
|||||||
CLEAR_ALL_ID,
|
CLEAR_ALL_ID,
|
||||||
SEPARATOR_ID,
|
SEPARATOR_ID,
|
||||||
MODIFICATION_MODE_ID,
|
MODIFICATION_MODE_ID,
|
||||||
DETECTION_MODE_ID
|
DETECTION_MODE_ID,
|
||||||
|
BRING_TOGETHER_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
<source>ICON_CC_JOIN</source>
|
<source>ICON_CC_JOIN</source>
|
||||||
<translation>join2.png</translation>
|
<translation>join2.png</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>ICON_CC_BRING_TOGETHER</source>
|
||||||
|
<translation>bringTogether.png</translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>ICON_CC_NEW_POINT</source>
|
<source>ICON_CC_NEW_POINT</source>
|
||||||
<translation>new_point.png</translation>
|
<translation>new_point.png</translation>
|
||||||
|
@ -5914,8 +5914,16 @@ shells and solids on the other hand.</translation>
|
|||||||
<message>
|
<message>
|
||||||
<source>JOIN_TLT</source>
|
<source>JOIN_TLT</source>
|
||||||
<translation>Join selected sections</translation>
|
<translation>Join selected sections</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>BRING_TOGETHER</source>
|
||||||
|
<translation>Bring together</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
|
<source>BRING_TOGETHER_TLT</source>
|
||||||
|
<translation>Bring together two points on the extremities of two sections</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
<source>CLEAR_ALL</source>
|
<source>CLEAR_ALL</source>
|
||||||
<translation>Clear all</translation>
|
<translation>Clear all</translation>
|
||||||
</message>
|
</message>
|
||||||
|
Loading…
Reference in New Issue
Block a user