]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Modify creation of curves: 1) using QDockWidget instead of QDialog; 2) selection...
authorakl <akl@opencascade.com>
Fri, 20 Sep 2013 12:03:35 +0000 (12:03 +0000)
committerakl <akl@opencascade.com>
Fri, 20 Sep 2013 12:03:35 +0000 (12:03 +0000)
20 files changed:
src/BasicGUI/BasicGUI.cxx
src/BasicGUI/BasicGUI.h
src/BasicGUI/Makefile.am
src/CurveCreator/CurveCreator_NewPointDlg.cxx
src/CurveCreator/CurveCreator_NewPointDlg.h
src/CurveCreator/CurveCreator_NewSectionDlg.cxx
src/CurveCreator/CurveCreator_NewSectionDlg.h
src/CurveCreator/CurveCreator_TreeView.cxx
src/CurveCreator/CurveCreator_Widget.cxx
src/CurveCreator/CurveCreator_Widget.h
src/CurveCreator/Makefile.am
src/EntityGUI/EntityGUI.cxx
src/EntityGUI/EntityGUI.h
src/EntityGUI/Makefile.am
src/GEOMBase/GEOMBase_Helper.cxx
src/GEOMBase/GEOMBase_Helper.h
src/GEOMUtils/GEOMUtils.cxx
src/GEOMUtils/GEOMUtils.hxx
src/GEOMUtils/Makefile.am
src/OperationGUI/OperationGUI.cxx

index e40b013bfea4085c84181a48d9309b36b8f6b91c..6de1396f3645b7fd567c980d21d4768e75e9bb92 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <GeometryGUI.h>
 #include "GeometryGUI_Operations.h"
+#include <GEOMUtils.hxx>
 
 #include <SUIT_Session.h>
 #include <SUIT_Desktop.h>
@@ -155,7 +156,7 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
       }
       else {
         OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
-        aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
+        aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
       }
 
       aPntDlg->OnPointSelected( aPnt );  // "feed" the point to point construction dialog
@@ -165,32 +166,6 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
 }
 
 
-//=======================================================================
-// function : ConvertClickToPoint()
-// purpose  : Returns the point clicked in 3D view
-//=======================================================================
-gp_Pnt BasicGUI::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
-{
-  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
-  aView->Eye( XEye, YEye, ZEye );
-
-  aView->At( XAt, YAt, ZAt );
-  gp_Pnt EyePoint( XEye, YEye, ZEye );
-  gp_Pnt AtPoint( XAt, YAt, ZAt );
-
-  gp_Vec EyeVector( EyePoint, AtPoint );
-  gp_Dir EyeDir( EyeVector );
-
-  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
-  Standard_Real X, Y, Z;
-  aView->Convert( x, y, X, Y, Z );
-  gp_Pnt ConvertedPoint( X, Y, Z );
-
-  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
-  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
-  return ResultPoint;
-}
-
 //=====================================================================================
 // EXPORTED METHODS
 //=====================================================================================
index aa4efc99465fdb52a1a0f9a19306cd1fd6e78a5e..dd120db2a5d110b180bd547692173a2aaf065ac4 100644 (file)
@@ -28,7 +28,6 @@
 #define BASICGUI_H
 
 #include <GEOMGUI.h>
-#include <V3d_View.hxx>
 
 //=================================================================================
 // class    : BasicGUI
@@ -42,8 +41,6 @@ public:
 
   bool   OnGUIEvent( int, SUIT_Desktop* );
   bool   OnMousePress( QMouseEvent*, SUIT_Desktop*, SUIT_ViewWindow* );
-
-  gp_Pnt ConvertClickToPoint( int, int, Handle(V3d_View) );
 };
 
 #endif // BASICGUI_H
index 1d680c9e252592304f4fde29c061486d17922cc5..c76757d1881e1239b2d825c4ea22fce724b1207b 100644 (file)
@@ -101,6 +101,7 @@ libBasicGUI_la_CPPFLAGS =                   \
        -I$(srcdir)/../GEOMBase                 \
        -I$(srcdir)/../GEOMImpl                 \
        -I$(srcdir)/../GEOMClient               \
+       -I$(srcdir)/../GEOMUtils                \
        -I$(top_builddir)/src/DlgRef            \
        -I$(top_builddir)/idl
 
@@ -109,6 +110,7 @@ libBasicGUI_la_LDFLAGS  =                                   \
        ../GEOMFiltersSelection/libGEOMFiltersSelection.la      \
        ../GEOMBase/libGEOMBase.la                              \
        ../GEOMGUI/libGEOM.la                                   \
+       ../GEOMUtils/libGEOMUtils.la                            \
        $(CAS_LDFLAGS) -lTKGeomBase                             \
        $(GUI_LDFLAGS) -lsuit                                   \
-       $(OPENCV_LIBS) 
+       $(OPENCV_LIBS)                                          
index af4bfd72460cd42222d5528d6bbc3c3f174c9c56..5af871285180224081d7c529d24aff9638eea6be 100755 (executable)
 #include <QLocale>
 
 CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
-  QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim)
+  QWidget(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim)
 {
-  QGridLayout* aCoordLay = new QGridLayout();
-
   QString aTitle = QString(tr("ADD_NEW_POINT"));
   setWindowTitle(aTitle);
 
+  QFrame* aFrame = new QFrame( this );
+  QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
+
+  QFrame* aCoordFrame = new QFrame( aFrame );
+  QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
+
   QLabel* aLbl = new QLabel( tr("X_COORD"), this);
   myX = new QDoubleSpinBox(this);
-  aCoordLay->addWidget(aLbl, 0, 0);
-  aCoordLay->addWidget(myX, 0, 1 );
+  aCoordLayout->addWidget(aLbl, 0, 0);
+  aCoordLayout->addWidget(myX, 0, 1 );
 
   aLbl = new QLabel( tr("Y_COORD"), this);
   myY = new QDoubleSpinBox(this);
-  aCoordLay->addWidget(aLbl, 1, 0 );
-  aCoordLay->addWidget(myY, 1, 1 );
+  aCoordLayout->addWidget(aLbl, 1, 0 );
+  aCoordLayout->addWidget(myY, 1, 1 );
 
   myZLabel = new QLabel( tr("Z_COORD"), this);
   myZ = new QDoubleSpinBox(this);
-  aCoordLay->addWidget(myZLabel, 2,0 );
-  aCoordLay->addWidget(myZ, 2,1 );
+  aCoordLayout->addWidget(myZLabel, 2,0 );
+  aCoordLayout->addWidget(myZ, 2,1 );
 
   if( theDim != CurveCreator::Dim3d ){
     myZ->hide();
     myZLabel->hide();
   }
 
-  myBtnBox = new QDialogButtonBox(this);
-  myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
-  myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
-  myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
-
-  connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
-  connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
-  connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
-  QVBoxLayout* aMainLay = new QVBoxLayout();
-  aMainLay->addLayout(aCoordLay);
-  aMainLay->addWidget(myBtnBox);
-  setLayout(aMainLay);
+  myBtnFrame = new QFrame( aFrame );
+  QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
+
+  myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
+  myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
+
+  connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelPoint() ) );
+
+  aBtnsLayout->addWidget( myAddBtn );
+  aBtnsLayout->addStretch( 1 );
+  aBtnsLayout->addWidget( myCancelBtn );
+
+  aLayout->addWidget( aCoordFrame, 0 );
+  aLayout->addWidget( myBtnFrame, 1 );
+
   clear();
   updateTitle();
 }
@@ -64,12 +71,14 @@ void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
 {
   myIsEdit = isEdit;
   if( myIsEdit ){
-    myContBtn->hide();
     myAddBtn->setText(tr("OK"));
+    myAddBtn->disconnect( SIGNAL( clicked() ) );
+    connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifyPoint() ) );
   }
   else{
-    myContBtn->show();
     myAddBtn->setText(tr("ADD_BTN"));
+    myAddBtn->disconnect( SIGNAL( clicked() ) );
+    connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addPoint() ) );
   }
   updateTitle();
 }
@@ -105,13 +114,6 @@ CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
   return aCoords;
 }
 
-void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
-{
-  if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
-    emit addPoint();
-  }
-}
-
 void CurveCreator_NewPointDlg::clear()
 {
   initSpinBox(myX);
index 71dc2e81918dafeebf37d54acc2ebf656d2abc19..d936e51bb71477af5b24ab0048ab8c47ce96e6c8 100755 (executable)
@@ -3,15 +3,16 @@
 
 #include "CurveCreator.hxx"
 
-#include <QDialog>
+#include <QDockWidget>
 
 class QDoubleSpinBox;
 class QDialogButtonBox;
 class QAbstractButton;
 class QPushButton;
 class QLabel;
+class QFrame;
 
-class CurveCreator_NewPointDlg : public QDialog
+class CurveCreator_NewPointDlg : public QWidget
 {
   Q_OBJECT
 public:
@@ -24,21 +25,22 @@ public:
   void setDimension(CurveCreator::Dimension theDim);
 signals:
   void addPoint();
+  void modifyPoint();
+  void cancelPoint();
 public slots:
 protected slots:
-  void onBtnClicked(QAbstractButton* theBtn );
 protected:
   void updateTitle();
   void initSpinBox(QDoubleSpinBox *theSpinBox);
 private:
-  QDialogButtonBox*       myBtnBox;
+  QFrame*                 myBtnFrame;
   CurveCreator::Dimension myDim;
   QDoubleSpinBox*         myX;
   QDoubleSpinBox*         myY;
   QDoubleSpinBox*         myZ;
   QLabel*                 myZLabel;
-  QPushButton*            myContBtn;
   QPushButton*            myAddBtn;
+  QPushButton*            myCancelBtn;
   bool                    myIsEdit;
   QString                 mySectionName;
 };
index 497bef2a61d63681b0ab44c38a8a3767ecc8297c..d7c7745d475e6f6a3f264b73143156ccec1c499f 100755 (executable)
 #include <QPushButton>
 
 CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
-  QDialog(parent)
+  QWidget(parent)
 {
-  std::string aNameStr;
-  QGridLayout* aLay = new QGridLayout();
+  QFrame* aFrame = new QFrame( this );
+  QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
+
+  QFrame* aCoordFrame = new QFrame( aFrame );
+  QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
+
   QLabel* aLbl = new QLabel(tr("NAME"), this);
   myName = new QLineEdit(this);
-  aLay->addWidget(aLbl, 0, 0);
-  aLay->addWidget(myName, 0 , 1);
+  aCoordLayout->addWidget(aLbl, 0, 0);
+  aCoordLayout->addWidget(myName, 0 , 1);
 
   aLbl = new QLabel(tr("LINE_TYPE"));
   myLineType = new QComboBox(this);
@@ -34,27 +38,29 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
   myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
   myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));
   myLineType->setCurrentIndex(0);
-  aLay->addWidget(aLbl, 1, 0);
-  aLay->addWidget(myLineType, 1 , 1);
+  aCoordLayout->addWidget(aLbl, 1, 0);
+  aCoordLayout->addWidget(myLineType, 1 , 1);
 
   aLbl = new QLabel(tr("LINE_CLOSED"));
   myIsClosed = new QCheckBox(this);
-  aLay->addWidget(aLbl, 2, 0);
-  aLay->addWidget(myIsClosed, 2, 1);
-
-  myBtnBox = new QDialogButtonBox(this);
-  myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
-  myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
-  myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
-
-  connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
-  connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
-  connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
-
-  QVBoxLayout* aMainLay = new QVBoxLayout();
-  aMainLay->addLayout(aLay);
-  aMainLay->addWidget(myBtnBox);
-  setLayout(aMainLay);
+  aCoordLayout->addWidget(aLbl, 2, 0);
+  aCoordLayout->addWidget(myIsClosed, 2, 1);
+
+  myBtnFrame = new QFrame( aFrame );
+  QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
+
+  myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
+  myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
+
+  connect( myAddBtn,  SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
+  connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) );
+
+  aBtnsLayout->addWidget( myAddBtn );
+  aBtnsLayout->addStretch( 1 );
+  aBtnsLayout->addWidget( myCancelBtn );
+
+  aLayout->addWidget( aCoordFrame, 0 );
+  aLayout->addWidget( myBtnFrame, 1 );
 }
 
 void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
@@ -78,12 +84,14 @@ void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
 {
   myIsEdit = isEdit;
   if( myIsEdit ){
-    myContBtn->hide();
     myAddBtn->setText(tr("OK"));
+    myAddBtn->disconnect( SIGNAL( clicked() ) );
+    connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) );
   }
   else{
-    myContBtn->show();
     myAddBtn->setText(tr("ADD_BTN"));
+    myAddBtn->disconnect( SIGNAL( clicked() ) );
+    connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
   }
   updateTitle();
 }
@@ -120,10 +128,3 @@ void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
 {
   myName->setText(theName);
 }
-
-void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
-{
-  if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
-    emit addSection();
-  }
-}
index d7568fb27270cf81af6ce6d98d675b28481fcafb..d88b08f13b507eab06f20e048631098e2d405285 100755 (executable)
@@ -3,7 +3,7 @@
 
 #include "CurveCreator.hxx"
 
-#include <QDialog>
+#include <QDockWidget>
 
 class CurveCreator_Curve;
 
@@ -13,8 +13,9 @@ class QCheckBox;
 class QPushButton;
 class QAbstractButton;
 class QDialogButtonBox;
+class QFrame;
 
-class CurveCreator_NewSectionDlg : public QDialog
+class CurveCreator_NewSectionDlg : public QWidget
 {
   Q_OBJECT
 public:
@@ -31,19 +32,20 @@ public:
 
 signals:
   void    addSection();
+  void    modifySection();
+  void    cancelSection();
 public slots:
 protected slots:
-  void onBtnClicked(QAbstractButton* theBtn );
 protected:
   void    updateTitle();
 private:
+  QFrame*             myBtnFrame;
   QLineEdit*          myName;
   QComboBox*          myLineType;
   QCheckBox*          myIsClosed;
   bool                myIsEdit;
-  QPushButton*        myContBtn;
   QPushButton*        myAddBtn;
-  QDialogButtonBox*   myBtnBox;
+  QPushButton*        myCancelBtn;
 };
 
 #endif // CURVECREATOR_NEWSECTION_H
index a6eaaaa0496d6197c238ad77e32b2590b86f129a..d7ff92f465652384f78e7723c5a0a2c0a31b3d24 100755 (executable)
@@ -227,6 +227,7 @@ void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePo
   if( aModel ){
     QModelIndex aSectIndx = aModel->sectionIndex( theSection );
     rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
+    expand( aSectIndx );
   }
 }
 
index 66f38c418f93d575177f2099f80601c1ddb6be83..c94ab8f4ccb8e09a894f2835a85f3a7f1a64dcc6 100644 (file)
@@ -1,14 +1,24 @@
 #include "CurveCreator_Widget.h"
 #include "CurveCreator_TreeView.h"
-#include "QVBoxLayout"
 #include "CurveCreator_Curve.hxx"
 #include "CurveCreator_CurveEditor.hxx"
 #include "CurveCreator.hxx"
 #include "CurveCreator_NewPointDlg.h"
 #include "CurveCreator_NewSectionDlg.h"
 
+#include <GEOMUtils.hxx>
+#include <GEOMBase_Helper.h>
+
 #include <SUIT_Session.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_ViewManager.h>
+
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewPort3d.h>
+
+#include <BRep_Tool.hxx>
+#include <TopoDS.hxx>
 
 #include <QHBoxLayout>
 #include <QVBoxLayout>
@@ -19,6 +29,7 @@
 #include <QToolBar>
 #include <QAction>
 #include <QMenu>
+#include <QMouseEvent>
 
 CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
                                          CurveCreator_Curve *theCurve,
@@ -28,14 +39,20 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
     if( myCurve )
         myEdit = new CurveCreator_CurveEditor( myCurve );
 
-    CurveCreator::Dimension aDim = CurveCreator::Dim3d;
+    CurveCreator::Dimension aDim = CurveCreator::Dim2d;
     if( myCurve )
         aDim = myCurve->getDimension();
-    myNewPointEditor = new CurveCreator_NewPointDlg(aDim, this);
-    connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
-
-    myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
-    connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
+    myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this );
+    myNewPointEditor->hide();
+    connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()) );
+    connect( myNewPointEditor, SIGNAL(modifyPoint()), this, SLOT(onModifyPoint()) );
+    connect( myNewPointEditor, SIGNAL(cancelPoint()), this, SLOT(onCancelPoint()) );
+
+    myNewSectionEditor = new CurveCreator_NewSectionDlg( this );
+    myNewSectionEditor->hide();
+    connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()) );
+    connect( myNewSectionEditor, SIGNAL(modifySection()), this, SLOT(onModifySection()) );
+    connect( myNewSectionEditor, SIGNAL(cancelSection()), this, SLOT(onCancelSection()) );
 
     QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
 
@@ -286,9 +303,16 @@ void CurveCreator_Widget::onNewPoint()
   myNewPointEditor->setEditMode(false);
   myNewPointEditor->setSectionName(aSectName);
   myNewPointEditor->setDimension(myCurve->getDimension());
-  if( myNewPointEditor->exec() == QDialog::Accepted ){
-    onAddNewPoint();
+
+  SUIT_ViewWindow* aViewWindow = GEOMBase_Helper::getActiveView();
+  SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
+  if ( aViewWindow == 0 )
+    return;
+  if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
+    connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
+             this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
   }
+  emit subOperationStarted( myNewPointEditor );
 }
 
 void CurveCreator_Widget::onAddNewPoint()
@@ -298,7 +322,7 @@ void CurveCreator_Widget::onAddNewPoint()
   CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
   myEdit->insertPoints(aCoords, mySection, myPointNum );
   mySectionView->pointsAdded( mySection, myPointNum );
-  myNewPointEditor->clear();
+//  myNewPointEditor->clear();
   myPointNum++;
   onSelectionChanged();
   updateUndoRedo();
@@ -312,9 +336,7 @@ void CurveCreator_Widget::onNewSection()
   myNewSectionEditor->setEditMode(false);
   QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
   myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
-  if( myNewSectionEditor->exec() == QDialog::Accepted ){
-    onAddNewSection();
-  }
+  emit subOperationStarted( myNewSectionEditor );
 }
 
 void CurveCreator_Widget::onAddNewSection()
@@ -330,6 +352,17 @@ void CurveCreator_Widget::onAddNewSection()
   mySection++;
   onSelectionChanged();
   updateUndoRedo();
+  onCancelSection();
+}
+
+void CurveCreator_Widget::onCancelPoint()
+{
+  emit subOperationFinished( myNewPointEditor );
+}
+
+void CurveCreator_Widget::onCancelSection()
+{
+  emit subOperationFinished( myNewSectionEditor );
 }
 
 QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
@@ -362,38 +395,51 @@ void CurveCreator_Widget::onEditSection( int theSection )
   CurveCreator::Type aType = myCurve->getType(theSection);
   myNewSectionEditor->setEditMode(true);
   myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
-  if( myNewSectionEditor->exec() == QDialog::Accepted ){
-    QString aName = myNewSectionEditor->getName();
-    bool    isClosed = myNewSectionEditor->isClosed();
-    CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
-    myEdit->startOperation();
-    myEdit->setClosed( isClosed, mySection );
-    myEdit->setName( aName.toStdString(), mySection );
-    myEdit->setType( aSectType, mySection );
-    myEdit->finishOperation();
-    mySectionView->sectionChanged(mySection);
-    updateUndoRedo();
-  }
+
+  emit subOperationStarted( myNewSectionEditor );
 }
 
-void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
+void CurveCreator_Widget::onModifySection()
 {
-  if( !myNewPointEditor )
-    return;
   if( !myEdit )
     return;
+  QString aName = myNewSectionEditor->getName();
+  bool isClosed = myNewSectionEditor->isClosed();
+  CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
+  myEdit->startOperation();
+  myEdit->setClosed( isClosed, mySection );
+  myEdit->setName( aName.toStdString(), mySection );
+  myEdit->setType( aSectType, mySection );
+  myEdit->finishOperation();
+  mySectionView->sectionChanged(mySection);
+  updateUndoRedo();
+  onCancelSection();
+}
+
+void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
+{
+  if( !myNewPointEditor || !myEdit )
+    return;
+  mySection = theSection;
+  myPointNum = thePoint;
   QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
   myNewPointEditor->setEditMode(true);
   myNewPointEditor->setSectionName(aSectName);
   myNewPointEditor->setDimension( myCurve->getDimension() );
   CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
   myNewPointEditor->setCoordinates(aCoords);
-  if( myNewPointEditor->exec() == QDialog::Accepted ){
-    aCoords = myNewPointEditor->getCoordinates();
-    myEdit->setCoordinates(aCoords, theSection, thePoint);
-    mySectionView->pointDataChanged(theSection, thePoint );
-    updateUndoRedo();
-  }
+  emit subOperationStarted( myNewPointEditor );
+}
+
+void CurveCreator_Widget::onModifyPoint()
+{
+  if( !myEdit )
+    return;
+  CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
+  myEdit->setCoordinates( aCoords, mySection, myPointNum );
+  mySectionView->pointDataChanged( mySection, myPointNum );
+  updateUndoRedo();
+  onCancelPoint();
 }
 
 void CurveCreator_Widget::onJoin()
@@ -689,3 +735,43 @@ QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints()
 {
   return mySectionView->getSelectedPoints();
 }
+
+//=================================================================================
+// function : GeometryGUI::OnMousePress()
+// purpose  : Manage mouse press events [static]
+//=================================================================================
+void CurveCreator_Widget::onMousePress( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
+{
+  if ( myNewPointEditor && theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
+       pe->modifiers() != Qt::ControlModifier ) {
+    OCCViewer_Viewer* anOCCViewer =
+      ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
+    Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+
+    gp_Pnt aPnt;    
+
+    ic->InitSelected();
+    if ( pe->modifiers() == Qt::ShiftModifier )
+      ic->ShiftSelect();  // Append selection
+    else
+      ic->Select();       // New selection
+
+    ic->InitSelected();
+    if ( ic->MoreSelected() ) {
+      TopoDS_Shape aShape = ic->SelectedShape();
+      if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+        aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
+    } else {
+      OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
+      aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
+    }
+    // set the coordinates into dialog
+    CurveCreator::Coordinates aCoords;
+    aCoords.push_back( aPnt.X() );
+    aCoords.push_back( aPnt.Y() );
+    if ( myCurve->getDimension() == 3 ) {
+      aCoords.push_back( aPnt.Z() );
+    }
+    myNewPointEditor->setCoordinates( aCoords );
+  }
+}
index f5ed9f1db7abe5b19a3f54ceb63e817eaf27c982..fe2cd856c1f14c087782ce6951be589953283124 100644 (file)
@@ -4,9 +4,10 @@
 #include "CurveCreator_Curve.hxx"
 
 #include <QWidget>
-
 #include <QMap>
 
+#include <SUIT_ViewWindow.h>
+
 class QAction;
 class QPixmap;
 class CurveCreator_CurveEditor;
@@ -29,6 +30,8 @@ public:
 
 signals:
     void selectionChanged();
+    void subOperationStarted( QWidget* );
+    void subOperationFinished( QWidget* );
 
 public slots:
 
@@ -40,6 +43,10 @@ protected slots:
     void     onAddNewSection();
     void     onEditSection( int theSection );
     void     onEditPoint( int theSection, int thePoint );
+    void     onModifyPoint();
+    void     onModifySection();
+    void     onCancelPoint();
+    void     onCancelSection();
     void     onJoin();
     void     onRemove();
     void     onMoveUp();
@@ -58,6 +65,7 @@ protected slots:
     void     onRedo();
     void     onUndoSettings();
     void     onContextMenu(QPoint thePoint);
+    void     onMousePress( SUIT_ViewWindow*, QMouseEvent* );
 protected:
     enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, NEW_POINT_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,
                    JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,
index 8a44f565d5b42c445d5287ffc9f739b154feea01..d92dd4f5cde56e4cd351aed8a305672043987418 100644 (file)
@@ -81,14 +81,26 @@ endif
 
 # additional information to compile and link file
 
-libCurveCreator_la_CPPFLAGS =  \
-       $(QT_INCLUDES)                          \
-       $(CAS_CPPFLAGS)         \
-       $(KERNEL_CXXFLAGS)      \
-       $(GUI_CXXFLAGS)
+libCurveCreator_la_CPPFLAGS =          \
+       $(QT_INCLUDES)                  \
+       $(CAS_CPPFLAGS)                 \
+       $(KERNEL_CXXFLAGS)              \
+       $(GUI_CXXFLAGS)                 \
+       $(CORBA_CXXFLAGS)               \
+       $(CORBA_INCLUDES)               \
+       -I$(srcdir)/../GEOMGUI          \
+       -I$(srcdir)/../GEOMUtils        \
+       -I$(srcdir)/../GEOMBase         \
+       -I$(top_builddir)/idl
 
-libCurveCreator_la_LDFLAGS  =                  \
-       $(QT_MT_LIBS) \
-       $(CAS_KERNEL) \
-       $(KERNEL_LDFLAGS) \
-       $(GUI_LDFLAGS) -lqtx -lsuit
+
+libCurveCreator_la_LDFLAGS  =          \
+       $(QT_MT_LIBS)                   \
+       $(CAS_KERNEL)                   \
+       $(CAS_VIEWER)                   \
+       $(OCCViewer)                    \
+       $(KERNEL_LDFLAGS)               \
+       $(GUI_LDFLAGS) -lqtx -lsuit     \
+       ../GEOMUtils/libGEOM.la         \
+       ../GEOMUtils/libGEOMUtils.la    \
+       ../GEOMUtils/libGEOMBase.la     
index 705138e361dcc2ca5c3fdfc84e9662c192c9b32f..ae37c08402a0b72cece216c492e7c52fe4de5847 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <GeometryGUI.h>
 #include "GeometryGUI_Operations.h"
+#include <GEOMUtils.hxx>
 
 #include <SUIT_Session.h>
 #include <SUIT_Desktop.h>
@@ -152,7 +153,7 @@ bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWi
         }
         else {
           OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
-          aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
+          aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
         }
         
         Qt::KeyboardModifiers modifiers = pe->modifiers();
@@ -240,7 +241,7 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
     if ( aSketcherDlg->acceptMouseEvent() ) 
     {    
       OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
-      gp_Pnt aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
+      gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
   
       Qt::KeyboardModifiers modifiers = pe->modifiers();
       if (QApplication::mouseButtons() == Qt::LeftButton )
@@ -251,32 +252,6 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
   return false;
 }
 
-//=======================================================================
-// function : ConvertClickToPoint()
-// purpose  : Returns the point clicked in 3D view
-//=======================================================================
-gp_Pnt EntityGUI::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
-{
-  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
-  aView->Eye( XEye, YEye, ZEye );
-
-  aView->At( XAt, YAt, ZAt );
-  gp_Pnt EyePoint( XEye, YEye, ZEye );
-  gp_Pnt AtPoint( XAt, YAt, ZAt );
-
-  gp_Vec EyeVector( EyePoint, AtPoint );
-  gp_Dir EyeDir( EyeVector );
-
-  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
-  Standard_Real X, Y, Z;
-  aView->Convert( x, y, X, Y, Z );
-  gp_Pnt ConvertedPoint( X, Y, Z );
-
-  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
-  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
-  return ResultPoint;
-}
-
 //=====================================================================================
 // function : DisplaySimulationShape() 
 // purpose  : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
index 1b84b29013829a23d52cdab9a71f9d0afc8c3811..ccf336999d411adf01121abd9305bacc8c5b851f 100644 (file)
@@ -32,7 +32,6 @@
 #include <SALOMEDSClient.hxx>
 
 #include <AIS_Shape.hxx>
-#include <V3d_View.hxx>
 
 class TopoDS_Shape;
 
@@ -52,8 +51,6 @@ public :
   bool              OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
   bool              OnMouseRelease( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
   
-  static gp_Pnt     ConvertClickToPoint( int x, int y, Handle(V3d_View) aView );
-
   void              DisplaySimulationShape( const TopoDS_Shape&, const TopoDS_Shape& ); 
   void              EraseSimulationShape();
 
index 37f0e6f46986d4d3a7356f24aeb43684608c4498..b88f96ceb41a404dc20a948df7e0fbd0bfca8607 100644 (file)
@@ -112,6 +112,7 @@ libEntityGUI_la_CPPFLAGS =                  \
        -I$(srcdir)/../GEOMImpl                 \
        -I$(srcdir)/../GEOMFiltersSelection     \
        -I$(srcdir)/../SKETCHER                 \
+       -I$(srcdir)/../GEOMUtils                \
        -I$(ShapeRec_dir)                       \
        -I$(srcdir)/../GEOM                     \
        -I$(top_builddir)/src/DlgRef            \
@@ -123,7 +124,8 @@ libEntityGUI_la_LDFLAGS  =                                  \
        ../GEOMBase/libGEOMBase.la                              \
        ../SKETCHER/libGEOMSketcher.la                          \
        ../GEOMGUI/libGEOM.la                                   \
+       ../GEOMUtils/libGEOMUtils.la                            \
        $(ShapeRec_la)                                          \
        $(QT_MT_LIBS)                                           \
        $(CAS_TKTopAlgo) -lTKernel                              \
-       $(Opencv_libs)
+       $(Opencv_libs)                                          
index 56282b716db8459394ee2718310afa6f25615560..e72d962775db8d484303bc141c5734ac90b01415 100755 (executable)
@@ -64,7 +64,7 @@
 // Function : getActiveView
 // Purpose  : Get active view window, returns 0 if no open study frame
 //================================================================
-static SUIT_ViewWindow* getActiveView()
+SUIT_ViewWindow* GEOMBase_Helper::getActiveView()
 {
   SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
   if ( activeStudy )
index ab5249e1ea36ee2110301c57e796571bf3e37910..37c8a47ce6c5889214386a08e7e7b4633e774a5a 100755 (executable)
@@ -61,6 +61,7 @@ class GEOMBASE_EXPORT GEOMBase_Helper
 public:
   GEOMBase_Helper( SUIT_Desktop* );
   virtual ~GEOMBase_Helper();
+  static SUIT_ViewWindow* getActiveView();
 
 protected:
   static GEOM::GEOM_Gen_ptr getGeomEngine();
index f2c53523f3839601a246df1bd7e6e8cc04d13a23..1f8b68b2e2a97eb1d9c113cd782de342e652e281 100644 (file)
@@ -72,6 +72,9 @@
 #include <gp_Pln.hxx>
 #include <gp_Lin.hxx>
 
+#include <ProjLib.hxx>
+#include <ElSLib.hxx>
+
 #include <vector>
 
 #include <Standard_Failure.hxx>
@@ -600,3 +603,29 @@ TopoDS_Shape GEOMUtils::GetEdgeNearPoint (const TopoDS_Shape& theShape,
 
   return aResult;
 }
+
+//=======================================================================
+// function : ConvertClickToPoint()
+// purpose  : Returns the point clicked in 3D view
+//=======================================================================
+gp_Pnt GEOMUtils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
+{
+  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
+  aView->Eye( XEye, YEye, ZEye );
+
+  aView->At( XAt, YAt, ZAt );
+  gp_Pnt EyePoint( XEye, YEye, ZEye );
+  gp_Pnt AtPoint( XAt, YAt, ZAt );
+
+  gp_Vec EyeVector( EyePoint, AtPoint );
+  gp_Dir EyeDir( EyeVector );
+
+  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
+  Standard_Real X, Y, Z;
+  aView->Convert( x, y, X, Y, Z );
+  gp_Pnt ConvertedPoint( X, Y, Z );
+
+  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
+  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
+  return ResultPoint;
+}
index 64c34bd857040dc3b7b1a0bc9feb3d513e1dc4c7..fd4c1140e0ac105280dae785bcf65727a5a5f30c 100644 (file)
@@ -33,6 +33,8 @@
 #include <gp_Ax3.hxx>
 #include <gp_Vec.hxx>
 
+#include <V3d_View.hxx>
+
 #include <NCollection_DataMap.hxx>
 
 #include <functional>
@@ -132,6 +134,16 @@ class GEOMUtils {
   Standard_EXPORT static TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape&  theShape,
                                                         const TopoDS_Vertex& thePoint);
 
+  /*!
+   * \brief Returns the point clicked in 3D view.
+   *
+   * \param x The X coordinate in the view.
+   * \param y The Y coordinate in the view.
+   * \param theView View where the given point takes place.
+   * \retval gp_Pnt Returns the point clicked in 3D view
+   */
+  Standard_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView );
+
 };
 
 #endif
index 73c1ebda4c5920c38ed42dfd2bd68ccd08a918d3..d1f1cbbeac275f539a14cbc83f8c9055fd082126 100644 (file)
@@ -54,5 +54,5 @@ libGEOMUtils_la_LDFLAGS  =                    \
        ../ARCHIMEDE/libGEOMArchimede.la        \
        ../SKETCHER/libGEOMSketcher.la          \
        $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics     \
-       $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat    \
+       $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat -lTKV3d    \
        $(STDLIB)
index 9a3d971c376a37ae97c6649aa9b73a5fd864bc8c..94db3f396899080c4c6f3b8a7feb9ac0c8b13558 100644 (file)
@@ -30,6 +30,8 @@
 #include <SUIT_Session.h>
 #include <SUIT_Desktop.h>
 #include <SalomeApp_Application.h>
+#include <OCCViewer_ViewWindow.h>
+#include <SUIT_ViewManager.h>
 
 #include <TopTools_MapOfShape.hxx>
 #include <TopExp_Explorer.hxx>
@@ -100,7 +102,11 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
       static CurveCreator_Curve *aStaticCurve = NULL;
 
       if (aStaticCurve == NULL) {
-        aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d);
+        aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim2d);
+      }
+      if (CurveCreator::Dim2d == aStaticCurve->getDimension()) {
+        OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)getGeometryGUI()->getApp()->activeViewManager()->getActiveView();
+        vw->onTopView();
       }
 
       QDialog     *aDialog     = new QDialog(parent);