Commit 8ff0325e authored by Yumin Yuan's avatar Yumin Yuan
Browse files

Made discrete write-op to be like write-ops in other sessions

parent 80683af9
...@@ -49,14 +49,15 @@ WriteOperator::WriteOperator() ...@@ -49,14 +49,15 @@ WriteOperator::WriteOperator()
bool WriteOperator::ableToOperate() bool WriteOperator::ableToOperate()
{ {
smtk::model::Model model; smtk::model::Models models =
this->specification()->associatedModelEntities<smtk::model::Models>();
bool able2Op = bool able2Op =
this->ensureSpecification() && this->ensureSpecification() &&
// The SMTK model must be valid // The SMTK model must be valid
(model = this->specification()->findModelEntity("model") (models.size() > 0 && models[0].isValid() &&
->value().as<smtk::model::Model>()).isValid() &&
// The CMB model must exist // The CMB model must exist
this->discreteSession()->findModelEntity(model.entity()); this->discreteSession()->findModelEntity(models[0].entity()));
if(!able2Op) if(!able2Op)
return false; return false;
...@@ -74,8 +75,12 @@ OperatorResult WriteOperator::operateInternal() ...@@ -74,8 +75,12 @@ OperatorResult WriteOperator::operateInternal()
Session* opsession = this->discreteSession(); Session* opsession = this->discreteSession();
// ableToOperate should have verified that the model exists // ableToOperate should have verified that the model exists
smtk::model::Model model = this->specification()-> smtk::model::Models models =
findModelEntity("model")->value().as<smtk::model::Model>(); this->specification()->associatedModelEntities<smtk::model::Models>();
if (models.size() == 0)
return this->createResult(OPERATION_FAILED);
smtk::model::Model model = models[0];
vtkDiscreteModelWrapper* modelWrapper = vtkDiscreteModelWrapper* modelWrapper =
opsession->findModelEntity(model.entity()); opsession->findModelEntity(model.entity());
......
...@@ -4,10 +4,15 @@ ...@@ -4,10 +4,15 @@
<Definitions> <Definitions>
<!-- Operator --> <!-- Operator -->
<AttDef Type="write" BaseType="operator"> <AttDef Type="write" BaseType="operator">
<AssociationsDef Name="Model" NumberOfRequiredValues="1">
<MembershipMask>model</MembershipMask>
</AssociationsDef>
<ItemDefinitions> <ItemDefinitions>
<!--
<ModelEntity Name="model" NumberOfRequiredValues="1"> <ModelEntity Name="model" NumberOfRequiredValues="1">
<MembershipMask>model</MembershipMask> <MembershipMask>model</MembershipMask>
</ModelEntity> </ModelEntity>
-->
<File Name="filename" NumberOfRequiredValues="1" <File Name="filename" NumberOfRequiredValues="1"
ShouldExist="false" ShouldExist="false"
FileFilters="Conceptual Model Builder (*.cmb)"> FileFilters="Conceptual Model Builder (*.cmb)">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment