Starting of 'Modification' mode develoment.

This commit is contained in:
akl 2013-10-30 14:37:13 +00:00
parent 26c427c3c2
commit d6378dbcb1
3 changed files with 99 additions and 47 deletions

View File

@ -30,6 +30,7 @@
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include <QMouseEvent> #include <QMouseEvent>
#include <QApplication>
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
CurveCreator_Curve *theCurve, CurveCreator_Curve *theCurve,
@ -44,7 +45,7 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
aDim = myCurve->getDimension(); aDim = myCurve->getDimension();
myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this ); myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this );
myNewPointEditor->hide(); myNewPointEditor->hide();
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()) ); // connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()) );
connect( myNewPointEditor, SIGNAL(modifyPoint()), this, SLOT(onModifyPoint()) ); connect( myNewPointEditor, SIGNAL(modifyPoint()), this, SLOT(onModifyPoint()) );
connect( myNewPointEditor, SIGNAL(cancelPoint()), this, SLOT(onCancelPoint()) ); connect( myNewPointEditor, SIGNAL(cancelPoint()), this, SLOT(onCancelPoint()) );
@ -117,17 +118,17 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) ); QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );
connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) ); connect(anAct, SIGNAL(triggered()), this, SLOT(onInsertSectionAfter()) );
anAct = createAction( CREATION_MODE_ID, tr("CREATION_MODE"), aNewPointPixmap, tr("CREATION_MODE_TLT"), anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"),
QKeySequence() ); QKeySequence() );
anAct->setCheckable(true); anAct->setCheckable(true);
connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onNewPoint(bool)) ); connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onAdditionMode(bool)) );
connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
aTB->addAction(anAct); aTB->addAction(anAct);
anAct = createAction( EDITION_MODE_ID, tr("EDITION_MODE"), anEditPointsPixmap, tr("EDITION_MODE_TLT"), anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"),
QKeySequence() ); QKeySequence() );
anAct->setCheckable(true); anAct->setCheckable(true);
connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onEditPoints(bool)) ); connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onModificationMode(bool)) );
connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) ); connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
aTB->addAction(anAct); aTB->addAction(anAct);
@ -238,9 +239,9 @@ void CurveCreator_Widget::onSelectionChanged()
anEnabledAct << UP_ID; anEnabledAct << UP_ID;
}*/ }*/
if( aSelSections.size() == 1 ){ if( aSelSections.size() == 1 ){
anEnabledAct << CREATION_MODE_ID << EDITION_MODE_ID << DETECTION_MODE_ID; anEnabledAct << ADDITION_MODE_ID << MODIFICATION_MODE_ID << DETECTION_MODE_ID;
} }
if (myActionMap[CREATION_MODE_ID]->isChecked()) { if (myActionMap[ADDITION_MODE_ID]->isChecked()) {
mySection = -1; mySection = -1;
myPointNum = -1; myPointNum = -1;
QList<int> aSelSection = mySectionView->getSelectedSections(); QList<int> aSelSection = mySectionView->getSelectedSections();
@ -248,7 +249,7 @@ void CurveCreator_Widget::onSelectionChanged()
mySection = aSelSection[0]; mySection = aSelSection[0];
myPointNum = myCurve->getNbPoints(mySection); myPointNum = myCurve->getNbPoints(mySection);
} }
} else if (myActionMap[EDITION_MODE_ID]->isChecked()) { } else if (myActionMap[MODIFICATION_MODE_ID]->isChecked()) {
anEnabledAct << REMOVE_ID; anEnabledAct << REMOVE_ID;
anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID; anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
int aSectCnt = myCurve->getNbSections(); int aSectCnt = myCurve->getNbSections();
@ -309,7 +310,7 @@ void CurveCreator_Widget::onSelectionChanged()
emit selectionChanged(); emit selectionChanged();
} }
void CurveCreator_Widget::onNewPoint(bool checked) void CurveCreator_Widget::onAdditionMode(bool checked)
{ {
if( !myEdit ) if( !myEdit )
return; return;
@ -321,13 +322,14 @@ void CurveCreator_Widget::onNewPoint(bool checked)
if ( aViewWindow == 0 ) if ( aViewWindow == 0 )
return; return;
SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) { if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
if (checked) { if (checked) {
connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) ); this, SLOT( onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ) ) );
} else { } else {
disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ), disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) ); this, SLOT( onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ) ) );
return; return;
} }
} }
@ -345,6 +347,7 @@ void CurveCreator_Widget::onNewPoint(bool checked)
myPointNum = aSelPoints[0].second + 1; myPointNum = aSelPoints[0].second + 1;
} }
} }
/*
QString aSectName; QString aSectName;
if( mySection < 0 ){ if( mySection < 0 ){
mySection = myCurve->getNbSections() - 1; mySection = myCurve->getNbSections() - 1;
@ -357,12 +360,34 @@ void CurveCreator_Widget::onNewPoint(bool checked)
myNewPointEditor->setEditMode(false); myNewPointEditor->setEditMode(false);
myNewPointEditor->setSectionName(aSectName); myNewPointEditor->setSectionName(aSectName);
myNewPointEditor->setDimension(myCurve->getDimension()); myNewPointEditor->setDimension(myCurve->getDimension());
*/
// emit subOperationStarted( myNewPointEditor ); // emit subOperationStarted( myNewPointEditor );
} }
void CurveCreator_Widget::onEditPoints(bool checked) void CurveCreator_Widget::onModificationMode(bool checked)
{ {
SUIT_ViewWindow* aViewWindow = 0;
SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
if ( activeStudy )
aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
if ( aViewWindow == 0 )
return;
SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
if (checked) {
// connect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ),
// this, SLOT( onPointSelect( SUIT_ViewWindow*, QMouseEvent* ) ) );
connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onPointDrag( SUIT_ViewWindow*, QMouseEvent* ) ) );
}
else {
// disconnect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ),
// this, SLOT( onPointSelect( SUIT_ViewWindow*, QMouseEvent* ) ) );
disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onPointDrag( SUIT_ViewWindow*, QMouseEvent* ) ) );
return;
}
}
} }
void CurveCreator_Widget::onDetectPoints(bool checked) void CurveCreator_Widget::onDetectPoints(bool checked)
@ -374,37 +399,37 @@ void CurveCreator_Widget::onModeChanged(bool checked)
if (checked) { if (checked) {
QAction* anAction = (QAction*)sender(); QAction* anAction = (QAction*)sender();
switch(myActionMap.key(anAction)) { switch(myActionMap.key(anAction)) {
case CREATION_MODE_ID: case ADDITION_MODE_ID:
if (myActionMap[EDITION_MODE_ID]->isChecked()) if (myActionMap[MODIFICATION_MODE_ID]->isChecked())
myActionMap[EDITION_MODE_ID]->trigger(); myActionMap[MODIFICATION_MODE_ID]->trigger();
else if (myActionMap[DETECTION_MODE_ID]->isChecked()) else if (myActionMap[DETECTION_MODE_ID]->isChecked())
myActionMap[DETECTION_MODE_ID]->trigger(); myActionMap[DETECTION_MODE_ID]->trigger();
break; break;
case EDITION_MODE_ID: case MODIFICATION_MODE_ID:
if (myActionMap[CREATION_MODE_ID]->isChecked()) if (myActionMap[ADDITION_MODE_ID]->isChecked())
myActionMap[CREATION_MODE_ID]->trigger(); myActionMap[ADDITION_MODE_ID]->trigger();
else if (myActionMap[DETECTION_MODE_ID]->isChecked()) else if (myActionMap[DETECTION_MODE_ID]->isChecked())
myActionMap[DETECTION_MODE_ID]->trigger(); myActionMap[DETECTION_MODE_ID]->trigger();
break; break;
case DETECTION_MODE_ID: case DETECTION_MODE_ID:
if (myActionMap[CREATION_MODE_ID]->isChecked()) if (myActionMap[ADDITION_MODE_ID]->isChecked())
myActionMap[CREATION_MODE_ID]->trigger(); myActionMap[ADDITION_MODE_ID]->trigger();
else if (myActionMap[EDITION_MODE_ID]->isChecked()) else if (myActionMap[MODIFICATION_MODE_ID]->isChecked())
myActionMap[EDITION_MODE_ID]->trigger(); myActionMap[MODIFICATION_MODE_ID]->trigger();
break; break;
} }
} }
onSelectionChanged(); onSelectionChanged();
} }
void CurveCreator_Widget::onAddNewPoint() void CurveCreator_Widget::onAddNewPoint(const CurveCreator::Coordinates& theCoords)
{ {
if( !myEdit ) if( !myEdit )
return; return;
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates(); // CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
myEdit->insertPoints(aCoords, mySection, myPointNum ); myEdit->insertPoints(theCoords, mySection, myPointNum );
mySectionView->pointsAdded( mySection, myPointNum ); mySectionView->pointsAdded( mySection, myPointNum );
myNewPointEditor->clear(); // myNewPointEditor->clear();
myPointNum++; myPointNum++;
onSelectionChanged(); onSelectionChanged();
updateUndoRedo(); updateUndoRedo();
@ -832,10 +857,10 @@ void CurveCreator_Widget::setInstantSketchingEnabled( const bool theState )
} }
//================================================================================= //=================================================================================
// function : GeometryGUI::OnMousePress() // function : GeometryGUI::onGetPointByClick()
// purpose : Manage mouse press events [static] // purpose : Manage mouse press events in Additon mode
//================================================================================= //=================================================================================
void CurveCreator_Widget::onMousePress( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe ) void CurveCreator_Widget::onGetPointByClick( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
{ {
if ( myNewPointEditor && theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() && if ( myNewPointEditor && theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
pe->modifiers() != Qt::ControlModifier ) { pe->modifiers() != Qt::ControlModifier ) {
@ -851,7 +876,7 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow* theViewWindow, QMouseEv
else else
ic->Select(); // New selection ic->Select(); // New selection
TopoDS_Shape aShape; /*TopoDS_Shape aShape;
ic->InitSelected(); ic->InitSelected();
if ( ic->MoreSelected() ) if ( ic->MoreSelected() )
@ -859,7 +884,8 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow* theViewWindow, QMouseEv
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX ) if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) ); aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
else { else*/
{
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() ); aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
} }
@ -870,6 +896,28 @@ void CurveCreator_Widget::onMousePress( SUIT_ViewWindow* theViewWindow, QMouseEv
if ( myCurve->getDimension() == 3 ) { if ( myCurve->getDimension() == 3 ) {
aCoords.push_back( aPnt.Z() ); aCoords.push_back( aPnt.Z() );
} }
myNewPointEditor->setCoordinates( aCoords ); onAddNewPoint(aCoords);
// myNewPointEditor->setCoordinates( aCoords );
} }
} }
//=================================================================================
// function : GeometryGUI::onPointDrag()
// purpose : Manage mouse move events in Modification mode
//=================================================================================
void CurveCreator_Widget::onPointDrag( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
{
if ( !(pe->buttons() & Qt::LeftButton) )
return;
if ( (pe->pos() - myDragStartPosition).manhattanLength() < QApplication::startDragDistance() )
return;
/*
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
mimeData->setData(mimeType, data);
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
*/
}

View File

@ -2,6 +2,7 @@
#define CURVECREATOR_WIDGET_H #define CURVECREATOR_WIDGET_H
#include "CurveCreator_Curve.hxx" #include "CurveCreator_Curve.hxx"
#include "CurveCreator.hxx"
#include <QWidget> #include <QWidget>
#include <QMap> #include <QMap>
@ -39,13 +40,13 @@ signals:
public slots: public slots:
protected slots: protected slots:
void onNewPoint(bool checked); void onAdditionMode(bool checked);
void onEditPoints(bool checked); void onModificationMode(bool checked);
void onDetectPoints(bool checked); void onDetectPoints(bool checked);
void onModeChanged(bool checked); void onModeChanged(bool checked);
void onNewSection(); void onNewSection();
void onSelectionChanged(); void onSelectionChanged();
void onAddNewPoint(); void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
void onAddNewSection(); void onAddNewSection();
void onEditSection( int theSection ); void onEditSection( int theSection );
void onEditPoint( int theSection, int thePoint ); void onEditPoint( int theSection, int thePoint );
@ -71,13 +72,15 @@ protected slots:
void onRedo(); void onRedo();
void onUndoSettings(); void onUndoSettings();
void onContextMenu(QPoint thePoint); void onContextMenu(QPoint thePoint);
void onMousePress( SUIT_ViewWindow*, QMouseEvent* ); void onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* );
// void onPointSelect( SUIT_ViewWindow*, QMouseEvent* );
void onPointDrag( SUIT_ViewWindow*, QMouseEvent* );
protected: protected:
enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, CREATION_MODE_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID, enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, ADDITION_MODE_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,
JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID, JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,
INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID, INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_ID, CLOSE_SECTIONS_ID, UNCLOSE_SECTIONS_ID,
SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID, SET_SECTIONS_POLYLINE_ID, SET_SECTIONS_SPLINE_ID, CLEAR_ALL_ID, SEPARATOR_ID,
EDITION_MODE_ID, DETECTION_MODE_ID }; MODIFICATION_MODE_ID, DETECTION_MODE_ID };
private: private:
QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage, QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
const QString& theToolTip, const QKeySequence& theShortcut ); const QString& theToolTip, const QKeySequence& theShortcut );
@ -92,6 +95,7 @@ private:
CurveCreator_NewSectionDlg* myNewSectionEditor; CurveCreator_NewSectionDlg* myNewSectionEditor;
int mySection; int mySection;
int myPointNum; int myPointNum;
QPoint myDragStartPosition;
}; };
#endif // CURVECREATOR_WIDGET_H #endif // CURVECREATOR_WIDGET_H

View File

@ -5320,20 +5320,20 @@ Ignoring units will cause model scaling (as dimensions are supposed to be specif
<translation>Insert section after</translation> <translation>Insert section after</translation>
</message> </message>
<message> <message>
<source>CREATION_MODE</source> <source>ADDITION_MODE</source>
<translation>Creation mode</translation> <translation>Addition mode</translation>
</message> </message>
<message> <message>
<source>CREATION_MODE_TLT</source> <source>ADDITION_MODE_TLT</source>
<translation>Creation mode</translation> <translation>Addition mode</translation>
</message> </message>
<message> <message>
<source>EDITION_MODE</source> <source>MODIFICATION_MODE</source>
<translation>Edition mode</translation> <translation>Modification mode</translation>
</message> </message>
<message> <message>
<source>EDITION_MODE_TLT</source> <source>MODIFICATION_MODE_TLT</source>
<translation>Edition mode</translation> <translation>Modification mode</translation>
</message> </message>
<message> <message>
<source>DETECTION_MODE</source> <source>DETECTION_MODE</source>