//
#include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Document.h>
#include <BRepBuilderAPI_MakeEdge2d.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
template<class T> void append( std::vector<T>& theList, const std::vector<T>& theList2 )
{
}
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline,
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
const gp_Pnt2d& thePoint ) const
{
std::vector<gp_Pnt2d> aPointsList( 1 );
for( int i=0, n=aCurves.size(); i<n; i++ )
{
std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( aCurves[i], aPointsList );
- bool isLocalOK = CreatePolylines( aCurvesList );
+ bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
isOK = isOK && isLocalOK;
}
return isOK;
}
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline,
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
const Handle( HYDROData_PolylineXY )& theTool ) const
{
std::vector<Handle( Geom2d_Curve )> aCurves = GetCurves( thePolyline );
{
std::vector<gp_Pnt2d> aPointsList = Intersection( aCurves[i], aToolCurves[j] );
std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( aCurves[i], aPointsList );
- bool isLocalOK = CreatePolylines( aCurvesList );
+ bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
isOK = isOK && isLocalOK;
}
return isOK;
}
-bool HYDROData_PolylineOperator::Split( const HYDROData_SequenceOfObjects& thePolylines )
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const HYDROData_SequenceOfObjects& thePolylines )
{
int f = thePolylines.Lower(), l = thePolylines.Upper();
bool isOK = true;
append( aCompletePointsList, aPointsList );
}
std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( anAllCurves[i], aCompletePointsList );
- bool isLocalOK = CreatePolylines( aCurvesList );
+ bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
isOK = isOK && isLocalOK;
}
return isOK;
}
-bool HYDROData_PolylineOperator::Merge( const HYDROData_SequenceOfObjects& thePolylines )
+bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theName,
+ const HYDROData_SequenceOfObjects& thePolylines )
{
//TODO
return true;
return aResult;
}
-bool HYDROData_PolylineOperator::CreatePolylines( const std::vector<Handle( Geom2d_Curve )>& theCurves )
+bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const std::vector<Handle( Geom2d_Curve )>& theCurves )
{
+ if( theDoc.IsNull() )
+ return false;
+
int n = theCurves.size();
for( int i=0; i<n; i++ )
{
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge2d( theCurves[i] ).Edge();
- //TODO
+ BRepBuilderAPI_MakeWire aMakeWire;
+ aMakeWire.Add( anEdge );
+
+ Handle( HYDROData_PolylineXY ) aPolyline =
+ Handle( HYDROData_PolylineXY )::DownCast( theDoc->CreateObject( KIND_POLYLINEXY ) );
+ if( aPolyline.IsNull() )
+ return false;
+
+ aPolyline->SetShape( aMakeWire.Wire() );
+ //TODO: set name
}
return true;
}
#include <gp_Pnt2d.hxx>
#include <vector>
-class HYDROData_PolylineOperator
+class Handle( HYDROData_Document );
+
+class HYDRODATA_EXPORT HYDROData_PolylineOperator
{
public:
- HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& thePolyline,
- const gp_Pnt2d& thePoint ) const;
- HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& thePolyline,
- const Handle( HYDROData_PolylineXY )& theTool ) const;
- HYDRODATA_EXPORT bool Split( const HYDROData_SequenceOfObjects& thePolylines );
- HYDRODATA_EXPORT bool Merge( const HYDROData_SequenceOfObjects& thePolylines );
-
- static HYDRODATA_EXPORT std::vector<Handle( Geom2d_Curve )> GetCurves( const Handle( HYDROData_PolylineXY )& thePolyline );
-
- static HYDRODATA_EXPORT std::vector<gp_Pnt2d> Intersection( const Handle( Geom2d_Curve )& theCurve,
- const Handle( Geom2d_Curve )& theTool );
-
- static HYDRODATA_EXPORT std::vector<Handle( Geom2d_Curve )> Split( const Handle( Geom2d_Curve )& theCurve,
- const std::vector<gp_Pnt2d>& thePoints );
-
- static HYDRODATA_EXPORT bool CreatePolylines( const std::vector<Handle( Geom2d_Curve )>& theCurves );
+ bool Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
+ const gp_Pnt2d& thePoint ) const;
+ bool Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
+ const Handle( HYDROData_PolylineXY )& theTool ) const;
+ bool Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const HYDROData_SequenceOfObjects& thePolylines );
+ bool Merge( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theName,
+ const HYDROData_SequenceOfObjects& thePolylines );
+
+protected:
+ static std::vector<Handle( Geom2d_Curve )> GetCurves( const Handle( HYDROData_PolylineXY )& thePolyline );
+
+ static std::vector<gp_Pnt2d> Intersection( const Handle( Geom2d_Curve )& theCurve,
+ const Handle( Geom2d_Curve )& theTool );
+
+ static std::vector<Handle( Geom2d_Curve )> Split( const Handle( Geom2d_Curve )& theCurve,
+ const std::vector<gp_Pnt2d>& thePoints );
+
+ static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const std::vector<Handle( Geom2d_Curve )>& theCurves );
};
#endif
return getPolylineShape();
}
+bool HYDROData_PolylineXY::SetShape( const TopoDS_Shape& theShape )
+{
+ setPolylineShape( theShape );
+ return true;
+}
+
bool convertEdgeToSection( const TopoDS_Edge& theEdge,
NCollection_Sequence<TCollection_AsciiString>& theSectNames,
NCollection_Sequence<HYDROData_PolylineXY::SectionType>& theSectTypes,
* Returns the 2D presentation of all points.
*/
HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
+ HYDRODATA_EXPORT bool SetShape( const TopoDS_Shape& theShape );
/**
* Returns the 3D presentation of all points.
*/
HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape );
-
/**
* Returns flag indicating that polyline can be edited or not.
*/
#include <HYDROGUI_MergePolylinesDlg.h>
#include <HYDROGUI_ObjListBox.h>
#include <QFrame>
+#include <QLabel>
#include <QGridLayout>
+#include <QLineEdit>
HYDROGUI_MergePolylinesDlg::HYDROGUI_MergePolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle )
: HYDROGUI_InputPanel( theModule, theTitle )
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
+ myName = new QLineEdit( mainFrame() );
+ aLayout->addWidget( new QLabel( tr( "RESULT_NAME" ) ), 0, 0 );
+ aLayout->addWidget( myName, 0, 1 );
+
myList = new HYDROGUI_ObjListBox( theModule, tr( "POLYLINES" ), KIND_POLYLINEXY, mainFrame() );
- aLayout->addWidget( myList, 0, 0 );
+ aLayout->addWidget( myList, 1, 0, 1, 2 );
}
HYDROGUI_MergePolylinesDlg::~HYDROGUI_MergePolylinesDlg()
{
return myList->setObjectsFromSelection();
}
+
+QString HYDROGUI_MergePolylinesDlg::GetResultName() const
+{
+ return myName->text();
+}
#include <HYDROGUI_InputPanel.h>
#include <HYDROData_Entity.h>
+class QLineEdit;
class HYDROGUI_ObjListBox;
class HYDROGUI_MergePolylinesDlg : public HYDROGUI_InputPanel
HYDROGUI_MergePolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_MergePolylinesDlg();
+ QString GetResultName() const;
HYDROData_SequenceOfObjects selectedPolylines() const;
void setSelectedPolylines( const HYDROData_SequenceOfObjects& );
void setPolylinesFromSelection();
private:
+ QLineEdit* myName;
HYDROGUI_ObjListBox* myList;
};
#include <HYDROGUI_MergePolylinesOp.h>
#include <HYDROGUI_MergePolylinesDlg.h>
#include <HYDROGUI_UpdateFlags.h>
+#include <HYDROData_Document.h>
#include <HYDROData_PolylineOperator.h>
HYDROGUI_MergePolylinesOp::HYDROGUI_MergePolylinesOp( HYDROGUI_Module* theModule )
if ( !aPanel )
return false;
+ QString aName = aPanel->GetResultName();
HYDROData_SequenceOfObjects aPolylinesList = aPanel->selectedPolylines();
HYDROData_PolylineOperator anOp;
- anOp.Merge( aPolylinesList );
+ anOp.Merge( doc(), aName.toLatin1().data(), aPolylinesList );
theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
#include <QGridLayout>
#include <QTabWidget>
#include <QMouseEvent>
+#include <QLineEdit>
#include <gp_Pnt2d.hxx>
const double MIN_COORD = -1000000;
aLayout->setMargin( 5 );
aLayout->setSpacing( 5 );
+ myName = new QLineEdit( mainFrame() );
+ aLayout->addWidget( new QLabel( tr( "RESULT_NAME" ) ), 0, 0 );
+ aLayout->addWidget( myName, 0, 1 );
+
myTab = new QTabWidget( aFrame );
- aLayout->addWidget( myTab, 0, 0 );
+ aLayout->addWidget( myTab, 1, 0, 1, 2 );
QFrame* aPointPage = new QFrame();
myMainPolyline1 = new HYDROGUI_ObjComboBox( theModule, tr( "POLYLINE" ), KIND_POLYLINEXY, aPointPage );
return aViewPort;
}
+
+QString HYDROGUI_SplitPolylinesDlg::GetResultName() const
+{
+ return myName->text();
+}
class OCCViewer_Viewer;
class SUIT_ViewWindow;
class OCCViewer_ViewPort3d;
+class QLineEdit;
class HYDROGUI_SplitPolylinesDlg : public HYDROGUI_InputPanel
{
HYDROGUI_SplitPolylinesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_SplitPolylinesDlg();
- Mode GetMode() const;
+ QString GetResultName() const;
+ Mode GetMode() const;
Handle( HYDROData_PolylineXY ) GetMainPolyline() const;
Handle( HYDROData_PolylineXY ) GetToolPolyline() const;
- gp_Pnt2d GetPoint() const;
- HYDROData_SequenceOfObjects GetPolylines() const;
+ gp_Pnt2d GetPoint() const;
+ HYDROData_SequenceOfObjects GetPolylines() const;
void setPolylinesFromSelection();
void setOCCViewer( OCCViewer_Viewer* theViewer );
OCCViewer_ViewPort3d* getViewPort() const;
private:
- QTabWidget* myTab;
- QtxDoubleSpinBox* myX;
- QtxDoubleSpinBox* myY;
+ QLineEdit* myName;
+ QTabWidget* myTab;
+ QtxDoubleSpinBox* myX;
+ QtxDoubleSpinBox* myY;
HYDROGUI_ObjComboBox* myMainPolyline1;
HYDROGUI_ObjComboBox* myMainPolyline2;
HYDROGUI_ObjComboBox* myToolPolyline;
#include <HYDROGUI_UpdateFlags.h>
#include <HYDROGUI_Shape.h>
#include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Document.h>
#include <LightApp_Application.h>
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewManager.h>
if ( !aPanel )
return false;
+ QString aName = aPanel->GetResultName();
Handle( HYDROData_PolylineXY ) aMainPolyline = aPanel->GetMainPolyline();
Handle( HYDROData_PolylineXY ) aToolPolyline = aPanel->GetToolPolyline();
HYDROData_SequenceOfObjects aPolylinesList = aPanel->GetPolylines();
switch( aPanel->GetMode() )
{
case HYDROGUI_SplitPolylinesDlg::ByPoint:
- anOp.Split( aMainPolyline, aPoint );
+ anOp.Split( doc(), aName.toLatin1().data(), aMainPolyline, aPoint );
break;
case HYDROGUI_SplitPolylinesDlg::ByTool:
- anOp.Split( aMainPolyline, aToolPolyline );
+ anOp.Split( doc(), aName.toLatin1().data(), aMainPolyline, aToolPolyline );
break;
case HYDROGUI_SplitPolylinesDlg::Split:
- anOp.Split( aPolylinesList );
+ anOp.Split( doc(), aName.toLatin1().data(), aPolylinesList );
break;
}
<source>COMPLETE_SPLIT</source>
<translation>Complete split</translation>
</message>
+ <message>
+ <source>RESULT_NAME</source>
+ <translation>Result name prefix:</translation>
+ </message>
</context>
<context>
<source>MERGE_POLYLINES</source>
<translation>Merge polylines</translation>
</message>
+ <message>
+ <source>RESULT_NAME</source>
+ <translation>Result name:</translation>
+ </message>
</context>
<context>