void ModelObjectVectorController::attach(const model::ModelObject& modelObject)
{
  detach();

  m_modelObject = modelObject;

  attachModel(modelObject.model());

  connect(m_model->getImpl<model::detail::Model_Impl>().get(),
    static_cast<void (model::detail::Model_Impl::*)(std::shared_ptr<detail::WorkspaceObject_Impl>, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::addWorkspaceObject),
    this,
    &ModelObjectVectorController::objectAdded,
    Qt::QueuedConnection);
  
  connect(m_model->getImpl<model::detail::Model_Impl>().get(),
    static_cast<void (model::detail::Model_Impl::*)(std::shared_ptr<detail::WorkspaceObject_Impl>, const IddObjectType &, const UUID &) const>(&model::detail::Model_Impl::removeWorkspaceObject),
    this,
    &ModelObjectVectorController::objectRemoved,
    Qt::QueuedConnection);
  
  connect(m_modelObject->getImpl<model::detail::ModelObject_Impl>().get(), &model::detail::ModelObject_Impl::onRelationshipChange,
          this, &ModelObjectVectorController::changeRelationship);

  connect(m_modelObject->getImpl<model::detail::ModelObject_Impl>().get(), &model::detail::ModelObject_Impl::onDataChange,
          this, &ModelObjectVectorController::dataChange);

  connect(m_modelObject->getImpl<model::detail::ModelObject_Impl>().get(), &model::detail::ModelObject_Impl::onChange,
          this, &ModelObjectVectorController::change);
}
void BuildingStorySpacesVectorController::attach(const model::ModelObject& modelObject)
{
  ModelObjectVectorController::attach(modelObject);
  BOOST_FOREACH(const model::Space& space, modelObject.model().getModelObjects<model::Space>()){
    attachOtherModelObject(space);
  }
}
void SpaceSpaceTypeVectorController::attach(const model::ModelObject& modelObject)
{
    ModelObjectVectorController::attach(modelObject);

    model::Building building = modelObject.model().getUniqueModelObject<model::Building>();
    attachOtherModelObject(building);
}
void ModelObjectVectorController::attachOtherModelObject(const model::ModelObject& modelObject)
{
  // check not already connected
  for (const model::ModelObject& currentModelObject : m_otherModelObjects){
    if (modelObject.handle() == currentModelObject.handle()){
      return;
    }
  }

  m_otherModelObjects.push_back(modelObject);

  connect(modelObject.getImpl<model::detail::ModelObject_Impl>().get(), &model::detail::ModelObject_Impl::onRelationshipChange,
          this, &ModelObjectVectorController::changeRelationship);
}
void ModelObjectVectorController::detachOtherModelObject(const model::ModelObject& modelObject)
{
  std::vector<model::ModelObject>::const_iterator it = m_otherModelObjects.begin();
  std::vector<model::ModelObject>::const_iterator itend = m_otherModelObjects.end();
  std::vector<model::ModelObject> newVector;
  for (; it != itend; ++it){
    if (it->handle() == modelObject.handle()){
      disconnect(modelObject.getImpl<model::detail::ModelObject_Impl>().get());
    }else{
      newVector.push_back(*it);
    }
  }
  m_otherModelObjects.swap(newVector);
}
Exemple #6
0
void OSDoubleEdit::bind(model::ModelObject& modelObject,
                          const char* property,
                          const boost::optional<std::string>& isDefaultedProperty,
                          const boost::optional<std::string>& isAutosizedProperty,
                          const boost::optional<std::string>& isAutocalculatedProperty)
{
  m_modelObject = modelObject;
  m_property = property;
  m_isDefaultedProperty = isDefaultedProperty;
  m_isAutosizedProperty = isAutosizedProperty;
  m_isAutocalculatedProperty = isAutocalculatedProperty;

  // only let one of autosize/autocalculate
  if (isAutosizedProperty && isAutocalculatedProperty) {
    LOG_AND_THROW("A field can only be autosized or autocalculated, it cannot be both.");
  }

  // check for attribute existence
  StringVector attributeNames = modelObject.attributeNames();
  StringVector::const_iterator anb(attributeNames.begin()),ane(attributeNames.end());
  BOOST_ASSERT(std::find(anb,ane,m_property) != ane);
  if (m_isDefaultedProperty) {
    BOOST_ASSERT(std::find(anb,ane,*m_isDefaultedProperty) != ane);
  }
  if (m_isAutosizedProperty) {
    BOOST_ASSERT(std::find(anb,ane,*m_isAutosizedProperty) != ane);
  }
  if (m_isAutocalculatedProperty) {
    BOOST_ASSERT(std::find(anb,ane,*m_isAutocalculatedProperty) != ane);
  }

  setEnabled(true);

  bool isConnected = false;
  isConnected = connect( this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()) );
  BOOST_ASSERT(isConnected);

  isConnected = connect( m_modelObject->getImpl<openstudio::model::detail::ModelObject_Impl>().get(),SIGNAL(onChange()),
                         this,SLOT(onModelObjectChange()) );
  BOOST_ASSERT(isConnected);

  isConnected = connect( m_modelObject->getImpl<openstudio::model::detail::ModelObject_Impl>().get(),SIGNAL(onRemoveFromWorkspace(Handle)),
                         this,SLOT(onModelObjectRemove(Handle)) );
  BOOST_ASSERT(isConnected);

  refreshTextAndLabel();
}
void ModelObjectVectorController::attachOtherModelObject(const model::ModelObject& modelObject)
{
  // check not already connected
  BOOST_FOREACH(const model::ModelObject& currentModelObject, m_otherModelObjects){
    if (modelObject.handle() == currentModelObject.handle()){
      return;
    }
  }

  m_otherModelObjects.push_back(modelObject);

  bool isConnected = false;
  isConnected = connect(modelObject.getImpl<model::detail::ModelObject_Impl>().get(),
                        SIGNAL(onRelationshipChange(int, Handle, Handle)),
                        this,
                        SLOT(changeRelationship(int, Handle, Handle)));
  OS_ASSERT(isConnected);
}
 // sort by name
 bool operator()(const model::ModelObject & lhs, const model::ModelObject & rhs){
   return (lhs.name() < rhs.name());
 }
void SpaceSpaceInfiltrationDesignFlowRateVectorController::attach(const model::ModelObject& modelObject)
{
    ModelObjectVectorController::attach(modelObject);
    BOOST_FOREACH(const model::SpaceInfiltrationDesignFlowRate& spaceInfiltrationDesignFlowRate, modelObject.model().getConcreteModelObjects<model::SpaceInfiltrationDesignFlowRate>()) {
        attachOtherModelObject(spaceInfiltrationDesignFlowRate);
    }
}
void SubSurfaceConstructionVectorController::onDataChange(const model::ModelObject& modelObject)
{
  if (m_modelObject && (modelObject.handle() == m_modelObject->handle())){
    emit itemIds(makeVector());
  }
}