//==================================================================================================
BuildAPI_Interpolation::BuildAPI_Interpolation(const FeaturePtr& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const ModelHighAPI_Selection& theStartTangent,
- const ModelHighAPI_Selection& theEndTangent,
- const bool theIsClosed,
- const bool theIsToReorder)
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Selection& theStartTangent,
+ const ModelHighAPI_Selection& theEndTangent,
+ const bool theIsClosed,
+ const bool theIsToReorder)
: ModelHighAPI_Interface(theFeature)
{
- if(initialize()) {
+ if (initialize()) {
fillAttribute(BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID(),mycreationmethod);
setUseTangents(true);
setTangents(theStartTangent, theEndTangent);
}
//==================================================================================================
-BuildAPI_Interpolation::BuildAPI_Interpolation(
- const FeaturePtr& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const bool theIsClosed,
- const bool theIsToReorder)
+BuildAPI_Interpolation::BuildAPI_Interpolation(const FeaturePtr& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const bool theIsClosed,
+ const bool theIsToReorder)
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
FeaturePtr aBase = feature();
std::string aPartName = theDumper.name(aBase->document());
- if( aBase->string(BuildPlugin_Interpolation::CREATION_METHOD_ID())->value() ==
+ if (aBase->string(BuildPlugin_Interpolation::CREATION_METHOD_ID())->value() ==
BuildPlugin_Interpolation::CREATION_METHOD_BY_SELECTION_ID() )
{
AttributeSelectionListPtr anAttrBaseObjects =
}
theDumper << closed() << ", " << reorder() << ")" << std::endl;
- }else{
+ } else {
theDumper << aBase << " = model.addInterpolation(" << aPartName ;
AttributeStringPtr XtAttr = xt();
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultBody.h>
-#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_ResultParameter.h>
#include <GeomAPI_Edge.h>
#include <GeomAPI_Lin.h>
#include <GeomAPI_ShapeExplorer.h>
-#include <ModelAPI_Tools.h>
-
-#include <ModelAPI_Expression.h>
-
#include <algorithm>
-
-#include <iostream>
#include <sstream>
data()->reflist(ARGUMENTS_ID())->setIsArgument(false);
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ARGUMENTS_ID());
- if( string( XT_ID())->value() == ""
+ if ( string( XT_ID())->value() == ""
&& string( YT_ID())->value() == ""
&& string( ZT_ID())->value() == "")
{
}
}
+//=================================================================================================
void BuildPlugin_Interpolation::attributeChanged(const std::string& theID)
{
- if( (theID == XT_ID()
+ if ((theID == XT_ID()
|| theID == YT_ID()
|| theID == ZT_ID()
|| theID == MINT_ID()
}
}
+//=================================================================================================
void BuildPlugin_Interpolation::updateCoordinates()
{
std::wstring exp;
double aMaxt = real(MAXT_ID())->value();
int aNbrStep = integer(NUMSTEP_ID())->value();
- if ( aMaxt < aMint ) {
+ if (aMaxt < aMint) {
setError("The minimum value of the parameter must be less than maximum value !!!" );
}
string(VARIABLE_ID())->setValue("t");
tables(VALUE_ID())->setSize(aNbrStep+1,4);
- for( int step = 0; step <= aNbrStep; step++ ){
+ for (int step = 0; step <= aNbrStep; step++ ){
ModelAPI_AttributeTables::Value aVal;
aVal.myDouble = step * aScale + aMint;
tables(VALUE_ID())->setValue(aVal,step,0);
//=================================================================================================
void BuildPlugin_Interpolation::execute()
{
- if( string(CREATION_METHOD_ID())->value() == CREATION_METHOD_BY_SELECTION_ID() )
+ if (string(CREATION_METHOD_ID())->value() == CREATION_METHOD_BY_SELECTION_ID())
{
// Get closed flag value
bool isClosed = boolean(CLOSED_ID())->value();
setResult(aResultBody);
- }else
- {
- if( string( XT_ID())->value() == ""
+ } else {
+ if (string( XT_ID())->value() == ""
||string( YT_ID())->value() == ""
||string( ZT_ID())->value() == ""
||tables(VALUE_ID())->rows()== 0 )
AttributeTablesPtr aTable = tables( VALUE_ID() );
std::list<std::vector<double> > aCoordPoints;
- for( int step = 0; step < aTable->rows() ; step++ ){
+ for (int step = 0; step < aTable->rows(); step++){
std::vector<double> aCoordPoint;
ModelAPI_AttributeTables::Value value;
//x
std::list<GeomVertexPtr> aVertices;
std::list<std::vector<double> >::const_iterator anItCoordPoints = aCoordPoints.begin();
- for( ; anItCoordPoints != aCoordPoints.end(); ++anItCoordPoints ){
+ for (; anItCoordPoints != aCoordPoints.end(); ++anItCoordPoints){
GeomVertexPtr aVertex =
GeomAlgoAPI_PointBuilder::vertex( (*anItCoordPoints)[0],
}
}
-void BuildPlugin_Interpolation::evaluate(std::string& theError)
+//=================================================================================================
+void BuildPlugin_Interpolation::evaluate(std::string& theError)
{
FeaturePtr aMyPtr = std::dynamic_pointer_cast<ModelAPI_Feature>(data()->owner());
std::shared_ptr<ModelAPI_BuildEvalMessage> aProcessMessage =
/// Creates a new part document if needed.
BUILDPLUGIN_EXPORT virtual void execute();
+ /// Called on change of any argument-attribute of this object.
+ /// \param[in] theID identifier of changed attribute.
BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
protected:
/// Evaluates the expression x(t), y(t),z(t) in value table.
void evaluate(std::string& theError);
- //Update coordinates x,y,z
+ ///Update coordinates x,y,z
void updateCoordinates();
+ ///Output error for python interpreter
std::string outErrorMessage;
};
#include <BuildPlugin_Filling.h>
#include <BuildPlugin_Validators.h>
-
-
-
// the only created instance of this plugin
static BuildPlugin_Plugin* MY_INSTANCE = new BuildPlugin_Plugin();
return true;
}
-
+//=================================================================================================
bool BuildPlugin_ValidatorExpressionInterpolation::isValid(const AttributePtr& theAttribute,
const std::list<std::string>& /*theArguments*/,
Events_InfoMessage& theError) const
Part_5_doc = Part_5.document()
Interpolation_11 = model.addInterpolation(Part_5_doc, "sin(t)","cos(t)","t", 0, 100, 10)
-
-model.checkResult(Interpolation_11, model, 1, [0], [0], [0], [1], [2])
-
+model.do()
+model.testNbResults(Interpolation_11, 1)
+model.end()
# =============================================================================
# Test 13. Check Python dump
# =============================================================================
</box>
<box id="analytical"
title="Curve analytical"
- tooltip="???"
icon="icons/Build/feature_interpolation_analytical.png">
<groupbox title="Curves parameters">
<stringvalue id="xt" label="X(t) equation">
+++ /dev/null
-// Copyright (C) 2014-2020 CEA/DEN, 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 "FeaturesPlugin_WidgetCreator.h"
-#include "FeaturesPlugin_WidgetFilletMultiRadiuses.h"
-
-
-FeaturesPlugin_WidgetCreator::FeaturesPlugin_WidgetCreator()
-: ModuleBase_IWidgetCreator()
-{
- myPanelTypes.insert("multiradius-panel");
- myPanelTypes.insert("multiradiuscurv-panel");
-}
-
-void FeaturesPlugin_WidgetCreator::widgetTypes(std::set<std::string>& theTypes)
-{
- theTypes = myPanelTypes;
-}
-
-
-ModuleBase_ModelWidget* FeaturesPlugin_WidgetCreator::createWidgetByType(
- const std::string& theType,
- QWidget* theParent,
- Config_WidgetAPI* theWidgetApi,
- ModuleBase_IWorkshop* theWorkshop)
-{
- ModuleBase_ModelWidget* aWidget = 0;
- if (myPanelTypes.find(theType) == myPanelTypes.end())
- return aWidget;
-
- if (theType == "multiradius-panel") {
- aWidget = new FeaturesPlugin_WidgetFilletMultiRadiuses(theParent, theWorkshop, theWidgetApi, true);
- }else if (theType == "multiradiuscurv-panel")
- {
- aWidget = new FeaturesPlugin_WidgetFilletMultiRadiuses(theParent, theWorkshop, theWidgetApi, false);
- }
-
-
- return aWidget;
-}
+++ /dev/null
-// Copyright (C) 2014-2020 CEA/DEN, 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 FeaturesPlugin_WidgetCreator_H
-#define FeaturesPlugin_WidgetCreator_H
-
-
-#include "FeaturesPlugin.h"
-#include <ModuleBase_IWidgetCreator.h>
-
-#include <string>
-#include <set>
-
-class QWidget;
-
-/**
-* \ingroup GUI
-* Interface to WidgetCreator which can create specific widgets by type
-*/
-class FeaturesPlugin_WidgetCreator : public ModuleBase_IWidgetCreator
-{
-public:
- /// Default constructor
- FeaturesPlugin_WidgetCreator();
-
- /// Virtual destructor
- ~FeaturesPlugin_WidgetCreator() {}
-
- /// Returns a container of possible page types, which this creator can process
- /// \param theTypes a list of type names
- virtual void widgetTypes(std::set<std::string>& theTypes);
-
- /// Create widget by its type
- /// The default implementation is empty
- /// \param theType a type
- /// \param theParent a parent widget
- /// \param theData a low-level API for reading xml definitions of widgets
- /// \param theWorkshop a current workshop
- /// \return a created model widget or null
- virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType,
- QWidget* theParent,
- Config_WidgetAPI* theWidgetApi,
- ModuleBase_IWorkshop* /*theWorkshop*/);
-private:
- std::set<std::string> myPanelTypes; ///< types of panels
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-// Copyright (C) 2014-2020 CEA/DEN, 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 "FeaturesPlugin_WidgetFilletMultiRadiuses.h"
-#include "FeaturesPlugin_Fillet.h"
-
-#include <ModuleBase_Tools.h>
-#include <ModuleBase_IWorkshop.h>
-#include <ModuleBase_IModule.h>
-#include <ModuleBase_ISelection.h>
-#include <ModuleBase_IPropertyPanel.h>
-
-#include <ModelAPI_AttributeSelectionList.h>
-#include <ModelAPI_AttributeSelection.h>
-#include <ModelAPI_AttributeDoubleArray.h>
-#include <ModelAPI_AttributeDouble.h>
-
-#include <ModelAPI_AttributeInteger.h>
-#include <ModelAPI_AttributeIntArray.h>
-#include <ModelAPI_AttributeString.h>
-
-#include <QLayout>
-#include <QWidget>
-#include <QFormLayout>
-#include <QComboBox>
-#include <QSpinBox>
-#include <QLabel>
-#include <QSlider>
-#include <QTableWidget>
-#include <QPushButton>
-#include <QHeaderView>
-#include <QStackedWidget>
-#include <QValidator>
-#include <QLineEdit>
-#include <QEvent>
-#include <QMouseEvent>
-#include <QScrollBar>
-#include <QApplication>
-#include <qabstractitemmodel.h>
-#include <GeomAlgoAPI_PointBuilder.h>
-#include <GeomAPI_Edge.h>
-#include <GeomAPI_Pnt.h>
-#include <GeomAPI_Curve.h>
-#include <Locale_Convert.h>
-#include <QStandardItem>
-#include <map>
-
-
-const char* MYFirstCol = "Shape";
-const char* MYTrue = "True";
-const char* MYFalse = "False";
-
-
-DataArrayItemDelegate::DataArrayItemDelegate(bool theTypeMethode)
- : QStyledItemDelegate(), myTypeMethodePoint(theTypeMethode)
-{
-}
-
-
-QWidget* DataArrayItemDelegate::createEditor(QWidget* theParent,
- const QStyleOptionViewItem & theOption,
- const QModelIndex& theIndex ) const
-{
- QWidget* aEditor = 0;
- if ((theIndex.column() == 0) && (theIndex.row() > 0 )) {
- QWidget* aWgt = QStyledItemDelegate::createEditor(theParent, theOption, theIndex);
- QLineEdit* aEdt = static_cast<QLineEdit*>(aWgt);
- aEdt->setReadOnly(true);
- aEditor = aEdt;
- } else {
- QLineEdit* aLineEdt = 0;
-
- aLineEdt = dynamic_cast<QLineEdit*>(QStyledItemDelegate::createEditor(theParent,
- theOption,
- theIndex));
- if (aLineEdt) {
- if( theIndex.column() == 2 )
- aLineEdt->setValidator(new QDoubleValidator(0.0 , 10000.0, 6, aLineEdt));
- else
- aLineEdt->setValidator(new QDoubleValidator(0.00001 , 0.9999, 6, aLineEdt));
- aEditor = aLineEdt;
- }
-
- }
-
- connect(aEditor, SIGNAL(textEdited(const QString&)),
- SLOT(onEditItem(const QString&)));
- return aEditor;
-}
-
-void DataArrayItemDelegate::onEditItem(const QString& theText)
-{
- QWidget* aWgt = dynamic_cast<QWidget*>(sender());
- commitData(aWgt);
-}
-
-
-//**********************************************************************************
-//**********************************************************************************
-//**********************************************************************************
-FeaturesPlugin_WidgetFilletMultiRadiuses::
- FeaturesPlugin_WidgetFilletMultiRadiuses(QWidget* theParent,
- ModuleBase_IWorkshop* theWorkshop,
- const Config_WidgetAPI* theData,
- bool TypeMethodeBypoint):
-ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0),
- myTypeMethodeBypoint(TypeMethodeBypoint),mySetSelection(true)
-{
- QVBoxLayout* aMainLayout = new QVBoxLayout(this);
-
- aMainLayout->addWidget(new QLabel("Radii", this));
- // Radiuses controls
- QFrame* aRadiusesFrame = new QFrame(this);
- aRadiusesFrame->setFrameShape( QFrame::HLine );
- aRadiusesFrame->setFrameShape(QFrame::Box);
- aRadiusesFrame->setFrameStyle(QFrame::StyledPanel);
- QVBoxLayout* aRadiusesLayout = new QVBoxLayout();
-
-
- myDataTbl = new QTableWidget(2, 3, aRadiusesFrame);
-
- myDelegate = new DataArrayItemDelegate(myTypeMethodeBypoint);
-
- myDataTbl->installEventFilter(this);
- myDataTbl->setItemDelegate(myDelegate);
-
- myDataTbl->verticalHeader()->hide();
- myDataTbl->setRowHeight(0, 25);
- myDataTbl->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
-
- if(myTypeMethodeBypoint){
- myfirstRowValue.push_back("Start extremity");
- myfirstRowValue.push_back("0");
- myfirstRowValue.push_back("0.5");
- myLastRowValue.push_back("End extremity");
- myLastRowValue.push_back("1");
- myLastRowValue.push_back("0.5");
- }else{
- myfirstRowValue.push_back("0");
- myfirstRowValue.push_back("0");
- myfirstRowValue.push_back("1");
- myLastRowValue.push_back("1");
- myLastRowValue.push_back("1");
- myLastRowValue.push_back("2");
- }
-
- if(myTypeMethodeBypoint)
- myDataTbl->hideColumn(1);
- else
- myDataTbl->hideColumn(0);
-
- QStringList aHeaders;
- aHeaders << "Point";
- aHeaders << "Curvilinear Abscissa";
- aHeaders << "Radius";
-
-
- myDataTbl->setHorizontalHeaderLabels(aHeaders);
-
- QTableWidgetItem* aItem;
- for(int j =0; j<3;j++)
- {
- aItem = new QTableWidgetItem(myfirstRowValue[j]);
- if(j==0 || j== 1)
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
- myDataTbl->setItem(0, j, aItem);
- aItem = new QTableWidgetItem(myLastRowValue[j]);
- if(j==0 || j== 1)
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
- myDataTbl->setItem(1, j, aItem);
- }
-
- connect(myDataTbl, SIGNAL(cellChanged(int, int)), SLOT(onTableEdited(int, int)));
-
- myDataTbl->horizontalHeader()->viewport()->installEventFilter(this);
-
- aRadiusesLayout->addWidget(myDataTbl);
- ///========================
-
- // Buttons below
- QWidget* aBtnWgt = new QWidget(this);
- aRadiusesLayout->addWidget(aBtnWgt);
- QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnWgt);
- aBtnLayout->setAlignment(Qt::AlignLeft);
- aBtnLayout->setContentsMargins(0, 0, 0, 0);
-
- QPushButton* aAddBtn = new QPushButton(tr("+"), aBtnWgt);
- QFont font = aAddBtn->font();
- font.setPointSize(12);
- aAddBtn->setFont(font);
- aBtnLayout->addWidget(aAddBtn);
- aBtnLayout->addStretch(1);
-
- myRemoveBtn = new QPushButton(tr("-"), aBtnWgt);
- font = myRemoveBtn->font();
- font.setPointSize(12);
- myRemoveBtn->setFont(font);
- aBtnLayout->addWidget(myRemoveBtn);
-
- aRadiusesFrame->setLayout(aRadiusesLayout ) ;
- aMainLayout->addWidget(aRadiusesFrame);
-
- connect(aAddBtn, SIGNAL(clicked(bool)), SLOT(onAdd()));
- connect(myRemoveBtn, SIGNAL(clicked(bool)), SLOT(onRemove()));
- connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(onFocusChanged(QWidget*, QWidget*)));
-}
-
-QList<QWidget*> FeaturesPlugin_WidgetFilletMultiRadiuses::getControls() const
-{
- QList<QWidget*> aControls;
- // this control will accept focus and will be highlighted in the Property Panel
- aControls.append(myDataTbl);
- return aControls;
-}
-
-//**********************************************************************************
-QIntList FeaturesPlugin_WidgetFilletMultiRadiuses::shapeTypes() const
-{
- QIntList aRes;
-
- aRes.append(ModuleBase_Tools::shapeType("vertex"));
- return aRes;
-}
-
-//**********************************************************************************
-void FeaturesPlugin_WidgetFilletMultiRadiuses::deactivate()
-{
-
- ModuleBase_WidgetSelector::deactivate();
- storeValueCustom();
-}
-
-//**********************************************************************************
-bool FeaturesPlugin_WidgetFilletMultiRadiuses::eventFilter(QObject* theObject, QEvent* theEvent)
-{
- QObject* aObject = 0;
-
- if (myDataTbl->horizontalHeader()->viewport() == theObject) {
- aObject = theObject;
- }
- if (aObject) {
- if (theEvent->type() == QEvent::MouseButtonDblClick) {
- if (myHeaderEditor) { //delete previous editor
- myHeaderEditor->deleteLater();
- myHeaderEditor = 0;
- }
- QMouseEvent* aMouseEvent = static_cast<QMouseEvent*>(theEvent);
- QHeaderView* aHeader = static_cast<QHeaderView*>(aObject->parent());
- QTableWidget* aTable = static_cast<QTableWidget*>(aHeader->parentWidget());
-
- int aShift = aTable->horizontalScrollBar()->value();
- int aPos = aMouseEvent->x();
- int aIndex = aHeader->logicalIndex(aHeader->visualIndexAt(aPos));
- if (aIndex > 0) {
- QRect aRect;
- aRect.setLeft(aHeader->sectionPosition(aIndex));
- aRect.setWidth(aHeader->sectionSize(aIndex));
- aRect.setTop(0);
- aRect.setHeight(aHeader->height());
- aRect.adjust(1, 1, -1, -1);
- aRect.translate(-aShift, 0);
-
- myHeaderEditor = new QLineEdit(aHeader->viewport());
- myHeaderEditor->move(aRect.topLeft());
- myHeaderEditor->resize(aRect.size());
- myHeaderEditor->setFrame(false);
- QString aText = aHeader->model()->
- headerData(aIndex, aHeader->orientation()).toString();
- myHeaderEditor->setText(aText);
- myHeaderEditor->setFocus();
- //myEditIndex = aIndex; //save for future use
- myHeaderEditor->installEventFilter(this); //catch focus out event
- //if user presses Enter it should close editor
- connect(myHeaderEditor, SIGNAL(returnPressed()), aTable, SLOT(setFocus()));
- myHeaderEditor->show();
- return true;
- }
- }
- } else if (theEvent->type() == QEvent::FocusIn) {
-
- QTableWidget* aTable = dynamic_cast<QTableWidget*>(theObject);
- if (aTable) {
- ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel();
- if (aPanel->activeWidget() != this) {
- aPanel->activateWidget(this, false);
- }
- }
- }
- else if (theEvent->type() == QEvent::Show ) {
-
- /* ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel();
- if (aPanel->activeWidget() != this) {
- aPanel->activateWidget(this, false);
- }*/
- DataPtr aData = myFeature->data();
- if( myTypeMethodeBypoint )
- aData->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())
- ->setValue(FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() );
- else
- aData->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())
- ->setValue(FeaturesPlugin_Fillet::CREATION_METHOD_BY_CURVILEAR_ABSCISSA() );
- }
- return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent);
-}
-
-
-
-//**********************************************************************************
-bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom()
-{
- DataPtr aData = myFeature->data();
-
- AttributeTablesPtr aTablesAttr;
-
- if(myTypeMethodeBypoint)
- aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_ID());
- else
- aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
-
- // Store data-
- int aRows = myDataTbl->rowCount();
-
- aTablesAttr->setSize(aRows, 2);
- aTablesAttr->setType(ModelAPI_AttributeTables::ValueType::DOUBLE);
-
- for (int i = 0; i < aRows; i++) {
- for (int j = 0; j < 2; j++) {
- QString aTblVal = myDataTbl->item(i, j+1)->text();
- aTablesAttr->setValue( getValue( aTblVal ), i, j);
- }
- }
-
- return true;
-}
-
-//**********************************************************************************
-bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom()
-{
-
- if ( !mySetSelection) {
- mySetSelection = true;
- return false;
- }
- DataPtr aData = myFeature->data();
-
- AttributeTablesPtr aTablesAttr;
-
- if(myTypeMethodeBypoint)
- aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_ID());
- else
- aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
-
- AttributeSelectionPtr anEdges =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aData->attribute(FeaturesPlugin_Fillet::EDGE_SELECTED_ID()));
-
-
-
- std::map<double,std::pair<QString,QString>> aValuesSort;
-
- double res;
- int aRows = 0;
- std::map<double,std::pair<QString,QString>>::iterator itValuesSort;
- if(myTypeMethodeBypoint)
- {
- if( !anEdges->isInitialized() )
- return;
-
- GeomEdgePtr anEdge = GeomEdgePtr(new GeomAPI_Edge( anEdges->value()));
- GeomPointPtr first = anEdge->firstPoint();
- GeomPointPtr last = anEdge->lastPoint();
- double taille = first->distance(last);
-
- std::shared_ptr<GeomAPI_Curve> aCurve(new GeomAPI_Curve(anEdges->value()));
-
- // Load points
- AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
- AttributeDoubleArrayPtr aArrayAttr;
- ListOfShape aPoints;
-
- std::set<GeomShapePtr> aContexts;
- for (int anIndex = 0; anIndex < aSelectionListAttr->size(); ++anIndex) {
- AttributeSelectionPtr aSelection = aSelectionListAttr->value(anIndex);
- GeomShapePtr aShape = aSelection->value();
-
- ResultPtr aContext = aSelection->context();
- aContexts.insert(aContext->shape());
-
- if (!aShape.get()) {
- aShape = aContext->shape();
- }
-
- aPoints.push_back(aShape);
- }
- int i =0;
-
- ListOfShape::const_iterator aPointsIt = aPoints.begin();
- for (; aPointsIt != aPoints.end(); ++aPointsIt) {
- AttributeSelectionPtr attsel = aSelectionListAttr->value(i);
- std::shared_ptr<GeomAPI_Pnt> aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt);
- std::shared_ptr<GeomAPI_Pnt> aPntCurv = aCurve->project(aPnt);
- res = (aPntCurv->distance(first) / taille);
- QString aName = QString::fromStdWString(attsel->namingName());
- QString aRad = findRadius( QString::number(res) );
- if ( aValuesSort.find( res ) == aValuesSort.end() )
- aValuesSort[ res ] = std::make_pair(aName, aRad );
- i++;
- }
-
- res = 0.0;
- aValuesSort[ res ] = std::make_pair (myfirstRowValue[0], findRadius( QString::number(res) )) ;
- res = 1.0;
- aValuesSort[ res ] = std::make_pair (myLastRowValue[0], findRadius( QString::number(res) )) ;
- aRows = aValuesSort.size();
- }else{
-
- ModelAPI_AttributeTables::Value aVal;
- if (aTablesAttr->isInitialized()){
-
- for (int anIndex = 0; anIndex < aTablesAttr->rows(); ++anIndex) {
- aVal = aTablesAttr->value(anIndex,0);
- double curv = getValueText(aVal).toDouble();
- if ( aValuesSort.find( curv ) == aValuesSort.end() )
- aValuesSort[ curv ] = std::make_pair(getValueText(aVal), findRadius(getValueText(aVal)));
- }
- aRows = aTablesAttr->rows();
- }else{
- res = 0.0;
- aValuesSort[ res ] = std::make_pair (myfirstRowValue[0], myfirstRowValue[2]) ;
- res = 1.0;
- aValuesSort[ res ] = std::make_pair (myLastRowValue[0], myLastRowValue[2]) ;
- aRows = 2;
- }
-
- }
-
- QTableWidgetItem* aItem = 0;
- myDataTbl->blockSignals(true);
- aItem = myDataTbl->item( myDataTbl->rowCount() -1, 0 );
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
- aItem = myDataTbl->item( myDataTbl->rowCount() -1, 1 );
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
-
-
- myDataTbl->setRowCount(aRows);
-
- itValuesSort = aValuesSort.begin();
-
- for (int k = 0; k < aRows; k++, ++itValuesSort ) {
-
- std::pair<QString,QString> elem = itValuesSort->second;
- QString aCurv = QString::number(itValuesSort->first);
-
- aItem = myDataTbl->item(k, 0);
- if (aItem) {
- aItem->setText( elem.first);
- } else {
- aItem = new QTableWidgetItem(elem.first);
- myDataTbl->setItem(k, 0, aItem);
- }
- aItem = myDataTbl->item(k, 1);
- if (aItem) {
- aItem->setText( aCurv);
- } else {
- aItem = new QTableWidgetItem(aCurv);
- myDataTbl->setItem(k, 1, aItem);
- }
- aItem = myDataTbl->item(k, 2);
- if (aItem) {
- aItem->setText( elem.second);
- } else {
- aItem = new QTableWidgetItem(elem.second);
- myDataTbl->setItem(k, 2, aItem);
- }
- }
- aItem = myDataTbl->item(myDataTbl->rowCount()-1, 0 );
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled );
- aItem = myDataTbl->item(myDataTbl->rowCount()-1, 1 );
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled );
- myDataTbl->blockSignals(false);
-
- return true;
-}
-
-
-//**********************************************************************************
-void FeaturesPlugin_WidgetFilletMultiRadiuses::onAdd()
-{
-
- QModelIndex index = myDataTbl->currentIndex();
- int i = index.row();
- if( i == -1 )
- return false;
-
- if( !myDataTbl->currentItem()->isSelected() && myDataTbl->rowCount() >2 )
- return false;
-
- myDataTbl->blockSignals(true);
-
- if ( i == myDataTbl->rowCount() -1)
- i = myDataTbl->rowCount() - 2;
-
- if ( i == 0)
- i = 1;
- else
- i= i+1;
-
-
- myDataTbl->model()->insertRow(i);
- QTableWidgetItem* aItem =0;
-
- aItem = myDataTbl->item( i, 0 );
- aItem = new QTableWidgetItem( "New" );
- myDataTbl->setItem(i, 0, aItem);
- aItem = new QTableWidgetItem(myfirstRowValue[1]);
- myDataTbl->setItem(i, 1, aItem);
- aItem = new QTableWidgetItem("-1");
- myDataTbl->setItem(i, 1, aItem);
- aItem = new QTableWidgetItem(myfirstRowValue[2]);
- myDataTbl->setItem(i, 2, aItem);
- aItem = new QTableWidgetItem(myLastRowValue[2]);
- myDataTbl->setItem(i, 2, aItem);
- myDataTbl->blockSignals(false);
-
- emit valuesChanged();
- myDataTbl->setCurrentCell( i, 0);
-}
-
-//**********************************************************************************
-void FeaturesPlugin_WidgetFilletMultiRadiuses::onRemove()
-{
- QModelIndex index = myDataTbl->currentIndex();
-
- if( !myDataTbl->currentItem()->isSelected() && myDataTbl->rowCount() >2 )
- return false;
-
- myDataTbl->blockSignals(true);
- if (index.row() == -1
- || index.row() == 0
- || index.row() == myDataTbl->rowCount() -1)
- return;
-
- if (myTypeMethodeBypoint)
- {
- QTableWidgetItem* aItem = 0;
-
- QString aName = myDataTbl->item( index.row() , 0 )->text();
- AttributeSelectionListPtr aSelList =
- myFeature->data()->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
-
- AttributeSelectionPtr aAttr;
- for (int i = 0; i < aSelList->size(); i++) {
- aAttr = aSelList->value(i);
- if( aName == QString::fromStdWString( aAttr->namingName()) )
- {
- aSelList->remove({i});
- }
- }
- }
- myDataTbl->model()->removeRow(index.row());
- myDataTbl->blockSignals(false);
-
- emit valuesChanged();
-}
-
-//**********************************************************************************
-void FeaturesPlugin_WidgetFilletMultiRadiuses::onTableEdited(int theRow, int theCol)
-{
- // Do not store here column of names
- if (theCol == 0)
- return;
-
- if (!myFeature.get())
- return;
-
- ModelAPI_AttributeTables::Value aVal = getValue(myDataTbl->item(theRow, theCol)->text());
-
- AttributeTablesPtr aTablesAttr;
-
- if(myTypeMethodeBypoint)
- aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_ID());
- else
- aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
-
- if (aTablesAttr->isInitialized())
- {
- aTablesAttr->setValue(aVal,theRow, theCol - 1);
- emit valuesChanged();
- }
-}
-
-//**********************************************************************************
-bool FeaturesPlugin_WidgetFilletMultiRadiuses::
- isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
-{
- return true;
-}
-
-//**********************************************************************************
-bool FeaturesPlugin_WidgetFilletMultiRadiuses::processEnter()
-{
-
- return true;
-}
-
-//**********************************************************************************
-bool FeaturesPlugin_WidgetFilletMultiRadiuses::
- setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues, const bool theToValidate)
-{
-
- if ( theValues.size() > 1 || !myTypeMethodeBypoint || theValues.size() == 0 )
- {
- mySetSelection = false;
- return false;
- }
- QModelIndex index = myDataTbl->currentIndex();
- if( index.row() == -1 )
- {
- mySetSelection = false;
- return false;
- }
-
- if( !myDataTbl->currentItem()->isSelected()){
- mySetSelection = false;
- return false;
- }
-
-
- AttributeSelectionListPtr aSelList =
- myFeature->data()->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
-
- ResultPtr aResult;
- GeomShapePtr aShape;
- int aNbData = 0;
- ModuleBase_ViewerPrsPtr aValue = theValues.first();
- aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
- aShape = aValue->shape();
- if ( (aResult.get() || aShape.get() ) && !aSelList->isInList(aResult, aShape)) {
- aSelList->append(aResult, aShape);
- onRemove();
- }else{
- mySetSelection = false;
- return false;
- }
-
- return true;
-}
-
-//**********************************************************************************
-QList<std::shared_ptr<ModuleBase_ViewerPrs>>
- FeaturesPlugin_WidgetFilletMultiRadiuses::getAttributeSelection() const
-{
- QList<std::shared_ptr<ModuleBase_ViewerPrs>> aList;
- if(myFeature) {
- DataPtr aData = myFeature->data();
- AttributeSelectionListPtr aSelList =
- aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
- AttributeSelectionPtr aAttr;
- ObjectPtr anObject;
- for (int i = 0; i < aSelList->size(); i++) {
- aAttr = aSelList->value(i);
- ModuleBase_ViewerPrsPtr
- aPrs(new ModuleBase_ViewerPrs(aAttr->context(), aAttr->value(), NULL));
- aList.append(aPrs);
- }
- }
- return aList;
-}
-
-//**********************************************************************************
-ModelAPI_AttributeTables::Value FeaturesPlugin_WidgetFilletMultiRadiuses::getValue(QString theStrVal) const
-{
- ModelAPI_AttributeTables::Value aVal;
- aVal.myDouble = theStrVal.toDouble();
- return aVal;
-}
-
-//**********************************************************************************
-QString FeaturesPlugin_WidgetFilletMultiRadiuses::findRadius(QString thename) const
-{
- AttributeTablesPtr aTablesAttr;
-
- if(myTypeMethodeBypoint)
- aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_ID());
- else
- aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
-
- for(int i = 0; i < aTablesAttr->rows(); ++i)
- {
- ModelAPI_AttributeTables::Value aVal = aTablesAttr->value( i, 0) ;
- if( getValueText(aVal) == thename )
- {
- aVal = aTablesAttr->value( i, 1);
- return getValueText(aVal);
- }
- }
- return "0.5";
-}
-
-//**********************************************************************************
-QString FeaturesPlugin_WidgetFilletMultiRadiuses::getValueText(ModelAPI_AttributeTables::Value& theVal) const
-{
-
- return QString::number(theVal.myDouble);
-}
+++ /dev/null
-// Copyright (C) 2014-2020 CEA/DEN, 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 FeaturesPlugin_WidgetFilletMultiRadiuses_H
-#define FeaturesPlugin_WidgetFilletMultiRadiuses_H
-
-#include "FeaturesPlugin.h"
-
-#include <ModuleBase_WidgetSelector.h>
-#include <ModuleBase_ViewerPrs.h>
-#include <ModelAPI_AttributeTables.h>
-
-#include <QList>
-#include <QStringList>
-#include <QStyledItemDelegate>
-
-class QWidget;
-class QLabel;
-class QTableWidget;
-class QPushButton;
-class QTableWidgetItem;
-class QLineEdit;
-
-class DataArrayItemDelegate : public QStyledItemDelegate
-{
- Q_OBJECT
-public:
- DataArrayItemDelegate(bool theTypeMethode);
-
- virtual QWidget* createEditor(QWidget* theParent,
- const QStyleOptionViewItem & theOption,
- const QModelIndex& theIndex) const;
-
-private slots:
- void onEditItem(const QString& theText);
-
-private:
- bool myTypeMethodePoint;
-};
-
-
-/*!
- * \ingroup GUI
- * Represent a content of the property panel to show/modify parameters of a Field feature.
- */
-class FeaturesPlugin_WidgetFilletMultiRadiuses : public ModuleBase_WidgetSelector
-{
- Q_OBJECT
-public:
- FeaturesPlugin_WidgetFilletMultiRadiuses(QWidget* theParent,
- ModuleBase_IWorkshop* theWorkshop,
- const Config_WidgetAPI* theData,
- bool TypeMethodeBypoint);
-
- virtual ~FeaturesPlugin_WidgetFilletMultiRadiuses() {}
-
- /// Returns true if the event is processed.
- virtual bool processEnter();
-
- /// The methiod called when widget is deactivated
- virtual void deactivate();
-
- /// Checks the widget validity. By default, it returns true.
- /// \param thePrs a selected presentation in the view
- /// \return a boolean value
- virtual bool isValidSelectionCustom(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
-
-protected:
- /// Saves the internal parameters to the given feature
- /// \return True in success
- virtual bool storeValueCustom();
-
- /// Restore value from attribute data to the widget's control
- virtual bool restoreValueCustom();
-
- /// Redefinition of virtual function
- /// \param theObject an object for the event
- /// \param theEvent an event
- virtual bool eventFilter(QObject* theObject, QEvent* theEvent);
-
- //virtual void showEvent(QShowEvent* theEvent);
-
- /// Returns list of widget controls
- /// \return a control list
- virtual QList<QWidget*> getControls() const;
-
- /// Set the given wrapped value to the current widget
- /// This value should be processed in the widget according to the needs
- /// \param theValues the wrapped selection values
- /// \param theToValidate a validation of the values flag
- virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
- const bool theToValidate);
-
- /// Return the attribute values wrapped in a list of viewer presentations
- /// \return a list of viewer presentations, which contains an attribute result and
- /// a shape. If the attribute do not uses the shape, it is empty
- virtual QList<std::shared_ptr<ModuleBase_ViewerPrs>> getAttributeSelection() const;
-
-private slots:
-
- /// Slot called on add a row
- void onAdd();
-
- /// Slot called on remove a row
- void onRemove();
-
- /// Retunrs a list of possible shape types
- /// \return a list of shapes
- virtual QIntList shapeTypes() const;
-
- /// Slot called on editing of a table cell
- /// \param theRow a row of the cell
- /// \param theCol a column of the cell
- void onTableEdited(int theRow, int theCol);
-
-
-private:
-
- /// Return a value from the string
- /// \param theStrVal a string
- ModelAPI_AttributeTables::Value getValue(QString theStrVal) const;
-
- /// Return a QString from the ModelAPI_AttributeTables
- /// \param theStrVal a string
- QString getValueText(ModelAPI_AttributeTables::Value& theVal) const;
-
- /// Return a radii value from the name
- /// \param theStrVal a string
- QString findRadius(QString thename) const;
-
- /// tables
- QTableWidget* myDataTbl;
-
- /// Remove button
- QPushButton* myRemoveBtn;
-
- /// Editor for table header
- QLineEdit* myHeaderEditor;
-
- bool myTypeMethodeBypoint;
-
- bool mySetSelection;
-
- DataArrayItemDelegate* myDelegate;
-
- std::vector<QString> myfirstRowValue;
- std::vector<QString> myLastRowValue;
-
-};
-
-#endif
\ No newline at end of file
+++ /dev/null
-// Copyright (C) 2014-2020 CEA/DEN, 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 <GeomAlgoAPI_STEPImportXCAF.h>
-
-#include <TDF_ChildIDIterator.hxx>
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TNaming_Builder.hxx>
-#include <TNaming_NamedShape.hxx>
-
-#include <IFSelect_ReturnStatus.hxx>
-#include <Interface_EntityIterator.hxx>
-#include <Interface_Graph.hxx>
-#include <Interface_InterfaceModel.hxx>
-#include <Interface_Static.hxx>
-#include <STEPControl_Reader.hxx>
-#include <StepBasic_Product.hxx>
-#include <StepBasic_ProductDefinition.hxx>
-#include <StepBasic_ProductDefinitionFormation.hxx>
-#include <StepGeom_GeometricRepresentationItem.hxx>
-#include <StepShape_TopologicalRepresentationItem.hxx>
-#include <StepRepr_DescriptiveRepresentationItem.hxx>
-#include <StepRepr_ProductDefinitionShape.hxx>
-#include <StepRepr_PropertyDefinitionRepresentation.hxx>
-#include <StepRepr_Representation.hxx>
-#include <TransferBRep.hxx>
-#include <Transfer_Binder.hxx>
-#include <Transfer_TransientProcess.hxx>
-#include <XSControl_TransferReader.hxx>
-#include <XSControl_WorkSession.hxx>
-
-#include <BRep_Builder.hxx>
-
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopTools_IndexedMapOfShape.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopoDS_Iterator.hxx>
-
-#include <XCAFApp_Application.hxx>
-#include <XCAFDoc_DocumentTool.hxx>
-#include <OSD_Exception.hxx>
-#include <Locale_Convert.h>
-
-#include <TDocStd_Document.hxx>
-#include <XCAFDoc_ColorTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_MaterialTool.hxx>
-#include <Quantity_Color.hxx>
-#include <TopoDS.hxx>
-#include <STEPConstruct.hxx>
-#include <STEPConstruct_Tool.hxx>
-#include <StepBasic_ProductDefinitionRelationship.hxx>
-#include <StepRepr_NextAssemblyUsageOccurrence.hxx>
-#include <XCAFDoc_Location.hxx>
-
-#include <TColStd_SequenceOfAsciiString.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
-
-
-//=============================================================================
-/*!
- * GetShape()
- */
-//=============================================================================
-
-TopoDS_Shape GetShape(const Handle(Standard_Transient) &theEnti,
- const Handle(Transfer_TransientProcess) &theTP)
-{
- TopoDS_Shape aResult;
- Handle(Transfer_Binder) aBinder = theTP->Find(theEnti);
-
- if (aBinder.IsNull()) {
- return aResult;
- }
-
- aResult = TransferBRep::ShapeResult(aBinder);
-
- return aResult;
-}
-
-// ----------------------------------------------------------------------------
-
-std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const bool anMaterials,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- const std::string &format)
-{
- // dummy XCAF Application to handle the STEP XCAF Document
- Handle(XCAFApp_Application) dummy_app = XCAFApp_Application::GetApplication();
- // XCAF Document to contain the STEP/IGES file itself
- Handle(TDocStd_Document) doc;
- // check if a file is already open under this handle, if so, close it to
- // prevent segfaults when trying to create a new document
- if(dummy_app->NbDocuments() > 0) {
- dummy_app->GetDocument(1, doc);
- dummy_app->Close(doc);
- }
-
- dummy_app->NewDocument( TCollection_ExtendedString("MDTV-CAF"), doc);
- // transfer STEP/IGES into the document, and get the main label
- reader.Transfer(doc);
- TDF_Label mainLabel = doc->Main();
- Handle_XCAFDoc_ShapeTool shapeTool = XCAFDoc_DocumentTool::ShapeTool(mainLabel);
- Handle_XCAFDoc_ColorTool colorTool = XCAFDoc_DocumentTool::ColorTool(mainLabel);
- Handle(XCAFDoc_MaterialTool) materialTool = XCAFDoc_DocumentTool::MaterialTool(mainLabel);
- // traverse the labels recursively to set attributes on shapes
- setShapeAttributes(shapeTool, colorTool, materialTool, mainLabel,
- TopLoc_Location(),theResultBody,theMaterialShape,false);
-
-
- std::shared_ptr<GeomAPI_Shape> ageom = setgeom(shapeTool,mainLabel);
-
- STEPControl_Reader aReader = reader.ChangeReader();
-
- // BEGIN: reading materials of sub-shapes from file
- if ( anMaterials )
- {
- TopTools_IndexedMapOfShape anIndices;
- TopExp::MapShapes(ageom->impl<TopoDS_Shape>(), anIndices);
-
- Handle(Interface_InterfaceModel) Model = aReader.WS()->Model();
- Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader();
- if (!TR.IsNull()) {
- Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
-
- Standard_Integer nb = Model->NbEntities();
-
- for (Standard_Integer ie = 1; ie <= nb; ie++) {
- Handle(Standard_Transient) enti = Model->Value(ie);
-
- // Store materials.
- StoreMaterial(theResultBody,enti, anIndices, TP, mainLabel,theMaterialShape);
- }
- }
- }
-
- return ageom;
-}
-
-std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
- const TDF_Label &label)
-{
- BRep_Builder B;
- TopoDS_Compound compound;
- B.MakeCompound(compound);
-
- TDF_LabelSequence frshapes;
- shapeTool->GetShapes(frshapes);
-
- std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape);
-
- if (frshapes.Length() == 0) {
- aGeomShape->setImpl(new TopoDS_Shape());
- return aGeomShape;
- } else if (frshapes.Length() == 1) {
- TopoDS_Shape shape = shapeTool->GetShape(frshapes.Value(1));
- aGeomShape->setImpl(new TopoDS_Shape(shape));
- return aGeomShape;
- } else {
- for (Standard_Integer i=1; i<frshapes.Length(); i++) {
- TopoDS_Shape S = shapeTool->GetShape(frshapes.Value(i));
-
- TDF_Label aLabel = shapeTool->FindShape(S, Standard_False);
- if ( (!aLabel.IsNull()) && (shapeTool->IsShape(aLabel)) ) {
- if (shapeTool->IsFree(aLabel) ) {
- if (S.IsNull()) {
- continue;
- }
- else {
- B.Add(compound, S);
- }
- }
- }
- }
- TopoDS_Shape shape = compound;
- aGeomShape->setImpl(new TopoDS_Shape(shape));
- return aGeomShape;
- }
-}
-
-void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
- const Handle(XCAFDoc_ColorTool) &colorTool,
- const Handle(XCAFDoc_MaterialTool) &materialTool,
- const TDF_Label &label,
- const TopLoc_Location &loc,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- bool isRef)
-{
- std::wstring shapeName;
- Handle(TDataStd_Name) n;
-
- if(label.FindAttribute(TDataStd_Name::GetID(), n)) {
- TCollection_ExtendedString name = n->Get();
-
- shapeName = Locale::Convert::toWString(TCollection_AsciiString(name).ToCString()) ;
- }
-
- TopLoc_Location partLoc = loc;
- Handle(XCAFDoc_Location) l;
- if(label.FindAttribute(XCAFDoc_Location::GetID(), l)) {
- if(isRef)
- partLoc = partLoc * l->Get();
- else
- partLoc = l->Get();
- }
-
- TDF_Label ref;
- if(shapeTool->IsReference(label) && shapeTool->GetReferredShape(label, ref)) {
-
- setShapeAttributes( shapeTool, colorTool, materialTool, ref,
- partLoc,theResultBody,theMaterialShape,true);
- }
-
- if( shapeTool->IsSimpleShape(label) && (isRef || shapeTool->IsFree(label))) {
-
- TopoDS_Shape shape = shapeTool->GetShape(label);
-
- std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
- if (!loc.IsIdentity()){
- shape.Move(loc);
- }
- aShapeGeom->setImpl(new TopoDS_Shape(shape));
- shapeName = theResultBody->addShapeName(aShapeGeom, shapeName);
-
-
- shape.Location(isRef ? loc : partLoc);
- int dim =
- (shape.ShapeType() == TopAbs_VERTEX) ?
- 0 :
- (shape.ShapeType() == TopAbs_EDGE || shape.ShapeType() == TopAbs_WIRE) ?
- 1 :
- (shape.ShapeType() == TopAbs_FACE ||
- shape.ShapeType() == TopAbs_SHELL) ? 2 :3;
-
- Handle(TCollection_HAsciiString) matName;
- Handle(TCollection_HAsciiString) matDescription;
- Standard_Real matDensity;
- Handle(TCollection_HAsciiString) matDensName;
- Handle(TCollection_HAsciiString) matDensValType;
-
- if(materialTool->GetMaterial(label, matName, matDescription, matDensity,
- matDensName, matDensValType)) {
- std::wstring nameMaterial = Locale::Convert::toWString(matName->ToCString());
-
- theMaterialShape[nameMaterial].push_back(shapeName);
- }
-
-
- Quantity_Color col;
- if(colorTool->GetColor(label, XCAFDoc_ColorGen, col)) {
- double r = col.Red(), g = col.Green(), b = col.Blue();
- std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- theResultBody->addShapeColor(shapeName, ColRGB);
- }
- else if(colorTool->GetColor(label, XCAFDoc_ColorSurf, col)) {
- double r = col.Red(), g = col.Green(), b = col.Blue();
- std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- theResultBody->addShapeColor(shapeName, ColRGB);
- }
- else if(colorTool->GetColor(label, XCAFDoc_ColorCurv, col)) {
- double r = col.Red(), g = col.Green(), b = col.Blue();
- std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- theResultBody->addShapeColor(shapeName, ColRGB);
- }
- // check explicit coloring of boundary entities
- if(dim == 3) {
- TopExp_Explorer xp2(shape, TopAbs_FACE);
- while(xp2.More()) {
- if(colorTool->GetColor(xp2.Current(), XCAFDoc_ColorGen, col) ||
- colorTool->GetColor(xp2.Current(), XCAFDoc_ColorSurf, col) ||
- colorTool->GetColor(xp2.Current(), XCAFDoc_ColorCurv, col)) {
- double r = col.Red(), g = col.Green(), b = col.Blue();
- TopoDS_Face face = TopoDS::Face(xp2.Current());
- std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- std::wstringstream aNameFace;
- TopoDS_Shape shapeface = xp2.Current();
- if (!loc.IsIdentity()){
- shapeface.Move(loc);
- }
- aShapeGeom->setImpl(new TopoDS_Shape(shapeface));
- theResultBody->addShapeColor(
- theResultBody->addShapeName(aShapeGeom , aNameFace.str()), ColRGB);
- }
- xp2.Next();
- }
- }
- if(dim == 2) {
- TopExp_Explorer xp1(shape, TopAbs_EDGE);
- while(xp1.More()) {
- if(colorTool->GetColor(xp1.Current(), XCAFDoc_ColorGen, col) ||
- colorTool->GetColor(xp1.Current(), XCAFDoc_ColorSurf, col) ||
- colorTool->GetColor(xp1.Current(), XCAFDoc_ColorCurv, col)) {
- double r = col.Red(), g = col.Green(), b = col.Blue();
- std::vector<int> ColRGB = {int(r*255),int(g*255),int(b*255)};
- std::wstringstream aNameEdge;
- aNameEdge << L"Edge_"<< shapeName;
- aShapeGeom->setImpl(new TopoDS_Shape(xp1.Current() ));
- theResultBody->addShapeColor(
- theResultBody->addShapeName(aShapeGeom , aNameEdge.str()), ColRGB);
- }
- xp1.Next();
- }
- }
- }
- else {
- int indiceChild = 1;
-
- if (!shapeTool->IsReference(label)){
- TopoDS_Shape shape = shapeTool->GetShape(label);
-
- std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
- if (!loc.IsIdentity()){
- shape.Move(loc);
- }
- aShapeGeom->setImpl(new TopoDS_Shape(shape));
- shapeName = theResultBody->addShapeName(aShapeGeom, shapeName);
- }
- for(TDF_ChildIterator it(label); it.More(); it.Next()) {
-
- setShapeAttributes( shapeTool, colorTool, materialTool,
- it.Value(), partLoc,theResultBody,theMaterialShape, isRef);
- indiceChild++;
- }
- }
-}
-
-
-//=============================================================================
- /*!
- * StoreMaterial()
- */
- //=============================================================================
-
- void StoreMaterial( std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const Handle(Standard_Transient) &theEnti,
- const TopTools_IndexedMapOfShape &theIndices,
- const Handle(Transfer_TransientProcess) &theTP,
- const TDF_Label &theShapeLabel,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape )
- {
- // Treat Product Definition Shape only.
- Handle(StepRepr_ProductDefinitionShape) aPDS =
- Handle(StepRepr_ProductDefinitionShape)::DownCast(theEnti);
- Handle(StepBasic_ProductDefinition) aProdDef;
-
- if(aPDS.IsNull() == Standard_False) {
- // Product Definition Shape ==> Product Definition
- aProdDef = aPDS->Definition().ProductDefinition();
- }
-
- if (aProdDef.IsNull() == Standard_False) {
- // Product Definition ==> Property Definition
- const Interface_Graph &aGraph = theTP->Graph();
- Interface_EntityIterator aSubs = aGraph.Sharings(aProdDef);
- TopoDS_Shape aShape;
-
- for(aSubs.Start(); aSubs.More(); aSubs.Next()) {
- Handle(StepRepr_PropertyDefinition) aPropD =
- Handle(StepRepr_PropertyDefinition)::DownCast(aSubs.Value());
-
- if(aPropD.IsNull() == Standard_False) {
- // Property Definition ==> Representation.
- Interface_EntityIterator aSubs1 = aGraph.Sharings(aPropD);
-
- for(aSubs1.Start(); aSubs1.More(); aSubs1.Next()) {
- Handle(StepRepr_PropertyDefinitionRepresentation) aPDR =
- Handle(StepRepr_PropertyDefinitionRepresentation)::
- DownCast(aSubs1.Value());
-
- if(aPDR.IsNull() == Standard_False) {
- // Property Definition ==> Material Name.
- Handle(StepRepr_Representation) aRepr = aPDR->UsedRepresentation();
-
- if(aRepr.IsNull() == Standard_False) {
- Standard_Integer ir;
-
- for(ir = 1; ir <= aRepr->NbItems(); ir++) {
- Handle(StepRepr_RepresentationItem) aRI = aRepr->ItemsValue(ir);
- Handle(StepRepr_DescriptiveRepresentationItem) aDRI =
- Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(aRI);
-
- if(aDRI.IsNull() == Standard_False) {
- // Get shape from Product Definition
- Handle(TCollection_HAsciiString) aMatName = aDRI->Name();
- if(aMatName.IsNull() == Standard_False) {
- TCollection_ExtendedString
- aMatNameExt (aMatName->ToCString());
-
- if (aShape.IsNull()) {
- //Get the shape.
- aShape = GetShape(aProdDef, theTP);
- if (aShape.IsNull()) {
- return;
- }
- }
-
- // as PRODUCT can be included in the main shape
- // several times, we look here for all iclusions.
- Standard_Integer isub, nbSubs = theIndices.Extent();
-
- for (isub = 1; isub <= nbSubs; isub++) {
- TopoDS_Shape aSub = theIndices.FindKey(isub);
-
- if (aSub.IsPartner(aShape)) {
- std::shared_ptr<GeomAPI_Shape> aShapeGeom(new GeomAPI_Shape);
- aShapeGeom->setImpl(new TopoDS_Shape(aSub));
- std::wstring nom = theResultBody->findShapeName(aShapeGeom);
- std::wstring matName= Locale::Convert::toWString(aMatName->ToCString());
- theMaterialShape[matName].push_back(nom);
-
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
+++ /dev/null
-// Copyright (C) 2014-2020 CEA/DEN, 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 GEOMALGOAPI_STEPIMPORTXCAF_H_
-#define GEOMALGOAPI_STEPIMPORTXCAF_H_
-
-#include <GeomAlgoAPI.h>
-#include <TopoDS_Shape.hxx>
-
-#include <string>
-#include <vector>
-#include <map>
-#include <set>
-#include <GeomAPI_Shape.h>
-#include <XCAFDoc_ColorTool.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-#include <XCAFDoc_MaterialTool.hxx>
-#include <TDocStd_Document.hxx>
-#include <XSControl_WorkSession.hxx>
-
-#include <STEPCAFControl_Reader.hxx>
-
-#include <ModelAPI_ResultBody.h>
-#include <TopTools_IndexedMapOfShape.hxx>
-
- // read Attributs of step file
- GEOMALGOAPI_EXPORT
- std::shared_ptr<GeomAPI_Shape> readAttributes( STEPCAFControl_Reader &reader,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const bool anMaterials,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- const std::string &format);
- // read attributs for label
- GEOMALGOAPI_EXPORT
- void setShapeAttributes(const Handle(XCAFDoc_ShapeTool) &shapeTool,
- const Handle(XCAFDoc_ColorTool) &colorTool,
- const Handle(XCAFDoc_MaterialTool) &materialTool,
- const TDF_Label &label,
- const TopLoc_Location &loc,
- std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape,
- bool isRef);
-
-// read geometry
-GEOMALGOAPI_EXPORT
-std::shared_ptr<GeomAPI_Shape> setgeom(const Handle(XCAFDoc_ShapeTool) &shapeTool,
- const TDF_Label &label);
-
-// store Materiel for theShapeLabel in the map theMaterialShape
-GEOMALGOAPI_EXPORT
-void StoreMaterial( std::shared_ptr<ModelAPI_ResultBody> theResultBody,
- const Handle(Standard_Transient) &theEnti,
- const TopTools_IndexedMapOfShape &theIndices,
- const Handle(Transfer_TransientProcess) &theTP,
- const TDF_Label &theShapeLabel,
- std::map< std::wstring, std::list<std::wstring>> &theMaterialShape );
-
-#endif /* GEOMALGOAPI_STEPIMPORTXCAF_H_ */
#include <iostream>
#include <algorithm>
-//------------------------------------------------------------------------------
+//=================================================================================================
// Tools
std::wstring toString(double theValue)
return std::set<std::wstring>(theContainer.begin(), theContainer.end());
}
-//------------------------------------------------------------------------------
+//=================================================================================================
InitializationPlugin_EvalListener::InitializationPlugin_EvalListener()
{
myInterp->initialize();
}
+//=================================================================================================
InitializationPlugin_EvalListener::~InitializationPlugin_EvalListener()
{
}
+//=================================================================================================
void InitializationPlugin_EvalListener::processEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
Locale::Convert::toWString(anExprAttr->value());
anExpZ.erase(std::remove(anExpZ.begin(),anExpZ.end(), ' '), anExpZ.end());
- for(int step =0; step < anValueAttr->rows(); step++ ){
+ for (int step =0; step < anValueAttr->rows(); step++){
aVal.myDouble = evaluate(anVar,
anValueAttr->value(step,0).myDouble,
aParam,
anError,
aParamsList,
anIsFirstTime);
- if(!anError.empty()) break;
+ if (!anError.empty()) break;
anValueAttr->setValue(aVal,step,1);
-
aVal.myDouble = evaluate(anVar,
anValueAttr->value(step,0).myDouble,
aParam,
anError,
aParamsList,
anIsFirstTime);
- if(!anError.empty()) break;
+ if (!anError.empty()) break;
anValueAttr->setValue(aVal,step,2);
-
aVal.myDouble = evaluate(anVar,
anValueAttr->value(step,0).myDouble,
aParam,
anError,
aParamsList,
anIsFirstTime);
- if(!anError.empty()) break;
+ if (!anError.empty()) break;
anValueAttr->setValue(aVal,step,3);
- if ( anIsFirstTime )
+ if (anIsFirstTime)
anIsFirstTime = false;
}
-
aMsg->setResults(aParamsList, anError);
}
}
+//=================================================================================================
double InitializationPlugin_EvalListener::evaluate(
std::wstring& theVariable,
double theValueVariable,
std::list<std::wstring> anExprParams = myInterp->compile(theExpression);
// find expression's params in the model
-
std::list<std::wstring>::iterator it = anExprParams.begin();
- for ( ; it != anExprParams.end(); it++) {
+ for (; it != anExprParams.end(); it++) {
double aValue;
ResultParameterPtr aParamRes;
// If variable does not exist python interpreter will generate an error.
*it, aValue, aParamRes, theParameter->document()))
continue;
- if( theIsFirstTime )
+ if (theIsFirstTime)
{
std::list<ResultParameterPtr>::iterator anIter =
std::find(theParamsList.begin(),theParamsList.end(), aParamRes );
- if(anIter == theParamsList.end())
+ if (anIter == theParamsList.end())
theParamsList.push_back(aParamRes);
}
return result;
}
-
+//=================================================================================================
double InitializationPlugin_EvalListener::evaluate(FeaturePtr theParameter,
const std::wstring& theExpression, std::string& theError,
std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
return result;
}
+//=================================================================================================
void InitializationPlugin_EvalListener::processEvaluationEvent(
const std::shared_ptr<Events_Message>& theMessage)
{
}
}
+//=================================================================================================
void InitializationPlugin_EvalListener::initDataModel()
{
myInterp->runString("import salome_iapp;salome_iapp.register_module_in_study(\"Shaper\")");
FeaturePtr myParam; ///< parameters that should be evaluated
bool myIsProcessed; ///< true if results were set
std::string myError; ///< error of processing, empty if there is no error
- /// result of processing, list of parameters in expression found
+ /// result of processing, list of parameters in expression found
std::list<std::shared_ptr<ModelAPI_ResultParameter> > myParamsList;
public:
send(FeaturePtr theParameter, const void* theSender)
{
std::shared_ptr<ModelAPI_BuildEvalMessage> aMessage =
- std::shared_ptr<ModelAPI_BuildEvalMessage>(
- new ModelAPI_BuildEvalMessage(eventId(), theSender));
+ std::shared_ptr<ModelAPI_BuildEvalMessage>(
+ new ModelAPI_BuildEvalMessage(eventId(), theSender));
aMessage->setParameter(theParameter);
Events_Loop::loop()->send(aMessage);
return aMessage;
MODELAPI_EXPORT void setParameter(FeaturePtr theParam);
/// Sets the results of processing
MODELAPI_EXPORT void setResults(
- const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
- const std::string& theError);
- /// Returns the results of processing: list of parameters found in the expression
+ const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& theParamsList,
+ const std::string& theError);
+ /// Returns the results of processing: list of parameters found in the expression
MODELAPI_EXPORT const std::list<std::shared_ptr<ModelAPI_ResultParameter> >& params() const;
/// Returns true if the expression is processed
MODELAPI_EXPORT bool isProcessed();