GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjectsSelList, isKeepSubShapes, anObjects, aParts))
+ anObjectsSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
// Parameters of rotation.
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Rotated");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjectsSelList, isKeepSubShapes, anObjects, aParts))
+ anObjectsSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
std::shared_ptr<GeomAPI_Dir> aFirstDir, aSecondDir;
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Translated");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
// Getting objects.
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECTS_LIST_ID());
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjectsSelList, isKeepSubShapes, anObjects, aParts))
+ anObjectsSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
// Verify the start shape
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Placed");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
// Getting objects.
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
AttributeSelectionListPtr anObjSelList = selectionList(OBJECTS_LIST_ID());
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjSelList, isKeepSubShapes, anObjects, aParts))
+ anObjSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
std::string anError;
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Rotated");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
// Getting objects.
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
AttributeSelectionListPtr anObjSelList = selectionList(OBJECTS_LIST_ID());
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjSelList, isKeepSubShapes, anObjects, aParts))
+ anObjSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
// Getting the center point
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Scaled");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
// Getting objects.
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
AttributeSelectionListPtr anObjSelList = selectionList(OBJECTS_LIST_ID());
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjSelList, isKeepSubShapes, anObjects, aParts))
+ anObjSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
// Getting the center point
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Scaled");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
void FeaturesPlugin_Symmetry::buildResult(
const std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theAlgo,
const std::list<std::shared_ptr<GeomAPI_Shape> >& theOriginalShapes,
- std::shared_ptr<GeomAPI_Shape> theTargetShape, int& theResultIndex)
+ std::shared_ptr<GeomAPI_Shape> theTargetShape, int& theResultIndex, std::string & theTextureFile)
{
// Store and name the result.
ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, theOriginalShapes, ListOfShape(),
theAlgo, theTargetShape, "Symmetried");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, theResultIndex++);
}
// Getting objects.
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
AttributeSelectionListPtr anObjSelList = selectionList(OBJECTS_LIST_ID());
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjSelList, isKeepSubShapes, anObjects, aParts))
+ anObjSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
std::string anError;
ListOfShape aTopLevel;
anObjects.topLevelObjects(aTopLevel);
for (ListOfShape::iterator anIt = aTopLevel.begin(); anIt != aTopLevel.end(); ++anIt)
- buildResult(aMakeShapeList, anOriginalShapes, *anIt, aResultIndex);
+ buildResult(aMakeShapeList, anOriginalShapes, *anIt, aResultIndex, theTextureFile);
// Remove the rest results if there were produced in the previous pass.
removeResults(aResultIndex);
void buildResult(const std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theAlgo,
const std::list<std::shared_ptr<GeomAPI_Shape> >& theOriginalShapes,
std::shared_ptr<GeomAPI_Shape> theTargetShape,
- int& theResultIndex);
+ int& theResultIndex, std::string &theTextureFile);
/// Create new result for the given part and transformation
void buildResult(std::shared_ptr<ModelAPI_ResultPart> theOriginal,
}
//==================================================================================================
-bool FeaturesPlugin_Tools::shapesFromSelectionList(
- const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
+bool FeaturesPlugin_Tools::shapesFromSelectionList(const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
const bool theStoreFullHierarchy,
GeomAPI_ShapeHierarchy& theHierarchy,
- std::list<ResultPtr>& theParts)
+ std::list<ResultPtr>& theParts, std::string &theTextureFile)
{
int aSize = theSelectionList->size();
+ if(aSize == 1)
+ {
+ auto anObjectAttr = theSelectionList->value(0);
+ if(anObjectAttr.get())
+ {
+ FeaturePtr aFeature = anObjectAttr->contextFeature();
+ if(aFeature.get() && aFeature->results().size() == 1)
+ {
+ theTextureFile = aFeature->firstResult()->getTextureFile();
+ }
+ else
+ {
+ if(!aFeature.get())
+ {
+ auto aResult = anObjectAttr->context();
+ if(aResult.get())
+ {
+ theTextureFile = aResult->getTextureFile();
+ }
+ }
+ }
+ }
+ }
for (int anObjectsIndex = 0; anObjectsIndex < aSize; anObjectsIndex++) {
AttributeSelectionPtr anObjectAttr = theSelectionList->value(anObjectsIndex);
std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
const std::shared_ptr<ModelAPI_AttributeSelectionList> theSelectionList,
const bool theStoreFullHierarchy,
GeomAPI_ShapeHierarchy& theHierarchy,
- std::list<ResultPtr>& theParts);
+ std::list<ResultPtr>& theParts, std::string& theTextureFile);
};
#endif /* FeaturesPlugin_Tools_H_ */
// Getting objects.
GeomAPI_ShapeHierarchy anObjects;
std::list<ResultPtr> aParts;
+ std::string theTextureFile;
AttributeSelectionListPtr anObjectsSelList = selectionList(OBJECTS_LIST_ID());
if (!FeaturesPlugin_Tools::shapesFromSelectionList(
- anObjectsSelList, isKeepSubShapes, anObjects, aParts))
+ anObjectsSelList, isKeepSubShapes, anObjects, aParts, theTextureFile))
return;
std::string anError;
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
FeaturesPlugin_Tools::loadModifiedShapes(aResultBody, anOriginalShapes, ListOfShape(),
aMakeShapeList, *anIt, "Translated");
+ aResultBody->setTextureFile(theTextureFile);
setResult(aResultBody, aResultIndex++);
}
myHistoryCash.Clear();
}
+void Model_ResultBody::setTextureFile(const std::string & theTextureFile)
+{
+ ModelAPI_Result::setTextureFile(theTextureFile);
+ for( auto sub : mySubs){
+ sub->setTextureFile(theTextureFile);
+ }
+ for(auto map : mySubsMap){
+ map.first->setTextureFile(theTextureFile);
+ }
+}
bool Model_ResultBody::isConnectedTopology()
{
/// Cleans cash related to the already stored elements
MODEL_EXPORT virtual void cleanCash() override;
+ /// sets the texture file
+ MODEL_EXPORT virtual void setTextureFile(const std::string & theTextureFile) override;
+
+
protected:
/// Makes a body on the given feature
Model_ResultBody();
return (textureFile != "");
}
- MODELAPI_EXPORT void setTextureFile(const std::string & theTextureFile)
+ MODELAPI_EXPORT virtual void setTextureFile(const std::string & theTextureFile)
{
textureFile = theTextureFile;
}
isModified = true;
}
else {
+ if (myFeature->firstResult().get() && myFeature->firstResult()->hasTextureFile())
+ {
+ PartSet_Module::setTexture( myFeature->firstResult()->getTextureFile(), aPresentation);
+ }
anOperationPrs->Redisplay();
isModified = true;
aRedisplayed = true;
}
+//******************************************************
+void PartSet_Module::setTexture(const std::string & theTextureFile, const AISObjectPtr& thePrs)
+{
+ Handle(AIS_InteractiveObject) anAIS = thePrs->impl<Handle(AIS_InteractiveObject)>();
+ if (!anAIS.IsNull())
+ {
+ /// set color to white and change material aspect,
+ /// in order to keep a natural apect of the image.
+ thePrs->setColor(255, 255, 255);
+ Quantity_Color myShadingColor(NCollection_Vec3<float>(1., 1., 1.));
+ Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
+ if (!anAISShape.IsNull())
+ {
+ auto myDrawer = anAISShape->Attributes();
+
+ myDrawer->ShadingAspect()->SetColor(myShadingColor);
+ myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
+ Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC);
+ aMatAspect.SetTransparency(0.0);
+ myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
+ myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
+
+ Handle(Image_PixMap) aPixmap;
+ QPixmap px(theTextureFile.c_str());
+
+ if (!px.isNull() )
+ aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage());
+
+ anAISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMap
+ (new Graphic3d_Texture2Dmanual(aPixmap));
+ anAISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
+
+ anAISShape->SetDisplayMode(AIS_Shaded);
+ }
+ }
+
+}
+
+
+
//******************************************************
void PartSet_Module::customizePresentation(const ObjectPtr& theObject,
const AISObjectPtr& thePrs) const
/// set texture parameters
if(aResult->hasTextureFile())
{
- Handle(AIS_InteractiveObject) anAIS = thePrs->impl<Handle(AIS_InteractiveObject)>();
- if (!anAIS.IsNull())
- {
- /// set color to white and change material aspect,
- /// in order to keep a natural apect of the image.
- thePrs->setColor(255, 255, 255);
- Quantity_Color myShadingColor(NCollection_Vec3<float>(1., 1., 1.));
- Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(anAIS);
- if (!anAISShape.IsNull())
- {
- auto myDrawer = anAISShape->Attributes();
-
- myDrawer->ShadingAspect()->SetColor(myShadingColor);
- myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
- Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC);
- aMatAspect.SetTransparency(0.0);
- myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
- myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
-
- Handle(Image_PixMap) aPixmap;
- QPixmap px(aResult->getTextureFile().c_str());
-
- if (!px.isNull() )
- aPixmap = OCCViewer_Utilities::imageToPixmap( px.toImage());
-
- anAISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMap
- (new Graphic3d_Texture2Dmanual(aPixmap));
- anAISShape->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
-
- anAISShape->SetDisplayMode(AIS_Shaded);
- }
- }
+ setTexture(aResult->getTextureFile(), thePrs);
}
}
FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
/// Reads description of features from XML file
virtual void createFeatures();
+ /// add texture
+ PARTSET_EXPORT static void setTexture(const std::string &theTextureFile, const AISObjectPtr& thePrs);
+
public slots:
/// Slolt called on object display
/// \param theObject a data object