#include <QAction>
#include <QMenu>
#include <QMouseEvent>
+#include <QApplication>
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
CurveCreator_Curve *theCurve,
aDim = myCurve->getDimension();
myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this );
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(cancelPoint()), this, SLOT(onCancelPoint()) );
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Insert ) );
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() );
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)) );
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() );
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)) );
aTB->addAction(anAct);
anEnabledAct << UP_ID;
}*/
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;
myPointNum = -1;
QList<int> aSelSection = mySectionView->getSelectedSections();
mySection = aSelSection[0];
myPointNum = myCurve->getNbPoints(mySection);
}
- } else if (myActionMap[EDITION_MODE_ID]->isChecked()) {
+ } else if (myActionMap[MODIFICATION_MODE_ID]->isChecked()) {
anEnabledAct << REMOVE_ID;
anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
int aSectCnt = myCurve->getNbSections();
emit selectionChanged();
}
-void CurveCreator_Widget::onNewPoint(bool checked)
+void CurveCreator_Widget::onAdditionMode(bool checked)
{
if( !myEdit )
return;
if ( aViewWindow == 0 )
return;
SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
+
if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
if (checked) {
connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
- this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ this, SLOT( onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ) ) );
} else {
disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
- this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ this, SLOT( onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* ) ) );
return;
}
}
myPointNum = aSelPoints[0].second + 1;
}
}
+/*
QString aSectName;
if( mySection < 0 ){
mySection = myCurve->getNbSections() - 1;
myNewPointEditor->setEditMode(false);
myNewPointEditor->setSectionName(aSectName);
myNewPointEditor->setDimension(myCurve->getDimension());
-
+*/
// 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)
if (checked) {
QAction* anAction = (QAction*)sender();
switch(myActionMap.key(anAction)) {
- case CREATION_MODE_ID:
- if (myActionMap[EDITION_MODE_ID]->isChecked())
- myActionMap[EDITION_MODE_ID]->trigger();
+ case ADDITION_MODE_ID:
+ if (myActionMap[MODIFICATION_MODE_ID]->isChecked())
+ myActionMap[MODIFICATION_MODE_ID]->trigger();
else if (myActionMap[DETECTION_MODE_ID]->isChecked())
myActionMap[DETECTION_MODE_ID]->trigger();
break;
- case EDITION_MODE_ID:
- if (myActionMap[CREATION_MODE_ID]->isChecked())
- myActionMap[CREATION_MODE_ID]->trigger();
+ case MODIFICATION_MODE_ID:
+ if (myActionMap[ADDITION_MODE_ID]->isChecked())
+ myActionMap[ADDITION_MODE_ID]->trigger();
else if (myActionMap[DETECTION_MODE_ID]->isChecked())
myActionMap[DETECTION_MODE_ID]->trigger();
break;
case DETECTION_MODE_ID:
- if (myActionMap[CREATION_MODE_ID]->isChecked())
- myActionMap[CREATION_MODE_ID]->trigger();
- else if (myActionMap[EDITION_MODE_ID]->isChecked())
- myActionMap[EDITION_MODE_ID]->trigger();
+ if (myActionMap[ADDITION_MODE_ID]->isChecked())
+ myActionMap[ADDITION_MODE_ID]->trigger();
+ else if (myActionMap[MODIFICATION_MODE_ID]->isChecked())
+ myActionMap[MODIFICATION_MODE_ID]->trigger();
break;
}
}
onSelectionChanged();
}
-void CurveCreator_Widget::onAddNewPoint()
+void CurveCreator_Widget::onAddNewPoint(const CurveCreator::Coordinates& theCoords)
{
if( !myEdit )
return;
- CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
- myEdit->insertPoints(aCoords, mySection, myPointNum );
+// CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
+ myEdit->insertPoints(theCoords, mySection, myPointNum );
mySectionView->pointsAdded( mySection, myPointNum );
- myNewPointEditor->clear();
+// myNewPointEditor->clear();
myPointNum++;
onSelectionChanged();
updateUndoRedo();
}
//=================================================================================
-// function : GeometryGUI::OnMousePress()
-// purpose : Manage mouse press events [static]
+// function : GeometryGUI::onGetPointByClick()
+// 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() &&
pe->modifiers() != Qt::ControlModifier ) {
else
ic->Select(); // New selection
- TopoDS_Shape aShape;
+ /*TopoDS_Shape aShape;
ic->InitSelected();
if ( ic->MoreSelected() )
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
- else {
+ else*/
+ {
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
}
if ( myCurve->getDimension() == 3 ) {
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);
+ */
+}
#define CURVECREATOR_WIDGET_H
#include "CurveCreator_Curve.hxx"
+#include "CurveCreator.hxx"
#include <QWidget>
#include <QMap>
public slots:
protected slots:
- void onNewPoint(bool checked);
- void onEditPoints(bool checked);
+ void onAdditionMode(bool checked);
+ void onModificationMode(bool checked);
void onDetectPoints(bool checked);
void onModeChanged(bool checked);
void onNewSection();
void onSelectionChanged();
- void onAddNewPoint();
+ void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
void onAddNewSection();
void onEditSection( int theSection );
void onEditPoint( int theSection, int thePoint );
void onRedo();
void onUndoSettings();
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:
- 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,
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,
- EDITION_MODE_ID, DETECTION_MODE_ID };
+ MODIFICATION_MODE_ID, DETECTION_MODE_ID };
private:
QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
const QString& theToolTip, const QKeySequence& theShortcut );
CurveCreator_NewSectionDlg* myNewSectionEditor;
int mySection;
int myPointNum;
+ QPoint myDragStartPosition;
};
#endif // CURVECREATOR_WIDGET_H