aResult = IGESExport(theFileName, aFormatName, aShape, anError);
} else if (aFormatName == "STEP")
{
- //aResult = STEPExport(theFileName, aFormatName, aShape, anError);
+ aResult = STEPExport(theFileName, aShapes, aContexts, anError);
} else {
anError = "Unsupported format: " + aFormatName;
}
aCurShape = anAttrSelection->context()->shape();
if (!aCurShape.get())
continue;
- #ifndef HAVE_SALOME
+ //#ifndef HAVE_SALOME
ResultPtr aRes = anAttrSelection->context();
std::vector<int> aColor;
ModelAPI_Tools::getColor(aRes, aColor);
{
aColoredShapes[aCurShape] = aColor;
}
- #endif
+ //#endif
aShapeList.push_back(aCurShape);
}
std::shared_ptr<GeomAPI_Shape> aShape =
#ifndef HAVE_SALOME
bool aRes = true;// STEPExport(theFileName, aShape, aColoredShapes, anError);
#else
- bool aRes = true;// STEPExport(theFileName, "STEP", aShape, anError);
+ bool aRes = STEPExport(theFileName, aShape, aColoredShapes, anError);
#endif
if (!anError.empty() || !aRes)
theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorSurf, aCol) ||
theColorTool->GetColor(aXp2.Current(), XCAFDoc_ColorCurv, aCol)) {
double aR = aCol.Red(), aG = aCol.Green(), aB = aCol.Blue();
+#if 0
TopoDS_Face aFace = TopoDS::Face(aXp2.Current());
std::vector<int> aColRGB = {int(aR*255),int(aG*255),int(aB*255)};
std::wstringstream aNameFace;
aShapeface.Move(theLoc);
}
aShapeGeom->setImpl(new TopoDS_Shape(aShapeface));
- theResultBody->addShapeColor(
- theResultBody->addShapeName(aShapeGeom , aNameFace.str()), aColRGB);
+ theResultBody->addShapeColor(theResultBody->addShapeName(aFaceGeom, aNameFace), aColRGB);
+#else
+ //TopoDS_Face aFace = TopoDS::Face(aXp2.Current());
+ std::vector<int> aColRGB = { int(aR * 255),int(aG * 255),int(aB * 255) };
+ std::wstring aNameFace;
+ TopoDS_Shape aShapeface = aXp2.Current();
+ if (!theLoc.IsIdentity()) {
+ aShapeface.Move(theLoc);
+ }
+ std::shared_ptr<GeomAPI_Shape> aFaceGeom(new GeomAPI_Shape);
+ aFaceGeom->setImpl(new TopoDS_Shape(aShapeface));
+ theResultBody->addShapeColor(theResultBody->addShapeName(aFaceGeom, aNameFace), aColRGB);
+#endif
+ //std::cout << "Subshape " << Locale::Convert::toString(L"XXX") << " " << aColRGB[0] << aColRGB[1] << aColRGB[2] << std::endl;
}
aXp2.Next();
}
int indice = 1;
std::wstringstream aName;
aName << theName;
- while(myNamesShape.find(aName.str()) != myNamesShape.end() ){
+#if 0
+ while (myNamesShape.find(aName.str()) != myNamesShape.end()) {
+#else
+ while (aName.str().empty() || myNamesShape.find(aName.str()) != myNamesShape.end()) {
+#endif
aName.str(L"");
aName << theName << L"__" << indice;
indice++;
aECreator->sendUpdated(data()->owner(), EVENT_DISP);
}
cleanCash();
+ }
+ else if (!aThisShape.IsNull() && (aThisShape.ShapeType() == TopAbs_SOLID ||
+ aThisShape.ShapeType() == TopAbs_SHELL)) {
+ std::cout << ".....subshape is a SOLID or SHELL" << std::endl;
+ // Iterate on all faces
+ //MBS:
+ ResultBodyPtr anOwner = std::dynamic_pointer_cast<ModelAPI_ResultBody>(data()->owner());
+ TopExp_Explorer aExp(aThisShape, TopAbs_FACE);
+ for (; aExp.More(); aExp.Next()) {
+ TopoDS_Shape aFace = aExp.Current();
+ if (!aFace.IsNull()) {
+ GeomShapePtr aGeomFace(new GeomAPI_Shape);
+ aGeomFace->setImpl<TopoDS_Shape>(new TopoDS_Shape(aFace));
+ std::wstring aName = findShapeName(aGeomFace);
+ ///
+ for (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> >::iterator it =
+ myNamesShape.begin();
+ it != myNamesShape.end();
+ ++it)
+ {
+ TopoDS_Shape curSelectedShape = (*it).second->impl<TopoDS_Shape>();
+ if (curSelectedShape.TShape().IsNull())
+ continue;
+ if (aFace.TShape() == curSelectedShape.TShape())
+ {
+ aName = (*it).first; // Find necessary shape,
+ // but it NOT correct because result shape contains anothet location. WHY?
+ break;
+ }
+ }
+ ///
+ if (!aName.empty()) {
+ const std::vector<int> &aColor = findShapeColor(aName);
+ if (!aColor.empty()) {
+ ModelAPI_Tools::setColor(anOwner, aGeomFace, aColor);
+ }
+ }
+ }
+ }
} else if (!mySubs.empty()) { // erase all subs
while(!mySubs.empty()) {
ResultBodyPtr anErased = *(mySubs.rbegin());
#include <QLabel>
#include <QButtonGroup>
+#include <QCheckBox>
#include <QGridLayout>
#include <QRadioButton>
#include <QDialogButtonBox>
};
}
-XGUI_ColorDialog::XGUI_ColorDialog(QWidget* theParent)
+XGUI_ColorDialog::XGUI_ColorDialog(QWidget* theParent, bool theCheckBoxNeed)
: QDialog(theParent, Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint)
{
setWindowTitle(tr("Color"));
myButtonGroup->addButton(aColorChoiceBtn, 0);
myButtonGroup->addButton(aRandomChoiceBtn, 1);
+ if (theCheckBoxNeed)
+ myTargetSetCheck = new QCheckBox(tr("Set on selected face"), this);
+
aLay->addWidget(aColorChoiceBtn, 0, 0);
aLay->addWidget(myColorButton, 0, 1);
aLay->addWidget(aRandomChoiceBtn, 1, 0);
aLay->addWidget(aRandomLabel, 1, 1);
+ aLay->addWidget(myTargetSetCheck, 2, 0, 1, 2);
QDialogButtonBox* aButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this);
connect(aButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(aButtons, SIGNAL(rejected()), this, SLOT(reject()));
- aLay->addWidget(aButtons, 2, 0, 1, 2);
+ aLay->addWidget(aButtons, 3, 0, 1, 2);
}
bool XGUI_ColorDialog::isRandomColor() const
return myButtonGroup->checkedId() == 1;
}
+bool XGUI_ColorDialog::isSetOnSubShape() const
+{
+ return myTargetSetCheck && myTargetSetCheck->isChecked();
+}
+
void XGUI_ColorDialog::setColor(const std::vector<int>& theValue)
{
if (theValue.size() != 3)
#include <QDialog>
class QButtonGroup;
+class QCheckBox;
class QtxColorButton;
/**
public:
/// Constructor
/// \param theParent a parent widget for the dialog
- XGUI_EXPORT XGUI_ColorDialog(QWidget* theParent);
+ XGUI_EXPORT XGUI_ColorDialog(QWidget* theParent, bool theCheckBoxNeed = true);
XGUI_EXPORT virtual ~XGUI_ColorDialog() {};
/// \return a boolean value
bool isRandomColor() const;
+ /// Returns whether the need set color on subshape only
+ /// \return a boolean value
+ bool isSetOnSubShape() const;
+
/// Initializes the dialog with the given value. Set choice on certain value and fill it by.
/// \param theValue an RGB components value
void setColor(const std::vector<int>& theValue);
private:
QButtonGroup* myButtonGroup; /// a group, contained random and certain color radio button choice
QtxColorButton* myColorButton; /// a control to select a color
+ QCheckBox* myTargetSetCheck; /// a target shape for assign
};
#endif
return;
bool isRandomColor = aDlg->isRandomColor();
+ bool isSetToShape = aDlg->isSetOnSubShape();
// 3. abort the previous operation and start a new one
SessionPtr aMgr = ModelAPI_Session::get();
ResultBodyPtr aBodyResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aResult);
foreach(GeomShapePtr aShape, theSelectedObjects[aResult])
{
- if (aResult->shape()->impl<TopoDS_Shape>().IsEqual(aShape->impl<TopoDS_Shape>()) || !isColorOnSubShape)
+ if (aResult->shape()->impl<TopoDS_Shape>().IsEqual(aShape->impl<TopoDS_Shape>()) || !isColorOnSubShape || !isSetToShape)
{
if (aResult.get() != NULL)
{