if (myTrsf.get()) {
return baseRef()->partDoc();
}
- return data()->document("PartDocument")->value();
+ DocumentPtr aRes = data()->document(DOC_REF())->value();
+ if (!aRes.get() && myIsInLoad) { // trying to get this document from the session
+ aRes = document()->subDocument(data()->name());
+ }
+ return aRes;
}
Model_ResultPart::Model_ResultPart()
{
- myIsDisabled = true; // by default it is not initialized and false to be after created
- setIsConcealed(false);
+ myIsInLoad = false;
}
void Model_ResultPart::activate()
std::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->document(DOC_REF());
if (!aDocRef->value().get()) { // create (or open) a document if it is not yet created
+ myIsInLoad = true;
std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
+ myIsInLoad = false;
if (aDoc) {
+ aDoc->synchronizeTransactions();
aDocRef->setValue(aDoc);
}
}
}
}
+std::shared_ptr<ModelAPI_ResultPart> Model_ResultPart::original()
+{
+ if (myTrsf.get()) {
+ return baseRef()->original();
+ }
+ return std::dynamic_pointer_cast<ModelAPI_ResultPart>(data()->owner());
+}
+
bool Model_ResultPart::isActivated()
{
if (myTrsf.get()) {
if (!myTrsf.get()) { // disable of base result part
DocumentPtr aDoc = Model_ResultPart::partDoc();
if (aDoc.get() && aDoc->isOpened()) {
+ std::shared_ptr<Model_Document> anIntDoc = std::dynamic_pointer_cast<Model_Document>(aDoc);
// make the current feature the last in any case: to update shapes defore deactivation too
- FeaturePtr aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aDoc->object(
- ModelAPI_Feature::group(), aDoc->size(ModelAPI_Feature::group()) - 1));
+ FeaturePtr aLastFeature = anIntDoc->lastFeature();
aDoc->setCurrentFeature(aLastFeature, false);
if (theFlag) { // disable, so make all features disabled too
// update the shape just before the deactivation: it will be used outside of part
return false; // something is wrong
}
-std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shapeInPart(const std::string& theName)
+std::shared_ptr<GeomAPI_Shape> Model_ResultPart::shapeInPart(
+ const std::string& theName, const std::string& theType, int& theIndex)
{
- /// TODO: not implemented yet
- return std::shared_ptr<GeomAPI_Shape>();
+ theIndex = 0; // not found yet
+ std::shared_ptr<GeomAPI_Shape> aResult;
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(partDoc());
+ if (!aDoc.get()) // the part document is not presented for the moment
+ return aResult;
+
+ AttributeSelectionListPtr aSelAttr = aDoc->selectionInPartFeature();
+ aSelAttr->append(theName, theType);
+ theIndex = aSelAttr->size();
+ aResult = aSelAttr->value(theIndex - 1)->value();
+ return aResult;
}
+std::shared_ptr<GeomAPI_Shape> Model_ResultPart::selectionValue(const int theIndex)
+{
+ std::shared_ptr<GeomAPI_Shape> aResult;
+ std::shared_ptr<Model_Document> aDoc = std::dynamic_pointer_cast<Model_Document>(partDoc());
+ if (!aDoc.get()) // the part document is not presented for the moment
+ return aResult;
+
+ AttributeSelectionListPtr aSelAttr = aDoc->selectionInPartFeature();
+ aResult = aSelAttr->value(theIndex - 1)->value();
+ return aResult;
+}
void Model_ResultPart::colorConfigInfo(std::string& theSection, std::string& theName,
std::string& theDefault)