Modify creation of curves: 1) using QDockWidget instead of QDialog; 2) selection of new point coordinates by click in viewer.

This commit is contained in:
akl 2013-09-20 12:03:35 +00:00
parent 18247cdc08
commit 4a99ec5202
20 changed files with 288 additions and 178 deletions

View File

@ -38,6 +38,7 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include "GeometryGUI_Operations.h" #include "GeometryGUI_Operations.h"
#include <GEOMUtils.hxx>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
@ -155,7 +156,7 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
} }
else { else {
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); 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 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 // EXPORTED METHODS
//===================================================================================== //=====================================================================================

View File

@ -28,7 +28,6 @@
#define BASICGUI_H #define BASICGUI_H
#include <GEOMGUI.h> #include <GEOMGUI.h>
#include <V3d_View.hxx>
//================================================================================= //=================================================================================
// class : BasicGUI // class : BasicGUI
@ -42,8 +41,6 @@ public:
bool OnGUIEvent( int, SUIT_Desktop* ); bool OnGUIEvent( int, SUIT_Desktop* );
bool OnMousePress( QMouseEvent*, SUIT_Desktop*, SUIT_ViewWindow* ); bool OnMousePress( QMouseEvent*, SUIT_Desktop*, SUIT_ViewWindow* );
gp_Pnt ConvertClickToPoint( int, int, Handle(V3d_View) );
}; };
#endif // BASICGUI_H #endif // BASICGUI_H

View File

@ -101,6 +101,7 @@ libBasicGUI_la_CPPFLAGS = \
-I$(srcdir)/../GEOMBase \ -I$(srcdir)/../GEOMBase \
-I$(srcdir)/../GEOMImpl \ -I$(srcdir)/../GEOMImpl \
-I$(srcdir)/../GEOMClient \ -I$(srcdir)/../GEOMClient \
-I$(srcdir)/../GEOMUtils \
-I$(top_builddir)/src/DlgRef \ -I$(top_builddir)/src/DlgRef \
-I$(top_builddir)/idl -I$(top_builddir)/idl
@ -109,6 +110,7 @@ libBasicGUI_la_LDFLAGS = \
../GEOMFiltersSelection/libGEOMFiltersSelection.la \ ../GEOMFiltersSelection/libGEOMFiltersSelection.la \
../GEOMBase/libGEOMBase.la \ ../GEOMBase/libGEOMBase.la \
../GEOMGUI/libGEOM.la \ ../GEOMGUI/libGEOM.la \
../GEOMUtils/libGEOMUtils.la \
$(CAS_LDFLAGS) -lTKGeomBase \ $(CAS_LDFLAGS) -lTKGeomBase \
$(GUI_LDFLAGS) -lsuit \ $(GUI_LDFLAGS) -lsuit \
$(OPENCV_LIBS) $(OPENCV_LIBS)

View File

@ -11,45 +11,52 @@
#include <QLocale> #include <QLocale>
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) : 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")); QString aTitle = QString(tr("ADD_NEW_POINT"));
setWindowTitle(aTitle); 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); QLabel* aLbl = new QLabel( tr("X_COORD"), this);
myX = new QDoubleSpinBox(this); myX = new QDoubleSpinBox(this);
aCoordLay->addWidget(aLbl, 0, 0); aCoordLayout->addWidget(aLbl, 0, 0);
aCoordLay->addWidget(myX, 0, 1 ); aCoordLayout->addWidget(myX, 0, 1 );
aLbl = new QLabel( tr("Y_COORD"), this); aLbl = new QLabel( tr("Y_COORD"), this);
myY = new QDoubleSpinBox(this); myY = new QDoubleSpinBox(this);
aCoordLay->addWidget(aLbl, 1, 0 ); aCoordLayout->addWidget(aLbl, 1, 0 );
aCoordLay->addWidget(myY, 1, 1 ); aCoordLayout->addWidget(myY, 1, 1 );
myZLabel = new QLabel( tr("Z_COORD"), this); myZLabel = new QLabel( tr("Z_COORD"), this);
myZ = new QDoubleSpinBox(this); myZ = new QDoubleSpinBox(this);
aCoordLay->addWidget(myZLabel, 2,0 ); aCoordLayout->addWidget(myZLabel, 2,0 );
aCoordLay->addWidget(myZ, 2,1 ); aCoordLayout->addWidget(myZ, 2,1 );
if( theDim != CurveCreator::Dim3d ){ if( theDim != CurveCreator::Dim3d ){
myZ->hide(); myZ->hide();
myZLabel->hide(); myZLabel->hide();
} }
myBtnBox = new QDialogButtonBox(this); myBtnFrame = new QFrame( aFrame );
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole ); QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole ); 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 );
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);
clear(); clear();
updateTitle(); updateTitle();
} }
@ -64,12 +71,14 @@ void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
{ {
myIsEdit = isEdit; myIsEdit = isEdit;
if( myIsEdit ){ if( myIsEdit ){
myContBtn->hide();
myAddBtn->setText(tr("OK")); myAddBtn->setText(tr("OK"));
myAddBtn->disconnect( SIGNAL( clicked() ) );
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifyPoint() ) );
} }
else{ else{
myContBtn->show();
myAddBtn->setText(tr("ADD_BTN")); myAddBtn->setText(tr("ADD_BTN"));
myAddBtn->disconnect( SIGNAL( clicked() ) );
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addPoint() ) );
} }
updateTitle(); updateTitle();
} }
@ -105,13 +114,6 @@ CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
return aCoords; return aCoords;
} }
void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
{
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
emit addPoint();
}
}
void CurveCreator_NewPointDlg::clear() void CurveCreator_NewPointDlg::clear()
{ {
initSpinBox(myX); initSpinBox(myX);

View File

@ -3,15 +3,16 @@
#include "CurveCreator.hxx" #include "CurveCreator.hxx"
#include <QDialog> #include <QDockWidget>
class QDoubleSpinBox; class QDoubleSpinBox;
class QDialogButtonBox; class QDialogButtonBox;
class QAbstractButton; class QAbstractButton;
class QPushButton; class QPushButton;
class QLabel; class QLabel;
class QFrame;
class CurveCreator_NewPointDlg : public QDialog class CurveCreator_NewPointDlg : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -24,21 +25,22 @@ public:
void setDimension(CurveCreator::Dimension theDim); void setDimension(CurveCreator::Dimension theDim);
signals: signals:
void addPoint(); void addPoint();
void modifyPoint();
void cancelPoint();
public slots: public slots:
protected slots: protected slots:
void onBtnClicked(QAbstractButton* theBtn );
protected: protected:
void updateTitle(); void updateTitle();
void initSpinBox(QDoubleSpinBox *theSpinBox); void initSpinBox(QDoubleSpinBox *theSpinBox);
private: private:
QDialogButtonBox* myBtnBox; QFrame* myBtnFrame;
CurveCreator::Dimension myDim; CurveCreator::Dimension myDim;
QDoubleSpinBox* myX; QDoubleSpinBox* myX;
QDoubleSpinBox* myY; QDoubleSpinBox* myY;
QDoubleSpinBox* myZ; QDoubleSpinBox* myZ;
QLabel* myZLabel; QLabel* myZLabel;
QPushButton* myContBtn;
QPushButton* myAddBtn; QPushButton* myAddBtn;
QPushButton* myCancelBtn;
bool myIsEdit; bool myIsEdit;
QString mySectionName; QString mySectionName;
}; };

View File

@ -13,14 +13,18 @@
#include <QPushButton> #include <QPushButton>
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) : CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
QDialog(parent) QWidget(parent)
{ {
std::string aNameStr; QFrame* aFrame = new QFrame( this );
QGridLayout* aLay = new QGridLayout(); QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
QFrame* aCoordFrame = new QFrame( aFrame );
QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
QLabel* aLbl = new QLabel(tr("NAME"), this); QLabel* aLbl = new QLabel(tr("NAME"), this);
myName = new QLineEdit(this); myName = new QLineEdit(this);
aLay->addWidget(aLbl, 0, 0); aCoordLayout->addWidget(aLbl, 0, 0);
aLay->addWidget(myName, 0 , 1); aCoordLayout->addWidget(myName, 0 , 1);
aLbl = new QLabel(tr("LINE_TYPE")); aLbl = new QLabel(tr("LINE_TYPE"));
myLineType = new QComboBox(this); myLineType = new QComboBox(this);
@ -34,27 +38,29 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE")); myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE")); myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));
myLineType->setCurrentIndex(0); myLineType->setCurrentIndex(0);
aLay->addWidget(aLbl, 1, 0); aCoordLayout->addWidget(aLbl, 1, 0);
aLay->addWidget(myLineType, 1 , 1); aCoordLayout->addWidget(myLineType, 1 , 1);
aLbl = new QLabel(tr("LINE_CLOSED")); aLbl = new QLabel(tr("LINE_CLOSED"));
myIsClosed = new QCheckBox(this); myIsClosed = new QCheckBox(this);
aLay->addWidget(aLbl, 2, 0); aCoordLayout->addWidget(aLbl, 2, 0);
aLay->addWidget(myIsClosed, 2, 1); aCoordLayout->addWidget(myIsClosed, 2, 1);
myBtnBox = new QDialogButtonBox(this); myBtnFrame = new QFrame( aFrame );
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole ); QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept())); myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject())); myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
QVBoxLayout* aMainLay = new QVBoxLayout(); connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
aMainLay->addLayout(aLay); connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) );
aMainLay->addWidget(myBtnBox);
setLayout(aMainLay); 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 ) void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
@ -78,12 +84,14 @@ void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
{ {
myIsEdit = isEdit; myIsEdit = isEdit;
if( myIsEdit ){ if( myIsEdit ){
myContBtn->hide();
myAddBtn->setText(tr("OK")); myAddBtn->setText(tr("OK"));
myAddBtn->disconnect( SIGNAL( clicked() ) );
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) );
} }
else{ else{
myContBtn->show();
myAddBtn->setText(tr("ADD_BTN")); myAddBtn->setText(tr("ADD_BTN"));
myAddBtn->disconnect( SIGNAL( clicked() ) );
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
} }
updateTitle(); updateTitle();
} }
@ -120,10 +128,3 @@ void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
{ {
myName->setText(theName); myName->setText(theName);
} }
void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
{
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
emit addSection();
}
}

View File

@ -3,7 +3,7 @@
#include "CurveCreator.hxx" #include "CurveCreator.hxx"
#include <QDialog> #include <QDockWidget>
class CurveCreator_Curve; class CurveCreator_Curve;
@ -13,8 +13,9 @@ class QCheckBox;
class QPushButton; class QPushButton;
class QAbstractButton; class QAbstractButton;
class QDialogButtonBox; class QDialogButtonBox;
class QFrame;
class CurveCreator_NewSectionDlg : public QDialog class CurveCreator_NewSectionDlg : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -31,19 +32,20 @@ public:
signals: signals:
void addSection(); void addSection();
void modifySection();
void cancelSection();
public slots: public slots:
protected slots: protected slots:
void onBtnClicked(QAbstractButton* theBtn );
protected: protected:
void updateTitle(); void updateTitle();
private: private:
QFrame* myBtnFrame;
QLineEdit* myName; QLineEdit* myName;
QComboBox* myLineType; QComboBox* myLineType;
QCheckBox* myIsClosed; QCheckBox* myIsClosed;
bool myIsEdit; bool myIsEdit;
QPushButton* myContBtn;
QPushButton* myAddBtn; QPushButton* myAddBtn;
QDialogButtonBox* myBtnBox; QPushButton* myCancelBtn;
}; };
#endif // CURVECREATOR_NEWSECTION_H #endif // CURVECREATOR_NEWSECTION_H

View File

@ -227,6 +227,7 @@ void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePo
if( aModel ){ if( aModel ){
QModelIndex aSectIndx = aModel->sectionIndex( theSection ); QModelIndex aSectIndx = aModel->sectionIndex( theSection );
rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 ); rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
expand( aSectIndx );
} }
} }

View File

@ -1,14 +1,24 @@
#include "CurveCreator_Widget.h" #include "CurveCreator_Widget.h"
#include "CurveCreator_TreeView.h" #include "CurveCreator_TreeView.h"
#include "QVBoxLayout"
#include "CurveCreator_Curve.hxx" #include "CurveCreator_Curve.hxx"
#include "CurveCreator_CurveEditor.hxx" #include "CurveCreator_CurveEditor.hxx"
#include "CurveCreator.hxx" #include "CurveCreator.hxx"
#include "CurveCreator_NewPointDlg.h" #include "CurveCreator_NewPointDlg.h"
#include "CurveCreator_NewSectionDlg.h" #include "CurveCreator_NewSectionDlg.h"
#include <GEOMUtils.hxx>
#include <GEOMBase_Helper.h>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_ResourceMgr.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 <QHBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -19,6 +29,7 @@
#include <QToolBar> #include <QToolBar>
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include <QMouseEvent>
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent, CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
CurveCreator_Curve *theCurve, CurveCreator_Curve *theCurve,
@ -28,14 +39,20 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
if( myCurve ) if( myCurve )
myEdit = new CurveCreator_CurveEditor( myCurve ); myEdit = new CurveCreator_CurveEditor( myCurve );
CurveCreator::Dimension aDim = CurveCreator::Dim3d; CurveCreator::Dimension aDim = CurveCreator::Dim2d;
if( myCurve ) if( myCurve )
aDim = myCurve->getDimension(); aDim = myCurve->getDimension();
myNewPointEditor = new CurveCreator_NewPointDlg(aDim, this); myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this );
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint())); 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 = new CurveCreator_NewSectionDlg( this );
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection())); 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); QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
@ -286,9 +303,16 @@ void CurveCreator_Widget::onNewPoint()
myNewPointEditor->setEditMode(false); myNewPointEditor->setEditMode(false);
myNewPointEditor->setSectionName(aSectName); myNewPointEditor->setSectionName(aSectName);
myNewPointEditor->setDimension(myCurve->getDimension()); 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() void CurveCreator_Widget::onAddNewPoint()
@ -298,7 +322,7 @@ void CurveCreator_Widget::onAddNewPoint()
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates(); CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
myEdit->insertPoints(aCoords, mySection, myPointNum ); myEdit->insertPoints(aCoords, mySection, myPointNum );
mySectionView->pointsAdded( mySection, myPointNum ); mySectionView->pointsAdded( mySection, myPointNum );
myNewPointEditor->clear(); // myNewPointEditor->clear();
myPointNum++; myPointNum++;
onSelectionChanged(); onSelectionChanged();
updateUndoRedo(); updateUndoRedo();
@ -312,9 +336,7 @@ void CurveCreator_Widget::onNewSection()
myNewSectionEditor->setEditMode(false); myNewSectionEditor->setEditMode(false);
QString aSectName = QString( myCurve->getUnicSectionName().c_str() ); QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline ); myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
if( myNewSectionEditor->exec() == QDialog::Accepted ){ emit subOperationStarted( myNewSectionEditor );
onAddNewSection();
}
} }
void CurveCreator_Widget::onAddNewSection() void CurveCreator_Widget::onAddNewSection()
@ -330,6 +352,17 @@ void CurveCreator_Widget::onAddNewSection()
mySection++; mySection++;
onSelectionChanged(); onSelectionChanged();
updateUndoRedo(); 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, 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); CurveCreator::Type aType = myCurve->getType(theSection);
myNewSectionEditor->setEditMode(true); myNewSectionEditor->setEditMode(true);
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType ); myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
if( myNewSectionEditor->exec() == QDialog::Accepted ){
QString aName = myNewSectionEditor->getName(); emit subOperationStarted( myNewSectionEditor );
bool isClosed = myNewSectionEditor->isClosed(); }
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
myEdit->startOperation(); void CurveCreator_Widget::onModifySection()
myEdit->setClosed( isClosed, mySection ); {
myEdit->setName( aName.toStdString(), mySection ); if( !myEdit )
myEdit->setType( aSectType, mySection ); return;
myEdit->finishOperation(); QString aName = myNewSectionEditor->getName();
mySectionView->sectionChanged(mySection); bool isClosed = myNewSectionEditor->isClosed();
updateUndoRedo(); 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 ) void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
{ {
if( !myNewPointEditor ) if( !myNewPointEditor || !myEdit )
return;
if( !myEdit )
return; return;
mySection = theSection;
myPointNum = thePoint;
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection)); QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
myNewPointEditor->setEditMode(true); myNewPointEditor->setEditMode(true);
myNewPointEditor->setSectionName(aSectName); myNewPointEditor->setSectionName(aSectName);
myNewPointEditor->setDimension( myCurve->getDimension() ); myNewPointEditor->setDimension( myCurve->getDimension() );
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint); CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
myNewPointEditor->setCoordinates(aCoords); myNewPointEditor->setCoordinates(aCoords);
if( myNewPointEditor->exec() == QDialog::Accepted ){ emit subOperationStarted( myNewPointEditor );
aCoords = myNewPointEditor->getCoordinates(); }
myEdit->setCoordinates(aCoords, theSection, thePoint);
mySectionView->pointDataChanged(theSection, thePoint ); void CurveCreator_Widget::onModifyPoint()
updateUndoRedo(); {
} if( !myEdit )
return;
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
myEdit->setCoordinates( aCoords, mySection, myPointNum );
mySectionView->pointDataChanged( mySection, myPointNum );
updateUndoRedo();
onCancelPoint();
} }
void CurveCreator_Widget::onJoin() void CurveCreator_Widget::onJoin()
@ -689,3 +735,43 @@ QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints()
{ {
return mySectionView->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 );
}
}

View File

@ -4,9 +4,10 @@
#include "CurveCreator_Curve.hxx" #include "CurveCreator_Curve.hxx"
#include <QWidget> #include <QWidget>
#include <QMap> #include <QMap>
#include <SUIT_ViewWindow.h>
class QAction; class QAction;
class QPixmap; class QPixmap;
class CurveCreator_CurveEditor; class CurveCreator_CurveEditor;
@ -29,6 +30,8 @@ public:
signals: signals:
void selectionChanged(); void selectionChanged();
void subOperationStarted( QWidget* );
void subOperationFinished( QWidget* );
public slots: public slots:
@ -40,6 +43,10 @@ protected slots:
void onAddNewSection(); void onAddNewSection();
void onEditSection( int theSection ); void onEditSection( int theSection );
void onEditPoint( int theSection, int thePoint ); void onEditPoint( int theSection, int thePoint );
void onModifyPoint();
void onModifySection();
void onCancelPoint();
void onCancelSection();
void onJoin(); void onJoin();
void onRemove(); void onRemove();
void onMoveUp(); void onMoveUp();
@ -58,6 +65,7 @@ protected slots:
void onRedo(); void onRedo();
void onUndoSettings(); void onUndoSettings();
void onContextMenu(QPoint thePoint); void onContextMenu(QPoint thePoint);
void onMousePress( SUIT_ViewWindow*, QMouseEvent* );
protected: protected:
enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, NEW_POINT_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID, 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, JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,

View File

@ -81,14 +81,26 @@ endif
# additional information to compile and link file # additional information to compile and link file
libCurveCreator_la_CPPFLAGS = \ libCurveCreator_la_CPPFLAGS = \
$(QT_INCLUDES) \ $(QT_INCLUDES) \
$(CAS_CPPFLAGS) \ $(CAS_CPPFLAGS) \
$(KERNEL_CXXFLAGS) \ $(KERNEL_CXXFLAGS) \
$(GUI_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) \ libCurveCreator_la_LDFLAGS = \
$(CAS_KERNEL) \ $(QT_MT_LIBS) \
$(KERNEL_LDFLAGS) \ $(CAS_KERNEL) \
$(GUI_LDFLAGS) -lqtx -lsuit $(CAS_VIEWER) \
$(OCCViewer) \
$(KERNEL_LDFLAGS) \
$(GUI_LDFLAGS) -lqtx -lsuit \
../GEOMUtils/libGEOM.la \
../GEOMUtils/libGEOMUtils.la \
../GEOMUtils/libGEOMBase.la

View File

@ -28,6 +28,7 @@
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include "GeometryGUI_Operations.h" #include "GeometryGUI_Operations.h"
#include <GEOMUtils.hxx>
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
@ -152,7 +153,7 @@ bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWi
} }
else { else {
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); 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(); Qt::KeyboardModifiers modifiers = pe->modifiers();
@ -240,7 +241,7 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
if ( aSketcherDlg->acceptMouseEvent() ) if ( aSketcherDlg->acceptMouseEvent() )
{ {
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); 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(); Qt::KeyboardModifiers modifiers = pe->modifiers();
if (QApplication::mouseButtons() == Qt::LeftButton ) if (QApplication::mouseButtons() == Qt::LeftButton )
@ -251,32 +252,6 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
return false; 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() // function : DisplaySimulationShape()
// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape

View File

@ -32,7 +32,6 @@
#include <SALOMEDSClient.hxx> #include <SALOMEDSClient.hxx>
#include <AIS_Shape.hxx> #include <AIS_Shape.hxx>
#include <V3d_View.hxx>
class TopoDS_Shape; class TopoDS_Shape;
@ -52,8 +51,6 @@ public :
bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow ); bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
bool OnMouseRelease( 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 DisplaySimulationShape( const TopoDS_Shape&, const TopoDS_Shape& );
void EraseSimulationShape(); void EraseSimulationShape();

View File

@ -112,6 +112,7 @@ libEntityGUI_la_CPPFLAGS = \
-I$(srcdir)/../GEOMImpl \ -I$(srcdir)/../GEOMImpl \
-I$(srcdir)/../GEOMFiltersSelection \ -I$(srcdir)/../GEOMFiltersSelection \
-I$(srcdir)/../SKETCHER \ -I$(srcdir)/../SKETCHER \
-I$(srcdir)/../GEOMUtils \
-I$(ShapeRec_dir) \ -I$(ShapeRec_dir) \
-I$(srcdir)/../GEOM \ -I$(srcdir)/../GEOM \
-I$(top_builddir)/src/DlgRef \ -I$(top_builddir)/src/DlgRef \
@ -123,7 +124,8 @@ libEntityGUI_la_LDFLAGS = \
../GEOMBase/libGEOMBase.la \ ../GEOMBase/libGEOMBase.la \
../SKETCHER/libGEOMSketcher.la \ ../SKETCHER/libGEOMSketcher.la \
../GEOMGUI/libGEOM.la \ ../GEOMGUI/libGEOM.la \
../GEOMUtils/libGEOMUtils.la \
$(ShapeRec_la) \ $(ShapeRec_la) \
$(QT_MT_LIBS) \ $(QT_MT_LIBS) \
$(CAS_TKTopAlgo) -lTKernel \ $(CAS_TKTopAlgo) -lTKernel \
$(Opencv_libs) $(Opencv_libs)

View File

@ -64,7 +64,7 @@
// Function : getActiveView // Function : getActiveView
// Purpose : Get active view window, returns 0 if no open study frame // 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(); SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
if ( activeStudy ) if ( activeStudy )

View File

@ -61,6 +61,7 @@ class GEOMBASE_EXPORT GEOMBase_Helper
public: public:
GEOMBase_Helper( SUIT_Desktop* ); GEOMBase_Helper( SUIT_Desktop* );
virtual ~GEOMBase_Helper(); virtual ~GEOMBase_Helper();
static SUIT_ViewWindow* getActiveView();
protected: protected:
static GEOM::GEOM_Gen_ptr getGeomEngine(); static GEOM::GEOM_Gen_ptr getGeomEngine();

View File

@ -72,6 +72,9 @@
#include <gp_Pln.hxx> #include <gp_Pln.hxx>
#include <gp_Lin.hxx> #include <gp_Lin.hxx>
#include <ProjLib.hxx>
#include <ElSLib.hxx>
#include <vector> #include <vector>
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
@ -600,3 +603,29 @@ TopoDS_Shape GEOMUtils::GetEdgeNearPoint (const TopoDS_Shape& theShape,
return aResult; 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;
}

View File

@ -33,6 +33,8 @@
#include <gp_Ax3.hxx> #include <gp_Ax3.hxx>
#include <gp_Vec.hxx> #include <gp_Vec.hxx>
#include <V3d_View.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
#include <functional> #include <functional>
@ -132,6 +134,16 @@ class GEOMUtils {
Standard_EXPORT static TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape, Standard_EXPORT static TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape,
const TopoDS_Vertex& thePoint); 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 #endif

View File

@ -54,5 +54,5 @@ libGEOMUtils_la_LDFLAGS = \
../ARCHIMEDE/libGEOMArchimede.la \ ../ARCHIMEDE/libGEOMArchimede.la \
../SKETCHER/libGEOMSketcher.la \ ../SKETCHER/libGEOMSketcher.la \
$(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \ $(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \
$(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat \ $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat -lTKV3d \
$(STDLIB) $(STDLIB)

View File

@ -30,6 +30,8 @@
#include <SUIT_Session.h> #include <SUIT_Session.h>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <OCCViewer_ViewWindow.h>
#include <SUIT_ViewManager.h>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
@ -100,7 +102,11 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
static CurveCreator_Curve *aStaticCurve = NULL; static CurveCreator_Curve *aStaticCurve = NULL;
if (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); QDialog *aDialog = new QDialog(parent);