From ec0534f7bb0df6c970a77ccd6788fe6e1381d418 Mon Sep 17 00:00:00 2001 From: isn Date: Fri, 28 Sep 2018 20:38:31 +0300 Subject: [PATCH] Lot 1 (linear&poly distance) --- src/HYDROGUI/CMakeLists.txt | 4 + src/HYDROGUI/HYDROGUI_MeasurementToolDlg.cxx | 131 +++++++ src/HYDROGUI/HYDROGUI_MeasurementToolDlg.h | 63 +++ src/HYDROGUI/HYDROGUI_MeasurementToolOp.cxx | 384 +++++++++++++++++++ src/HYDROGUI/HYDROGUI_MeasurementToolOp.h | 66 ++++ src/HYDROGUI/HYDROGUI_Operations.cxx | 9 + src/HYDROGUI/HYDROGUI_Operations.h | 1 + src/HYDROGUI/resources/HYDROGUI_images.ts | 4 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 42 ++ src/HYDROGUI/resources/icon_meas_tools.png | Bin 0 -> 216 bytes 10 files changed, 704 insertions(+) create mode 100644 src/HYDROGUI/HYDROGUI_MeasurementToolDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_MeasurementToolDlg.h create mode 100644 src/HYDROGUI/HYDROGUI_MeasurementToolOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_MeasurementToolOp.h create mode 100644 src/HYDROGUI/resources/icon_meas_tools.png diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 5d7211b2..683a4e8b 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -157,6 +157,8 @@ set(PROJECT_HEADERS HYDROGUI_ShowAttrPolyOp.h HYDROGUI_SetBoundaryTypePolygonOp.h HYDROGUI_SetBoundaryTypePolygonDlg.h + HYDROGUI_MeasurementToolOp.h + HYDROGUI_MeasurementToolDlg.h ) QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS}) @@ -316,6 +318,8 @@ set(PROJECT_SOURCES HYDROGUI_ShowAttrPolyOp.cxx HYDROGUI_SetBoundaryTypePolygonOp.cxx HYDROGUI_SetBoundaryTypePolygonDlg.cxx + HYDROGUI_MeasurementToolOp.cxx + HYDROGUI_MeasurementToolDlg.cxx ) add_definitions( diff --git a/src/HYDROGUI/HYDROGUI_MeasurementToolDlg.cxx b/src/HYDROGUI/HYDROGUI_MeasurementToolDlg.cxx new file mode 100644 index 00000000..a623a7b8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_MeasurementToolDlg.cxx @@ -0,0 +1,131 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_MeasurementToolDlg.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +HYDROGUI_MeasurementToolDlg::HYDROGUI_MeasurementToolDlg( QWidget* theParent ) + : QDialog( theParent ), myExit (false) +{ + QFormLayout* aMLayout = new QFormLayout( this ); + + mySwitcherLD = new QRadioButton(tr("LINEAR_DISTANCE")); + QRadioButton* aSwitcherPD = new QRadioButton(tr("POLYLINE_DISTANCE")); + + myPolylinesCBox = new QComboBox( this ); + + aMLayout->addRow(mySwitcherLD); + aMLayout->addRow(aSwitcherPD, myPolylinesCBox); + + myTotalDst = new QLineEdit( this ); + myTotalDst->setReadOnly(true); + + aMLayout->addRow(new QLabel(tr("TOTAL_DST")), myTotalDst); + + QPushButton* aClearButton = new QPushButton( tr("CLEAR") ); + + QPushButton* aCloseButton = new QPushButton( tr("CLOSE"), this ); + + QGroupBox* aPolyLenGroup = new QGroupBox(tr("POLYLINES_LENGTH")); + QVBoxLayout* aPolyLayout = new QVBoxLayout( aPolyLenGroup ); + + aMLayout->addRow(aClearButton, aCloseButton); + //// + connect( aClearButton, SIGNAL( clicked() ), this, SLOT( onClear () ) ); + connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( this, SIGNAL( rejected() ), this, SLOT( onExit () ) ); + connect( mySwitcherLD, SIGNAL( toggled(bool) ), this, SLOT( onSetMode (bool) ) ); + connect( myPolylinesCBox, SIGNAL( currentIndexChanged(int) ), this, SLOT( onClear () ) ); + + mySwitcherLD->setChecked(true); + + setLayout(aMLayout); +} + +HYDROGUI_MeasurementToolDlg::~HYDROGUI_MeasurementToolDlg() +{ +} + +void HYDROGUI_MeasurementToolDlg::setTotalDst(QString strVal) +{ + myTotalDst->setText(strVal); +} + +bool HYDROGUI_MeasurementToolDlg::IsLDChecked() const +{ + return mySwitcherLD->isChecked(); +} + +void HYDROGUI_MeasurementToolDlg::setPolylineNames(QStringList thePolyNames) +{ + myPolylinesCBox->clear(); + foreach (QString aName, thePolyNames) + myPolylinesCBox->addItem(aName); +} + +int HYDROGUI_MeasurementToolDlg::currentSelectedPolyline() const +{ + return myPolylinesCBox->currentIndex(); +} + +bool HYDROGUI_MeasurementToolDlg::GetExitFlag() const +{ + return myExit; +} + +void HYDROGUI_MeasurementToolDlg::onExit() +{ + myExit = true; + emit doExit(); +} + +void HYDROGUI_MeasurementToolDlg::onClear() +{ + emit clearLine(); +} + +void HYDROGUI_MeasurementToolDlg::onSetMode(bool mode) +{ + emit onClear(); + if (mode) + myPolylinesCBox->setDisabled(true); + else + myPolylinesCBox->setDisabled(false); +} + + + diff --git a/src/HYDROGUI/HYDROGUI_MeasurementToolDlg.h b/src/HYDROGUI/HYDROGUI_MeasurementToolDlg.h new file mode 100644 index 00000000..177402a8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_MeasurementToolDlg.h @@ -0,0 +1,63 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + + + +#ifndef HYDROGUI_MEASUREMENTTOOLDLG_H +#define HYDROGUI_MEASUREMENTTOOLDLG_H + +#include +#include + +class QLineEdit; +class QRadioButton; +class QComboBox; + +class HYDROGUI_MeasurementToolDlg : public QDialog +{ + Q_OBJECT + +public: + + HYDROGUI_MeasurementToolDlg( QWidget* theParent ); + virtual ~HYDROGUI_MeasurementToolDlg(); + + void setTotalDst(QString strVal); + int currentSelectedPolyline() const; + bool GetExitFlag() const; + bool IsLDChecked() const; + void setPolylineNames(QStringList thePolyNames); + +private slots: + void onClear(); + void onSetMode(bool mode); + void onExit(); + +signals: + void clearLine(); + void doExit(); + +private: + + bool myExit; + QLineEdit* myTotalDst; + QRadioButton* mySwitcherLD; + QComboBox* myPolylinesCBox; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_MeasurementToolOp.cxx b/src/HYDROGUI/HYDROGUI_MeasurementToolOp.cxx new file mode 100644 index 00000000..f0fd3540 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_MeasurementToolOp.cxx @@ -0,0 +1,384 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_MeasurementToolOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +HYDROGUI_MeasurementToolOp::HYDROGUI_MeasurementToolOp( HYDROGUI_Module* theModule ) + : HYDROGUI_Operation( theModule ), + myMeasDlg(0), + myLineMaker(NULL), + myAISLineM(NULL), + myDist(0), + // myFAd(NULL), + myFu(0) +{ + setName( tr( "MEASUREMENT_TOOL" ) ); +} + +HYDROGUI_MeasurementToolOp::~HYDROGUI_MeasurementToolOp() +{ + if (myLineMaker) + delete myLineMaker; +} + +void HYDROGUI_MeasurementToolOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + myMeasDlg = new HYDROGUI_MeasurementToolDlg( module()->getApp()->desktop() ); + myMeasDlg->setModal( false ); + myMeasDlg->setWindowTitle(getName()); + myMeasDlg->show(); + + //Tool: draw a distance line + LightApp_Application* anApp = module()->getApp(); + OCCViewer_ViewManager* aViewManager = + dynamic_cast( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ); + + setPreviewManager( aViewManager ); + + connect( myMeasDlg, SIGNAL( clearLine() ), this, SLOT( onClearLine() ) ); + + connect( myMeasDlg, SIGNAL( doExit() ), this, SLOT( onExit() ) ); + + OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer(); + + disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + aViewer, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + + //polyline names + HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY ); + QStringList aPolylineNames; + myPolyObjs.clear(); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() ); + myPolyObjs.push_back(aPolylineObj); + aPolylineNames << aPolylineObj->GetName(); + } + myMeasDlg->setPolylineNames(aPolylineNames); +} + +void HYDROGUI_MeasurementToolOp::onClearLine() +{ + eraseLine(); + myDist = 0; + //myPolyObjs.clear(); + myMeasDlg->setTotalDst(0); + delete myLineMaker; + myLineMaker = NULL; + myFW = TopoDS_Wire(); +} + +void HYDROGUI_MeasurementToolOp::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) +{ + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( !aViewManager ) + return; + + OCCViewer_ViewWindow* aViewWindow = (OCCViewer_ViewWindow*)aViewManager->getActiveView(); + if ( !aViewWindow ) + return; + + OCCViewer_ViewPort3d* aViewPort = aViewWindow->getViewPort(); + if ( !aViewPort ) + return; + + Handle(V3d_View) aView = aViewPort->getView(); + if ( aView.IsNull() ) + return; + + OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer(); + if ( !aViewer ) + return; + + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( aCtx.IsNull() ) + return; + + gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(), aView ); + + TopoDS_Shape aRes; + + if (myMeasDlg->IsLDChecked()) + { + if (!myLineMaker) + { + myLineMaker = new BRepLib_MakePolygon(); + myLineMaker->Add(aPnt); + aRes = myLineMaker->FirstVertex(); + } + else + { + myLineMaker->Add(aPnt); + aRes = myLineMaker->Shape(); + const TopoDS_Edge& aLE = myLineMaker->Edge(); + TopoDS_Vertex aFV = TopExp::FirstVertex(aLE, true); + TopoDS_Vertex aLV = TopExp::LastVertex(aLE, true); + double aNDist = BRep_Tool::Pnt(aFV).Distance(BRep_Tool::Pnt(aLV)); + myDist += aNDist; + myMeasDlg->setTotalDst(QString::number(myDist)); + } + + if ( !myAISLineM.IsNull() ) + { + if ( aCtx->HasOpenedContext() ) + aCtx->CloseLocalContext(); + aCtx->Erase( myAISLineM, Standard_False ); + } + } + else + { + double prec = 70; //minimum precision + int selectInd = myMeasDlg->currentSelectedPolyline(); + if (selectInd == -1) + return; + Handle(HYDROData_PolylineXY) aPolylineObj = myPolyObjs[selectInd]; + TopoDS_Shape aShape = aPolylineObj->GetShape(); + TopExp_Explorer exp(aShape, TopAbs_WIRE); + double fdist_min = RealLast(); + TopoDS_Wire minWire; + BRepAdaptor_Curve minC; + double minU; + for (;exp.More(); exp.Next()) + { + TopoDS_Wire W = TopoDS::Wire(exp.Current()); + if (W.IsNull()) + continue; + TopExp_Explorer expW(W, TopAbs_EDGE); + if (!expW.More()) + continue; + TopoDS_Edge E = TopoDS::Edge(expW.Current()); + expW.Next(); + if (expW.More()) + E = BRepAlgo::ConcatenateWireC0(W); + BRepAdaptor_Curve Ad(E); + Handle(Geom_BSplineCurve) aBsp = Ad.Curve().BSpline(); + std::vector params; + double Fp = Ad.FirstParameter(); + double Lp = Ad.LastParameter(); + params.push_back(Fp); + params.push_back(Lp); + if (!aBsp.IsNull()) + { + TColStd_Array1OfReal aKnots = aBsp->Knots(); + for (int i = 1; i <= aKnots.Size(); i++) + { + if (aKnots(i) > Fp && aKnots(i) < Lp) + params.push_back(aKnots(i)); + } + } + //in some cases, extrema gives inaccurate result -> + //split bspline by knot params and try to find minimum distance + //on each interval + std::sort(params.begin(), params.end()); + for (int i = 0; i < params.size() - 1; i++ ) + { + //Extrema_ExtPC extrema(aPnt, Ad, params[i], params[i+1]); + GeomAPI_ProjectPointOnCurve aProj; //extrema wrapper + aProj.Init (aPnt, Ad.Curve().Curve(), params[i], params[i+1]); + if (aProj.NbPoints() > 0) + { + double fdist = aProj.LowerDistance(); + gp_Pnt aFP = aProj.NearestPoint(); + int x1=-1, y1=-1, x2=-1, y2=-1; + CurveCreator_Utils::ConvertPointToClick(aPnt, aView, x1, y1); + CurveCreator_Utils::ConvertPointToClick(aFP, aView, x2, y2); + gp_Pnt2d pp1((double)x1, (double)y1); + gp_Pnt2d pp2((double)x2, (double)y2); + int aWinSX, aWinSY; + aView->Window()->Size(aWinSX, aWinSY); + double pd = pp1.Distance(pp2); + double WinDiagDist = sqrt ((double)aWinSX*(double)aWinSX + (double)aWinSY*(double)aWinSY); + if (fdist <= prec || pd / WinDiagDist < 0.08) + { + if (fdist < fdist_min) + { + fdist_min = fdist; + minWire = W; + minU = aProj.LowerDistanceParameter(); + minC.Initialize(E); + } + } + } + } + } + // + if (!minWire.IsNull()) + { + if (myFW.IsNull()) + { + myFu = minU; + myFW = minWire; + aRes = BRepLib_MakeVertex(aPnt); + } + else + { + if (myFW.IsSame(minWire)) + { + //calc distance on current curve + double LenAlongCurv = GCPnts_AbscissaPoint::Length(minC, myFu, minU); + myFW = TopoDS_Wire(); + if (!BRep_Tool::IsClosed(minWire)) + { + aRes = BRepLib_MakeEdge(minC.Curve().Curve(), Min(myFu, minU), Max (myFu, minU)); + myMeasDlg->setTotalDst(QString::number(LenAlongCurv)); + } + else + { + double Len2 = GCPnts_AbscissaPoint::Length(minC) - LenAlongCurv; + if (LenAlongCurv < Len2) + aRes = BRepLib_MakeEdge(minC.Curve().Curve(), Min(myFu, minU), Max (myFu, minU)); + else + { + TopoDS_Compound aCmpEd; + BRep_Builder aB; + aB.MakeCompound(aCmpEd); + aB.Add(aCmpEd, BRepLib_MakeEdge(minC.Curve().Curve(), minC.FirstParameter(), Min(myFu, minU))); + aB.Add(aCmpEd, BRepLib_MakeEdge(minC.Curve().Curve(), Max(myFu, minU), minC.LastParameter())); + aRes = aCmpEd; + } + myMeasDlg->setTotalDst(QString::number(LenAlongCurv) + ", " + QString::number(Len2)); + } + } + } + } + } + + if (aRes.IsNull()) + return; + + aCtx->Erase( myAISLineM, Standard_False ); + + myAISLineM = new AIS_Shape( aRes ); + + myAISLineM->SetColor( Quantity_NOC_ORANGE ); + //Handle(Prs3d_Drawer) aHA = myAISLineM->HilightAttributes(); + + myAISLineM->SetWidth( 3 ); + //Handle(Prs3d_PointAspect) anAspect = mySplitPointPreview->Attributes()->PointAspect(); + //anAspect->SetScale(2.0); + //anAspect->SetTypeOfMarker(Aspect_TOM_RING1); + //anAspect->SetColor(Quantity_NOC_BLACK); + //mySplitPointPreview->Attributes()->SetPointAspect( anAspect ); + + aCtx->SetZLayer(myAISLineM, Graphic3d_ZLayerId_Topmost); + + if ( aCtx->HasOpenedContext() ) + aCtx->CloseLocalContext(); + aCtx->Display( myAISLineM, Standard_False ); + aCtx->UpdateCurrentViewer(); +} + +void HYDROGUI_MeasurementToolOp::eraseLine() +{ + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( aViewManager ) + { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) + { + if ( !myAISLineM.IsNull() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( !aCtx.IsNull() ) + { + if ( aCtx->HasOpenedContext() ) + aCtx->CloseLocalContext(); + aCtx->Erase( myAISLineM, Standard_False ); + } + myAISLineM.Nullify(); + aCtx->UpdateCurrentViewer(); + } + } + } +} + +void HYDROGUI_MeasurementToolOp::abortOperation() +{ + if (!myMeasDlg->GetExitFlag()) + myMeasDlg->done(0); +} + +void HYDROGUI_MeasurementToolOp::onExit() +{ + onClearLine(); + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer(); + + if (aViewManager && aViewer) + { + disconnect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + + connect(aViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), + aViewManager->getOCCViewer(), SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + } + + if (myLineMaker) + delete myLineMaker; + + this->blockSignals(true); + HYDROGUI_Operation::abort(); + this->blockSignals(false); +} + + + + + diff --git a/src/HYDROGUI/HYDROGUI_MeasurementToolOp.h b/src/HYDROGUI/HYDROGUI_MeasurementToolOp.h new file mode 100644 index 00000000..c09389e9 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_MeasurementToolOp.h @@ -0,0 +1,66 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_MEASUREMENTTOOLOP_H +#define HYDROGUI_MEASUREMENTTOOLOP_H + +#include "HYDROGUI_Operation.h" + +#include +#include +#include + +class HYDROGUI_MeasurementToolDlg; +class QMouseEvent; +class SUIT_ViewWindow; +class HYDROData_PolylineXY; +class BRepLib_MakePolygon; + +class HYDROGUI_MeasurementToolOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_MeasurementToolOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_MeasurementToolOp(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + +protected slots: + void onMousePress(SUIT_ViewWindow*, QMouseEvent*); + void onClearLine(); + void onExit(); + +private: + void eraseLine(); + +private: + + Handle(AIS_Shape) myAISLineM; + BRepLib_MakePolygon* myLineMaker; + HYDROGUI_MeasurementToolDlg* myMeasDlg; + double myDist; + TopoDS_Wire myFW; + double myFu; + std::vector myPolyObjs; + +}; + +#endif \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index cf5d70f8..8c459d9a 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -45,6 +45,7 @@ #include "HYDROGUI_UpdateObjectOp.h" #include "HYDROGUI_VisualStateOp.h" #include "HYDROGUI_ImmersibleZoneOp.h" +#include "HYDROGUI_MeasurementToolOp.h" #include "HYDROGUI_ImportGeomObjectOp.h" #include "HYDROGUI_ImportObstacleFromFileOp.h" #include "HYDROGUI_TranslateObstacleOp.h" @@ -147,6 +148,8 @@ void HYDROGUI_Module::createActions() createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" ); createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" ); + createAction( MeasurementToolId, "MEASUREMENT_TOOL", "MEASUREMENT_TOOL_ICO" ); + createAction( ImportBCPolygonId, "IMPORT_BC_POLYGON", "IMPORT_BC_POLYGON_ICO" ); createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" ); @@ -288,6 +291,8 @@ void HYDROGUI_Module::createMenus() createMenu( CreateChannelId, aHydroId, -1, -1 ); createMenu( CreateDigueId, aHydroId, -1, -1 ); + createMenu( MeasurementToolId, aHydroId, -1, -1 ); + int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 ); createMenu( ImportImageId, aNewImageId, -1, -1 ); createMenu( separator(), aNewImageId ); @@ -355,6 +360,7 @@ void HYDROGUI_Module::createToolbars() createTool( ImportLandCoverMapId, aToolBar ); createTool( ImportBCPolygonId, aToolBar ); + createTool( MeasurementToolId, aToolBar ); createTool( ImportBathymetryId, aToolBar ); createTool( CreatePolylineId, aToolBar ); @@ -632,6 +638,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case ImportBCPolygonId: anOp = new HYDROGUI_ImportBCPolygonOp( aModule ); break; + case MeasurementToolId: + anOp = new HYDROGUI_MeasurementToolOp( aModule ); + break; case ObserveImageId: anOp = new HYDROGUI_ObserveImageOp( aModule ); break; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index e17c2d28..c1aac72b 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -115,6 +115,7 @@ enum OperationId ImportSinusXId, ExportSinusXId, ImportBCPolygonId, + MeasurementToolId, ExportToShapeFileID, ImportLandCoverMapId, diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index c2d89248..ba88e887 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -635,5 +635,9 @@ IMPORT_BC_POLYGON_ICO icon_bc_import.png + + MEASUREMENT_TOOL_ICO + icon_meas_tools.png + diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index d725e9c1..a3fa8e50 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -1051,6 +1051,10 @@ Would you like to remove all references from the image? DSK_IMPORT_SINUSX Import from SinusX + + DSK_MEASUREMENT_TOOL + Measurement tool + DSK_IMPORT_BC_POLYGON Import boundary polygons from SHP file @@ -1448,6 +1452,10 @@ Would you like to remove all references from the image? MEN_IMPORT_SINUSX Import from SinusX + + MEN_MEASUREMENT_TOOL + Measurement tool + MEN_EXPORT_SINUSX Export to SinusX @@ -1804,6 +1812,10 @@ Would you like to remove all references from the image? STB_IMPORT_SINUSX Import from SinusX + + STB_MEASUREMENT_TOOL + Measurement tool + STB_EXPORT_SINUSX Export to SinusX @@ -3716,7 +3728,37 @@ Polyline should consist from one not closed curve. SELECTION_TOOL Selection tool + + + HYDROGUI_MeasurementToolDlg + + LINEAR_DISTANCE + Linear distance + + + POLYLINE_DISTANCE + Distance on polyline: + + + TOTAL_DST + Distance: + + + CLEAR + Clear + + + CLOSE + Close + + + + HYDROGUI_MeasurementToolOp + + MEASUREMENT_TOOL + Measurement Tool + diff --git a/src/HYDROGUI/resources/icon_meas_tools.png b/src/HYDROGUI/resources/icon_meas_tools.png new file mode 100644 index 0000000000000000000000000000000000000000..d2b2c54f8d680ee010d1d920c58387414b83a9de GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1qucLCF%=h?3y^w370~qEv>0#LT=By}Z;C1rt33 zJwr2>%=KS^iab1B978Pp&-PgJF(`02@BF`Xbz3Wk=Tl<~n*~c(GGqwOk}P=>nzrS^ zok(A1pUVuFO#~AEpX>P2``22zyDy*1t4E}S<7~MCciTI|*KL1U-vP~J@O1TaS?83{ F1OTM|MH~PC literal 0 HcmV?d00001 -- 2.39.2