예제 #1
0
bool OSDocument::fromComponentLibrary(const OSItemId& itemId) const
{
  bool fromCompLibrary = (itemId.sourceId() == modelToSourceId(m_compLibrary));
  bool fromHVACCompLibrary = (itemId.sourceId() == modelToSourceId(m_hvacCompLibrary));
  bool fromCombinedCompLibrary = (itemId.sourceId() == modelToSourceId(m_combinedCompLibrary));
  bool result = (fromCompLibrary || fromHVACCompLibrary || fromCombinedCompLibrary);
  return result;
}
예제 #2
0
파일: OSItem.cpp 프로젝트: NREL/OpenStudio
bool OSItemId::operator==(const OSItemId& other) const
{
  bool result = false;
  if (!this->mimeDataText().isEmpty()){
    result = (this->mimeDataText() == other.mimeDataText());
  }
  return result;
}
예제 #3
0
boost::optional<model::Component> OSDocument::getComponent(const OSItemId& itemId) const
{
  boost::optional<model::Component> modelComponent;

  if(itemId.sourceId() == OSItemId::BCL_SOURCE_ID) 
  {
    boost::optional<BCLComponent> component;

    component = LocalBCL::instance().getComponent(itemId.itemId().toStdString());

    if(component){

      std::vector<std::string> oscFiles = component->files("osc");

      if(oscFiles.size() == 1u){

        openstudio::path oscPath = toPath(oscFiles[0]);

#ifdef _WINDOWS

        if (oscPath.string().size() > MAX_PATH){
          if (oscPath.is_complete()){
            oscPath = toPath("\\\\?\\") / oscPath;
          }
        }

#endif

        //BOOST_ASSERT(boost::filesystem::exists(oscPath));

        osversion::VersionTranslator translator;

        modelComponent = translator.loadComponent(oscPath);
      }
    }
  }
  
  return modelComponent;
}
예제 #4
0
boost::optional<model::ModelObject> OSDocument::getModelObject(const OSItemId& itemId) const
{
  if (fromModel(itemId)){
    Handle handle(itemId.itemId());
    return m_model.getModelObject<model::ModelObject>(handle);
  }else if (fromComponentLibrary(itemId)){
    if (itemId.sourceId() == modelToSourceId(m_compLibrary)){
      Handle handle(itemId.itemId());
      return m_compLibrary.getModelObject<model::ModelObject>(handle);
    }else if (itemId.sourceId() == modelToSourceId(m_hvacCompLibrary)){
      Handle handle(itemId.itemId());
      return m_hvacCompLibrary.getModelObject<model::ModelObject>(handle);
    }else if (itemId.sourceId() == modelToSourceId(m_combinedCompLibrary)){
      Handle handle(itemId.itemId());
      return m_combinedCompLibrary.getModelObject<model::ModelObject>(handle);
    }
  }

  return boost::none;
}
예제 #5
0
boost::optional<IddObjectType> OSDocument::getIddObjectType(const OSItemId& itemId) const
{
  if (fromBCL(itemId)){
    boost::optional<BCLComponent> component = LocalBCL::instance().getComponent(itemId.itemId().toStdString());
    if (component){
      BOOST_FOREACH(const Attribute& attribute, component->attributes()){
        if (istringEqual("OpenStudio Type", attribute.name())){
          try{
            IddObjectType iddObjectType(attribute.valueAsString());
            return iddObjectType;
          }catch(...){
          }
        }
      }
    }
  }

  boost::optional<model::ModelObject> modelObject = getModelObject(itemId);
  if (modelObject){
    return modelObject->iddObjectType();
  }

  return boost::none;
}
예제 #6
0
void RefrigerationController::removeCase(const OSItemId & itemid)
{
  if( boost::optional<model::Model> model = OSAppBase::instance()->currentModel() )
  {
    if(boost::optional<model::ModelObject> mo = model->getModelObject<model::ModelObject>(Handle(itemid.itemId())))
    {
      mo->remove();

      refresh();
    }
  }
}
예제 #7
0
void RefrigerationController::removeCondenser(const OSItemId & itemid)
{
  if( boost::optional<model::Model> model = OSAppBase::instance()->currentModel() )
  {
    if(boost::optional<model::ModelObject> mo = model->getModelObject<model::ModelObject>(Handle(itemid.itemId())))
    {
      mo->remove();

      OS_ASSERT(m_detailView);

      m_detailView->refrigerationCondenserView->setCondenserId(OSItemId());
    }
  }
}
예제 #8
0
void RefrigerationController::inspectOSItem(const OSItemId & itemid)
{
  boost::shared_ptr<OSDocument> doc = OSAppBase::instance()->currentDocument();

  OS_ASSERT(doc);

  OS_ASSERT(m_currentSystem);

  boost::optional<model::ModelObject> mo = m_currentSystem->model().getModelObject<model::ModelObject>(Handle(itemid.itemId()));

  doc->mainRightColumnController()->inspectModelObject(mo,false);
}
예제 #9
0
bool OSDocument::fromBCL(const OSItemId& itemId) const
{
  return (itemId.sourceId() == OSItemId::BCL_SOURCE_ID);
}
예제 #10
0
bool OSDocument::fromModel(const OSItemId& itemId) const
{
  return (itemId.sourceId() == modelToSourceId(m_model));
}