CModel* CModelManager::AddModel(CString URI) { TRACE("CModelManager::AddModel"); CModel *model = FindModel(URI); if (model == NULL) { if (URI.Right(3) == "ifc" || URI.Right(3) == "IFC" || URI.Right(3) == "Ifc" || URI.Right(6) == "ifcxml" || URI.Right(6) == "ifcXML" || URI.Right(6) == "ifcXml"|| URI.Right(6) == "IFCxml" || URI.Right(6) == "IFCXML" || URI.Right(6) == "IFCXml"|| URI.Right(6) == "Ifcxml" || URI.Right(6) == "IfcXML" || URI.Right(6) == "IfcXml") { model = new CIfcModel; ((CIfcModel*)model)->m_schemaFile = m_SchemaFile; } else model = new CGmlModel; model->m_URI = new char[URI.GetLength() + 1]; model->m_filePath = new char[URI.ReverseFind('\\') + 2]; model->m_fileName = new char[URI.GetLength() - URI.ReverseFind('\\') + 2]; strcpy(model->m_URI, URI.GetBuffer()); strcpy(model->m_filePath, URI.Mid(0, URI.ReverseFind('\\') + 1).GetBuffer()); strcpy(model->m_fileName, URI.Mid(URI.ReverseFind('\\') + 1, URI.GetLength()).GetBuffer()); m_models.push_back(model); model->OpenModel(); } return model; }
// virtual void CModelParameterSpecies::setValue(const C_FLOAT64 & value, const Framework & framework) { CModel * pModel = getModel(); if (framework == Concentration) { mConcentration = value; if (mpCompartment != NULL && pModel != NULL) { mValue = mConcentration * mpCompartment->getValue(ParticleNumbers) * pModel->getQuantity2NumberFactor(); } else { mValue = std::numeric_limits< C_FLOAT64 >::quiet_NaN(); } } else { mValue = value; if (mpCompartment != NULL && pModel != NULL) { mConcentration = mValue / mpCompartment->getValue(ParticleNumbers) * pModel->getNumber2QuantityFactor(); } else { mConcentration = std::numeric_limits< C_FLOAT64 >::quiet_NaN(); } } }
bool TaskWidget::commonAfterRunTask() { if (!mpTask) return false; if (mProgressBar != NULL) { mProgressBar->finish(); mProgressBar->deleteLater(); mProgressBar = NULL; } mpTask->setCallBack(NULL); CCopasiMessage::clearDeque(); assert(CCopasiRootContainer::getDatamodelList()->size() > 0); (*CCopasiRootContainer::getDatamodelList())[0]->finish(); // Update all values shown in the GUI CModel * pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel(); pModel->updateSimulatedValues(true); pModel->updateNonSimulatedValues(); protectedNotify(ListViews::STATE, ListViews::CHANGE, (*CCopasiRootContainer::getDatamodelList())[0]->getModel()->getKey()); unsetCursor(); CopasiUI3Window::getMainWindow()->suspendAutoSave(false); return loadTask(); }
void insertReactionRowsCommand::redo() { mpReactionDM->insertNewReactionRow(mPosition, mRows, QModelIndex()); assert(CCopasiRootContainer::getDatamodelList()->size() > 0); CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0]; assert(pDataModel != NULL); CModel * pModel = pDataModel->getModel(); assert(pModel != NULL); mpReaction = pModel->getReactions()[mPosition]; std::string sName = mpReaction->getObjectName(); if (mpReactionData != NULL) mpReactionData->setName(sName); CReactionInterface* ri = new CReactionInterface((*CCopasiRootContainer::getDatamodelList())[0]->getModel()); ri->initFromReaction(mpReaction); if (mpReactionData != NULL) mpReactionData->setRi(ri); setUndoState(true); setAction("Add to list"); if (mpReactionData != NULL) setName(mpReactionData->getName()); else setName(sName); }
/*!**************************************************************************** @Function InitApplication @Return bool true if no error occured @Description Code in InitApplication() will be called by PVRShell once per run, before the rendering context is created. Used to initialize variables that are not dependant on it (e.g. external modules, loading meshes, etc.) If the rendering context is lost, InitApplication() will not be called again. ******************************************************************************/ bool OGLES3StencilBuffer::InitApplication() { // Get and set the read path for content files CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath)); // Get and set the load/release functions for loading external files. // In the majority of cases the PVRShell will return NULL function pointers implying that // nothing special is required to load external files. CPVRTResourceFile::SetLoadReleaseFunctions(PVRShellGet(prefLoadFileFunc), PVRShellGet(prefReleaseFileFunc)); // Load the scene files if(!m_Cylinder.ReadFromFile(c_szCylinderFile) || !m_Sphere.ReadFromFile(c_szSphereFile)) { PVRShellSet(prefExitMessage, "ERROR: Couldn't load the .pod file\n"); return false; } // Initialise the angle variable m_fAngle = 0.0f; // Request Stencil Buffer support PVRShellSet(prefStencilBufferContext, true); return true; }
RemoveGlobalQuantityRowsCommand::RemoveGlobalQuantityRowsCommand( QModelIndexList rows, CQGlobalQuantityDM * pGlobalQuantityDM, const QModelIndex&) : CCopasiUndoCommand("Global Quantity", GLOBALQUANTITY_REMOVE) , mpGlobalQuantityDM(pGlobalQuantityDM) , mRows(rows) , mpGlobalQuantityData() , mFirstTime(true) { CCopasiDataModel * pDataModel = pGlobalQuantityDM->getDataModel(); assert(pDataModel != NULL); CModel * pModel = pDataModel->getModel(); assert(pModel != NULL); QModelIndexList::const_iterator i; for (i = rows.begin(); i != rows.end(); ++i) { CModelValue* pModelValue = &pModel->getModelValues()[i->row()]; if (pGlobalQuantityDM->isDefaultRow(*i) || pModelValue == NULL) continue; UndoGlobalQuantityData *data = new UndoGlobalQuantityData(pModelValue); mpGlobalQuantityData.append(data); } setText(QObject::tr(": Removed Global Quantity")); }
bool CQSpecieDM::removeRows(int position, int rows, const QModelIndex&) { if (rows <= 0) return true; beginRemoveRows(QModelIndex(), position, position + rows - 1); CModel * pModel = (*CCopasiRootContainer::getDatamodelList())[0]->getModel(); std::vector< std::string > DeletedKeys; DeletedKeys.resize(rows); std::vector< std::string >::iterator itDeletedKey; std::vector< std::string >::iterator endDeletedKey = DeletedKeys.end(); CCopasiVector< CMetab >::const_iterator itRow = pModel->getMetabolites().begin() + position; for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey, ++itRow) { *itDeletedKey = (*itRow)->getKey(); } for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey) { pModel->removeMetabolite(*itDeletedKey); emit notifyGUI(ListViews::METABOLITE, ListViews::DELETE, *itDeletedKey); emit notifyGUI(ListViews::METABOLITE, ListViews::DELETE, ""); //Refresh all as there may be dependencies. } endRemoveRows(); return true; }
void CQSpeciesDetail::loadReactionTable() { if (mpMetab == NULL) return; CModel * pModel = const_cast< CModel * >(mpMetab->getModel()); if (pModel == NULL) return; std::set< const CCopasiObject * > Reactions; pModel->appendDependentReactions(mpMetab->getDeletedObjects(), Reactions); mpReactionTable->setRowCount((int) Reactions.size()); std::set< const CCopasiObject * >::const_iterator it = Reactions.begin(); std::set< const CCopasiObject * >::const_iterator end = Reactions.end(); int i = 0; const CReaction * pReaction; for (; it != end; ++it, ++i) { pReaction = static_cast< const CReaction * >(*it); mpReactionTable->setItem(i, 0, new QTableWidgetItem(FROM_UTF8(pReaction->getObjectName()) + ":")); mpReactionTable->setItem(i, 1, new QTableWidgetItem(FROM_UTF8(CChemEqInterface::getChemEqString(pModel, *pReaction, false)))); } if (i == 0) mpReactionTable->setItem(i, 0, new QTableWidgetItem("none")); // Provide count of reactions, in label. mpLblReactions->setText("Involved in \n" + QString::number(mpReactionTable->rowCount()) + " Reactions"); return; }
RemoveAllReactionRowsCommand::RemoveAllReactionRowsCommand(CQReactionDM * pReaDM, const QModelIndex&) { mpReactionDM = pReaDM; assert(CCopasiRootContainer::getDatamodelList()->size() > 0); CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0]; assert(pDataModel != NULL); CModel * pModel = pDataModel->getModel(); assert(pModel != NULL); for (int i = 0; i != pReaDM->rowCount() - 1; ++i) { UndoReactionData *data = new UndoReactionData(); CReactionInterface* ri = new CReactionInterface((*CCopasiRootContainer::getDatamodelList())[0]->getModel()); if (pModel->getReactions()[i]) { data->setName(pModel->getReactions()[i]->getObjectName()); ri->initFromReaction(pModel->getReactions()[i]->getKey()); data->setRi(ri); mpReaData.append(data); } } mType = REACTIONREMOVEALL; setEntityType("Reaction"); this->setText(removeAllReactionRowsText()); }
void CEditAnimationDialog::OnSkinListBox( wxCommandEvent& event ) { TString strFileName = event.GetString(); wxString logMessage; m_pSkin = CResourceManager::GetInstance()->GetResource<CSkin>(strFileName, false); if (m_pSkin) { CModel* pModel = m_pAnimationGLWindow->GetModel(); if (pModel) { pModel->SetSkin(m_pSkin); m_pSkinCheckBox->SetValue(true); logMessage = strFileName + _T(" load success"); SharePtr<CTexture> pTestTexture = CResourceManager::GetInstance()->GetResource<CTexture>(_T("TestTexture.tga"), false); pModel->AddTexture(pTestTexture); m_bSkin = true; ShowAnima(); } else { logMessage = "No model is selected!"; } } else { m_pSkinCheckBox->SetValue(false); logMessage = WARNING + strFileName + _T(" load failed"); } wxLogMessage(logMessage); }
void SortModelRenderer::PrepareModels() { CMatrix3D worldToCam; if (m->models.size() == 0) return; g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam); for(std::vector<SModel*>::iterator it = m->models.begin(); it != m->models.end(); ++it) { SModel* smdl = *it; CModel* model = smdl->GetModel(); ENSURE(model->GetRenderData() == smdl); m->vertexRenderer->UpdateModelData(model, smdl->m_Data, smdl->m_UpdateFlags); smdl->m_UpdateFlags = 0; CVector3D modelpos = model->GetTransform().GetTranslation(); modelpos = worldToCam.Transform(modelpos); smdl->m_Distance = modelpos.Z; } PROFILE_START( "sorting transparent" ); std::sort(m->models.begin(), m->models.end(), SortModelsByDist()); PROFILE_END( "sorting transparent" ); }
void InsertCompartmentRowsCommand::redo() { if (firstTime) { mpCompartmentDM->insertNewCompartmentRow(mPosition, mRows, QModelIndex()); assert(CCopasiRootContainer::getDatamodelList()->size() > 0); CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0]; assert(pDataModel != NULL); CModel * pModel = pDataModel->getModel(); assert(pModel != NULL); CCompartment *pCompartment = pModel->getCompartments()[mPosition]; mpCompartmentData->setName(pCompartment->getObjectName()); mpCompartmentData->setStatus(pCompartment->getStatus()); mpCompartmentData->setInitialValue(pCompartment->getInitialValue()); firstTime = false; } else { mpCompartmentDM->addCompartmentRow(mpCompartmentData); } setUndoState(true); setAction("Add to list"); setName(mpCompartmentData->getName()); }
LIB3MFMETHODIMP CCOMModelTexture2D::ReadFromBuffer(_In_ BYTE * pBuffer, _In_ ULONG64 cbBufferSize) { try { if (pBuffer == nullptr) throw CNMRException(NMR_ERROR_INVALIDPOINTER); CModelTexture2DResource * pTextureResource = getTexture2D(); __NMRASSERT(pTextureResource); PImportStream pImportStream = std::make_shared<CImportStream_Memory>(pBuffer, cbBufferSize); CModel * pModel = pTextureResource->getModel(); __NMRASSERT(pModel); pModel->removeTextureStream(pTextureResource->getPath()); pModel->addTextureStream(pTextureResource->getPath(), pImportStream); return handleSuccess(); } catch (CNMRException & Exception) { return handleNMRException(&Exception); } catch (...) { return handleGenericException(); } }
void CQCompartment::deleteCompartment() { if (mpCompartment == NULL) return; QMessageBox::StandardButton choice = CQMessageBox::confirmDelete(this, "compartment", FROM_UTF8(mpCompartment->getObjectName()), mpCompartment->getDeletedObjects()); switch (choice) { case QMessageBox::Ok: { CModel * pModel = mpCompartment->getModel(); assert(pModel != NULL); pModel->removeCompartment(mKey); protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, mKey); protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, ""); //Refresh all as there may be dependencies. break; } default: break; } switchToWidget(CCopasiUndoCommand::COMPARTMENTS); }
LIB3MFMETHODIMP CCOMModelTexture2D::ReadFromFileUTF8(_In_z_ LPCSTR pszFilename) { try { if (pszFilename == nullptr) throw CNMRException(NMR_ERROR_INVALIDPOINTER); CModelTexture2DResource * pTextureResource = getTexture2D(); __NMRASSERT(pTextureResource); std::string sUTF8FileName(pszFilename); std::wstring sUTF16FileName = fnUTF8toUTF16(sUTF8FileName); PImportStream pImportStream = fnCreateImportStreamInstance(sUTF16FileName.c_str()); CModel * pModel = pTextureResource->getModel(); __NMRASSERT(pModel); pModel->removeTextureStream(pTextureResource->getPath()); pModel->addTextureStream(pTextureResource->getPath(), pImportStream); return handleSuccess(); } catch (CNMRException & Exception) { return handleNMRException(&Exception); } catch (...) { return handleGenericException(); } }
// Renders the scene. void CSceneManager::Render() { m_pRenderDevice->ClearScreen( m_ClearColour ); CVector3 camPos = m_pCamera->GetPosition(); m_pRender->RenderStart( &camPos );// place holder only. CTemplate* temp = 0; for(TUInt32 i = 0; i < m_TemplateList.size(); i++) { temp = m_TemplateList[i]; temp->Render( m_pRenderDevice->GetDevice() ); ID3D10ShaderResourceView* tex = temp->GetTexture(); for(TUInt32 model=0; model < temp->ModelCount(); model++) { CModel* current = temp->GetModelByIndex( model ); m_pRender->RenderModel( current->GetWorldMatrix(), tex ); m_pRenderDevice->DrawIndexed( temp->IndexCount() ); } } m_pRenderDevice->Present(); }
void CToySource::Build() const { Save(); CGeppetto g(true, FindAbsolutePath(GetDirectory(m_sFilename))); bool bSuccess = g.BuildFromInputScript(FindAbsolutePath(m_sFilename)); if (bSuccess) { if (CModelLibrary::FindModel(m_sToyFile) != ~0) { CModel* pModel = CModelLibrary::GetModel(CModelLibrary::FindModel(m_sToyFile)); TAssert(pModel); if (pModel) { for (size_t i = 0; i < GameServer()->GetMaxEntities(); i++) { CBaseEntity* pEntity = CBaseEntity::GetEntity(i); if (!pEntity) continue; if (pEntity->GetModel() == pModel) pEntity->RemoveFromPhysics(); } pModel->Reload(); } } else CModelLibrary::AddModel(m_sToyFile); } }
void CQSpeciesDetail::slotBtnDelete() { if (mpMetab == NULL) return; CModel * pModel = const_cast< CModel *>(mpMetab->getModel()); if (pModel == NULL) return; QMessageBox::StandardButton choice = CQMessageBox::confirmDelete(this, "species", FROM_UTF8(mpMetab->getObjectName()), mpMetab->getDeletedObjects()); switch (choice) { case QMessageBox::Ok: { pModel->removeMetabolite(mKey); #undef DELETE protectedNotify(ListViews::METABOLITE, ListViews::DELETE, mKey); protectedNotify(ListViews::METABOLITE, ListViews::DELETE, "");//Refresh all as there may be dependencies. //TODO notify about reactions break; } default: break; } }
void CEditAnimationDialog::OnAnimationListBox( wxCommandEvent& event ) { TString strFileName = event.GetString(); wxString logMessage; m_pAnimation = CResourceManager::GetInstance()->GetResource<CAnimation>(strFileName, false); if (m_pAnimation) { CModel* pModel = m_pAnimationGLWindow->GetModel(); if (pModel) { pModel->SetAnimaton(m_pAnimation); m_pAnimationCheckBox->SetValue(true); logMessage = strFileName; logMessage.append(_T(" load success")); m_bAnimation = true; ShowAnima(); } else { logMessage = "No model is selected!"; } } else { m_pAnimationCheckBox->SetValue(false); logMessage = WARNING + strFileName + _T(" load failed"); } wxLogMessage(logMessage); }
void CQSpeciesDetail::loadReactionTable() { if (mpMetab == NULL) return; CModel * pModel = const_cast< CModel * >(mpMetab->getModel()); if (pModel == NULL) return; std::set< const CCopasiObject * > Reactions; pModel->appendDependentReactions(mpMetab->getDeletedObjects(), Reactions); mpReactionTable->setRowCount(Reactions.size()); std::set< const CCopasiObject * >::const_iterator it = Reactions.begin(); std::set< const CCopasiObject * >::const_iterator end = Reactions.end(); int i = 0; const CReaction * pReaction; for (; it != end; ++it, ++i) { pReaction = static_cast< const CReaction * >(*it); mpReactionTable->setItem(i, 0, new QTableWidgetItem(FROM_UTF8(pReaction->getObjectName()) + ":")); mpReactionTable->setItem(i, 1, new QTableWidgetItem(FROM_UTF8(CChemEqInterface::getChemEqString(pModel, *pReaction, false)))); } if (i == 0) mpReactionTable->setItem(i, 0, new QTableWidgetItem("none")); // Resize columns to content. return; }
void Cockpit::drawWeapon () { char str [20]; CColor color; CVector3 tl, n; CRotation r; if (fplayer->missiles [fplayer->missiletype] <= 0) return; color.setColor (255, 0, 0); color.c [3] = 255; tl.x = 0.35; tl.y = -0.3; tl.z = -0.5; gl->disableAlphaBlending (); glEnable (GL_DEPTH_TEST); CModel *missile = NULL; if (fplayer->missiletype == 0) missile = &model_missile1; else if (fplayer->missiletype == 1) missile = &model_missile2; else if (fplayer->missiletype == 2) missile = &model_missile3; else if (fplayer->missiletype == 3) missile = &model_missile4; else if (fplayer->missiletype == 4) missile = &model_missile5; else if (fplayer->missiletype == 5) missile = &model_missile6; else if (fplayer->missiletype == 6) missile = &model_missile7; else if (fplayer->missiletype == 7) missile = &model_missile8; glEnable (GL_LIGHTING); missile->draw (&n, &tl, fplayer->rot, 0.05, 1.0, 0); glDisable (GL_LIGHTING); glDisable (GL_DEPTH_TEST); font1->drawText (16.0, -22.0, -4.0, missile->name, &color); sprintf (str, "N %d", fplayer->missiles [fplayer->missiletype]); font1->drawText (16.0, -24.0, -4.0, str, &color); }
VOID ReleaseModels(){ CModel* pModel = models; for(DWORD i=0; i < numModels; i++, pModel++){ pModel->Release(); } }
wxTreeItemId CEditAnimationDialog::AddModelToTree( TString ModelName ) { wxTreeItemId item = m_pModelTree->AppendItem(m_pModelTree->GetRootItem(), ModelName, eTCIT_File); CModel* pNewModel = new CModel; pNewModel->Initialize(); m_ModelNameMap[item] = pNewModel; return item; }
void CEditAnimationDialog::OnStopAnimation( wxCommandEvent& /*event*/ ) { CModel* pModel = m_pAnimationGLWindow->GetModel(); if (pModel) { pModel->GetAnimationController()->Stop(); m_pTimeBar->SetCurrentCursor(0); } }
void plugin_call(int maxthread) { srand(2); try { CModel model; model.init_and_terminate(maxthread); } catch( std::runtime_error& error ) { fprintf(stderr, "ERROR: %s\n", error.what()); } }
void test000052::test_bug988() { CDataModel* pDataModel = pCOPASIDATAMODEL; CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING)); CModel* pModel = pDataModel->getModel(); CPPUNIT_ASSERT(pModel != NULL); CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::mMol); CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml); CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s); CPPUNIT_ASSERT(pModel->getCompartments().size() == 1); const CCompartment* pCompartment = pModel->getCompartments()[0]; CPPUNIT_ASSERT(pCompartment != NULL); CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::Status::FIXED); CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1); CMetab* pA = pModel->getMetabolites()[0]; CPPUNIT_ASSERT(pA != NULL); CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::Status::ASSIGNMENT); const CExpression* pExpr = pA->getExpressionPtr(); // check the expression const CEvaluationNode* pNode = pExpr->getRoot(); CPPUNIT_ASSERT(pNode != NULL); const CEvaluationNodeChoice* pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pNode); CPPUNIT_ASSERT(pChoiceNode != NULL); pNode = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild()); CPPUNIT_ASSERT(pNode != NULL); const CEvaluationNodeLogical* pLogicalNode = dynamic_cast<const CEvaluationNodeLogical*>(pNode); CPPUNIT_ASSERT(pLogicalNode != NULL); CPPUNIT_ASSERT((pLogicalNode->subType()) == CEvaluationNode::SubType::LT); const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pLogicalNode->getChild()); CPPUNIT_ASSERT(pObjectNode != NULL); CCommonName objectCN = pObjectNode->getObjectCN(); CPPUNIT_ASSERT(!objectCN.empty()); CObjectInterface::ContainerList listOfContainers; listOfContainers.push_back(pModel); const CDataObject* pObject = CObjectInterface::DataModel(pCOPASIDATAMODEL->getObjectFromCN(listOfContainers, objectCN)); CPPUNIT_ASSERT(pObject != NULL); CPPUNIT_ASSERT(pObject->hasFlag(CDataObject::Reference) == true); CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time")); CPPUNIT_ASSERT(pObject->getObjectParent() == pModel); const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pObjectNode->getSibling()); CPPUNIT_ASSERT(pNumberNode != NULL); CPPUNIT_ASSERT((pNumberNode->subType()) == CEvaluationNode::SubType::DOUBLE); CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 5.0) / 5.0) < 1e-3); pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pLogicalNode->getSibling()); CPPUNIT_ASSERT(pNumberNode != NULL); CPPUNIT_ASSERT((pNumberNode->subType()) == CEvaluationNode::SubType::DOUBLE); CPPUNIT_ASSERT(pNumberNode->getValue() < 1e-3); pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNumberNode->getSibling()); CPPUNIT_ASSERT(pNumberNode != NULL); CPPUNIT_ASSERT((pNumberNode->subType()) == CEvaluationNode::SubType::DOUBLE); CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-3); CPPUNIT_ASSERT(pModel->getModelValues().size() == 0); CPPUNIT_ASSERT(pModel->getReactions().size() == 0); }
LIB3MFMETHODIMP CCOMModelComponentsObject::AddComponent(_In_ ILib3MFModelObjectResource * pObject, _In_opt_ MODELTRANSFORM * pmTransform, _Outptr_ ILib3MFModelComponent ** ppComponent) { try { if (!pObject) throw CNMRException (NMR_ERROR_INVALIDPOINTER); CModelComponentsObject * pComponentsObject = getComponentsObject(); CModel * pModel = pComponentsObject->getModel(); __NMRASSERT(pModel); // Get Resource ID ModelResourceID nObjectID; HRESULT hResult = pObject->GetResourceID(&nObjectID); if (hResult != LIB3MF_OK) return hResult; // Find class instance CModelObject * pObject = pModel->findObject(nObjectID); if (pObject == nullptr) throw CNMRException(NMR_ERROR_RESOURCENOTFOUND); // Convert Transform, if given NMATRIX3 mMatrix = fnMATRIX3_identity(); if (pmTransform) { int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { mMatrix.m_fields[i][j] = pmTransform->m_fFields[i][j]; } } } // Create Model component PModelComponent pNewComponent = std::make_shared<CModelComponent>(pObject, mMatrix); pComponentsObject->addComponent(pNewComponent); // Create Component COM Wrapper if (ppComponent) { CCOMObject<CCOMModelComponent> * pResult = new CCOMObject<CCOMModelComponent>(); pResult->AddRef(); pResult->setComponent(pNewComponent); *ppComponent = pResult; } return handleSuccess(); } catch (CNMRException & Exception) { return handleNMRException(&Exception); } catch (...) { return handleGenericException(); } }
void plugin_call(int maxthread) { srand(2); __TBB_TRY { CModel model; model.init_and_terminate(maxthread); } __TBB_CATCH( std::runtime_error& error ) { #if TBB_USE_EXCEPTIONS REPORT("ERROR: %s\n", error.what()); #endif /* TBB_USE_EXCEPTIONS */ }
int OOF_ReleaseTextures (void) { CModel* modelP; int bCustom, i; PrintLog ("releasing OOF model textures\n"); for (bCustom = 0; bCustom < 2; bCustom++) for (i = gameData.models.nHiresModels, modelP = gameData.models.oofModels [bCustom].Buffer (); i; i--, modelP++) modelP->ReleaseTextures (); return 0; }
void CQSpeciesDetail::slotBtnDelete() { if (mpMetab == NULL) return; CModel * pModel = const_cast< CModel *>(mpMetab->getModel()); if (pModel == NULL) return; QMessageBox::StandardButton choice = CQMessageBox::confirmDelete(this, "species", FROM_UTF8(mpMetab->getObjectName()), mpMetab->getDeletedObjects()); switch (choice) { case QMessageBox::Ok: { unsigned C_INT32 index = pModel->getMetabolites().getIndex(CCopasiRootContainer::getKeyFactory()->get(mKey)); pModel->removeMetabolite(mKey); std::string deletedKey = mKey; unsigned C_INT32 size = pModel->getMetabolites().size(); QObject *pParent = parent(); CTabWidget * pTabWidget = NULL; while (pParent != NULL && (pTabWidget = dynamic_cast< CTabWidget *>(pParent)) == NULL) { pParent = pParent->parent(); } if (pTabWidget != NULL) { if (size > 0) pTabWidget->enter(pModel->getMetabolites()[std::min(index, size - 1)]->getKey()); else pTabWidget->enter(""); } #undef DELETE protectedNotify(ListViews::METABOLITE, ListViews::DELETE, deletedKey); protectedNotify(ListViews::METABOLITE, ListViews::DELETE, "");//Refresh all as there may be dependencies. //TODO notify about reactions break; } default: break; } }