void Renderer::cacheModel(const ModelData& data) { for(auto m: models) if(data.getName()==m->getName()) return; models.push_back(new StaticModel{data.getName(),data.vertexdata,data.parts}); }
recondite::Model* reProjectAssets::ImportModel(const wxString& path) { import::ModelImporter modelImporter; import::ModelImporterOptions options; ModelData modelData; int error = modelImporter.ImportModel(path.c_str().AsChar(), modelData, options); if (!error) { modelData.CalculateBoundings(); wxFileName modelPath(path); wxString modelName = modelPath.GetName(); WriteModel(modelData, modelName); if (modelData.GetLineMeshCount() == 0) { CreateSelectionWireframeForModel(modelData); } recondite::Model* model = _component->GetEngine()->content->Models()->LoadFromData(modelData, modelName.c_str().AsChar()); wxString modelHandle = GetAssetPath(rAssetType::Model, modelName); _manifest.Add(rAssetType::Model, modelName.c_str().AsChar(), modelHandle.c_str().AsChar()); return model; } return nullptr; }
void RealTimeStationSearchModelPrivate::slotStationsRegistered(const QString & request, const QList<Station> &stations) { if (!requestRunning(request)) { return; } AbstractBackendWrapper *backend = qobject_cast<AbstractBackendWrapper *>(sender()); if (!backend) { return; } debug("realtime-station-search-model") << "Request" << request << "finished"; removeRequest(request); bool support = backend->capabilities().contains(CAPABILITY_REAL_TIME_RIDES_FROM_STATION); ModelDataList addedData; foreach (Station station, stations) { ModelData data; data.insert(Qt::UserRole + STATION_INDEX, QVariant::fromValue(station)); data.insert(Qt::UserRole + BACKEND_IDENTIFIER_INDEX, backend->identifier()); data.insert(RealTimeStationSearchModel::NameRole, station.name()); // TODO ProviderNameRole data.insert(RealTimeStationSearchModel::SupportRidesFromStationRole, support); addedData.append(data); }
void reProjectAssets::OnModelResourceLoaded(rEvent& event) { rResourceLoadedEvent& resourceLoadedEvent = (rResourceLoadedEvent&)event; ModelData* modelData = resourceLoadedEvent.GetModelData(); if (modelData->GetLineMeshCount() == 0) { CreateSelectionWireframeForModel(*modelData); } }
WizMix::operator ModelData() { int throttleChannel = -1; bool isTaranis = IS_TARANIS(GetEepromInterface()->getBoard()); ModelData model; model.used = true; model.modelId = modelId; model.setDefaultInputs(settings); int mixIndex = 0; int switchIndex = 0; int timerIndex = 0; // Safe copy model name strncpy(model.name, name, WIZ_MODEL_NAME_LENGTH); model.name[WIZ_MODEL_NAME_LENGTH] = 0; // Add the channel mixes for (int i=0; i<WIZ_MAX_CHANNELS; i++ ) { Channel ch = channel[i]; if (ch.input1 == THROTTLE_INPUT || ch.input2 == THROTTLE_INPUT) throttleChannel = i; addMix(model, ch.input1, ch.weight1, i, mixIndex); addMix(model, ch.input2, ch.weight2, i, mixIndex); } // Add the Throttle Cut option if( options[THROTTLE_CUT_OPTION] && throttleChannel >=0 ) { model.funcSw[switchIndex].swtch.type = SWITCH_TYPE_SWITCH; model.funcSw[switchIndex].swtch.index = isTaranis ? SWITCH_SF0 : SWITCH_THR; model.funcSw[switchIndex].enabled = 1; model.funcSw[switchIndex].func = (AssignFunc)throttleChannel; model.funcSw[switchIndex].param = -100; } // Add the Flight Timer option if (options[FLIGHT_TIMER_OPTION] ) { model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE; model.timers[timerIndex].mode.index = TMRMODE_THR_TRG; timerIndex++; } // Add the Throttle Timer option if (options[THROTTLE_TIMER_OPTION] && throttleChannel >=0) { model.timers[timerIndex].mode.type = SWITCH_TYPE_TIMER_MODE; model.timers[timerIndex].mode.index = TMRMODE_THR; timerIndex++; } return model; }
void CreateScreen( ModelData& ScreenMesh) { MeshData Screen; AttribData<vec3> Screen_vert; Screen_vert.Resize(4); Screen_vert.Set(0, vec3(-1.0f, 1.0f, 1.0f)); // lu-corner Screen_vert.Set(1, vec3( 1.0f, 1.0f, 1.0f)); // ru-corner Screen_vert.Set(2, vec3(-1.0f, -1.0f, 1.0f)); // bl-corner Screen_vert.Set(3, vec3( 1.0f, -1.0f, 1.0f)); // br-corner AttribData<vec2> Screen_UVs; Screen_UVs.Resize(4); Screen_UVs.Set(0, vec2(0.0f, 0.0f)); Screen_UVs.Set(1, vec2(0.0f, 1.0f)); Screen_UVs.Set(2, vec2(1.0f, 0.0f)); Screen_UVs.Set(3, vec2(1.0f, 1.0f)); AttribData<GLFace16> Screen_face; Screen_face.Resize(2); Screen_face.Set(0, GLFace16(0, 1, 2)); Screen_face.Set(1, GLFace16(1, 3, 2)); Polygons polys; polys.SetFaces(Screen_face); polys.SetMaterial(0); AttribData<Polygons> polygons; polygons.Resize(1); polygons.Set(0, polys); Screen.SetName("Screen"); Screen.SetVertexArray(Screen_vert); Screen.SetUVArray(Screen_UVs); Screen.SetPolygonList(polygons); Screen.GenerateNormals(false); Screen.GenerateTangents(); MaterialData Screen_mat; Screen_mat.MaterialType = HasRenderedTexture; Library<MaterialData> lib_mat; lib_mat.Resize(1); lib_mat.Set(0, Screen_mat); Library<MeshData> lib_mesh; lib_mesh.Resize(1); lib_mesh.Set(0, Screen); ScreenMesh.SetMeshData(lib_mesh); ScreenMesh.SetMaterialData(lib_mat); }
bool OpenTxEepromInterface::loadModel(ModelData &model, uint8_t *data, int index, unsigned int stickMode) { T _model; if (!data) { // load from EEPROM efile->openRd(FILE_MODEL(index)); int sz = efile->readRlc2((uint8_t*)&_model, sizeof(T)); if (sz) { model = _model; if (sz < (int)sizeof(T)) { std::cout << " size(" << model.name << ") " << sz << " < " << (int)sizeof(T) << " "; } if (stickMode) { applyStickModeToModel(model, stickMode); } } else { model.clear(); } } else { // load from SD Backup, size is stored in index if ((unsigned int)index < sizeof(T)) return false; memcpy((uint8_t*)&_model, data, sizeof(T)); model = _model; } return true; }
bool OpenTxEepromInterface::loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant) { T open9xModel(model, board, version, variant); if (!data) { // load from EEPROM QByteArray eepromData(sizeof(model), 0); // ModelData should be always bigger than the EEPROM struct efile->openRd(FILE_MODEL(index)); int numbytes = efile->readRlc2((uint8_t *)eepromData.data(), eepromData.size()); if (numbytes) { open9xModel.Import(eepromData); // open9xModel.Dump(); model.used = true; } else { model.clear(); } } else { // load from SD Backup, size is stored in index QByteArray eepromData((char *)data, index); open9xModel.Import(eepromData); } return true; }
void ResourceThreadModel::Load(const ResourceRequest& request) { DALI_ASSERT_DEBUG(request.GetType()->id == ResourceModel); DALI_LOG_INFO(mLogFilter, Debug::Verbose, "%s(%s)\n", __PRETTY_FUNCTION__, request.GetPath().c_str()); scoped_ptr<ModelBuilder> modelBuilder( CreateModelBuilder(request.GetPath()) ); ModelData modelData = ModelData::New(modelBuilder->GetModelName()); const bool success = modelBuilder->Build(modelData); if( success ) { // Construct LoadedResource and ResourcePointer for model data LoadedResource resource( request.GetId(), request.GetType()->id, ResourcePointer(&(modelData.GetBaseObject()))); // Queue the loaded resource mResourceLoader.AddLoadedResource(resource); } else { // add to the failed queue FailedResource resource(request.GetId(), FailureUnknown); mResourceLoader.AddFailedLoad(resource); } }
int main(int argc, char* argv[]) { LoaderObj *loader = new LoaderObj(); loader->loadFile("test.obj"); ModelData data; loader->cloneData(data); delete loader; Encoder *encoder = new Encoder(); // FIXME: set data should clone, but here is not. encoder->setData(data); encoder->saveFile("test.objc"); data.dispose(); return 0; }
Model::Model(ModelData & _data) : UsingShader(&ResMgr::loadShader(simpleShaderName, shaderSrcs::model_Vertex, shaderSrcs::model_Fragment, Shader::FromString), &ResMgr::loadShader(lightShaderName, shaderSrcs::model_LightVertex, shaderSrcs::model_LightFragment, Shader::FromString)), m_modelData(&_data), m_vaos(_data.getMeshes().size()), m_color(Color::Black), m_useColorOnly(false) { setUp(); }
void ModelViewerModule::Init(const rArrayString& args) { auto createControllerFunc = [&](const rString& name, rEngine* engine, ruiDocument* document) { return new ModelViewerController(_skeletonGeometry.get(), name, engine, document); }; auto deleteControllerFunc = [](ruiController* controller) { delete controller; }; _engine->ui->RegisterControllerClass("ModelViewerController", createControllerFunc, deleteControllerFunc); Model* model = nullptr; rString file, archive; ParseArgs(args, file, archive); if (!archive.empty()) { _engine->resources->OpenArchive(archive); model = _engine->content->Models()->LoadFromResource(file, "model"); } else { auto fileSystemRef = _engine->filesystem->OpenReadFileRef(file); ModelData modelData; modelData.Read(*fileSystemRef); _engine->filesystem->CloseReadFileRef(fileSystemRef); model = _engine->content->Models()->LoadFromData(modelData, "model"); } if (model->GetSkeleton()) { rPawn* pawn = new rPawn(model, "model", _engine); _skeletonGeometry.reset(new SkeletonGeometry(_engine, pawn)); _engine->scene->AddActor(pawn); } else { rProp* prop = new rProp(model, "model", _engine); _engine->scene->AddActor(prop); } rViewport* mainViewport = CreateView(model, _engine); _engine->ui->LoadUiDocument("C:/development/recondite/samples/modelviewer/modelviewer/modelviewer.xml", mainViewport); }
//============================================================================== // Loads Model Data into OpenGL and Stores Handles in Static Variables //============================================================================== void Tree::loadResources() { shaderProgram = ShaderUtil::createProgram("Tree", std::vector < GLenum > {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER}, true); sPositionHandle = glGetAttribLocation(shaderProgram, "iPosition"); sNormalHandle = glGetAttribLocation(shaderProgram, "iNormal"); sSunHandle = glGetUniformLocation(shaderProgram, "uSunDirection"); sMVPHandle = glGetUniformLocation(shaderProgram, "uMVP"); sNormalMatrixHandle = glGetUniformLocation(shaderProgram, "uNormalMatrix"); ModelData data = ShaderUtil::loadModel("tree"); verticesVBO = data.getVerticesVBO(); normalsVBO = data.getNormalsVBO(); vertCount = data.getVertCount(); glGenVertexArrays(1, &VAO); glBindVertexArray(VAO); glUseProgram(shaderProgram); //------------------------------------------------------------------------------ // Load Vertex Data //------------------------------------------------------------------------------ glBindBuffer(GL_ARRAY_BUFFER, verticesVBO); glEnableVertexAttribArray(sPositionHandle); glVertexAttribPointer(sPositionHandle, 3, GL_FLOAT, GL_FALSE, 0, NULL); //------------------------------------------------------------------------------ // Load Normal Data //------------------------------------------------------------------------------ glBindBuffer(GL_ARRAY_BUFFER, normalsVBO); glEnableVertexAttribArray(sNormalHandle); glVertexAttribPointer(sNormalHandle, 3, GL_FLOAT, GL_FALSE, 0, NULL); glUseProgram(0); glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); }
ModelData* ModelComponent::getModelData(){ ModelData *md = new ModelData(); std::map<char,std::vector<QString>* > numbers; for(std::map<char, QLineEdit*>::iterator i = components.begin(); i != components.end(); i++){ QString txt = i->second->text(); int count = 0; std::vector<QString> *vecString = new std::vector<QString>(); vecString->push_back(""); numbers[i->first] = vecString; QString::iterator j = txt.begin(); for(QString::iterator j = txt.begin(); j != txt.end(); j++){ if(((*j) >= '0' && (*j) <= '9') || (*j) == ',' || (*j) == '.' || (*j)=='-'){ //ten warunek mozna poprawic(chodzi o wystapienie dwoch kropek albo minusow vecString->at(count).push_back( (*j)); }else if((*j) == 32){ count++; vecString->push_back(""); }else{ break; //TODO throw execption } } if(vecString->back() == "" ){ vecString->pop_back(); } } std::vector<QString>* A = numbers.at('A'); std::vector<double> Adouble; for(std::vector<QString>::iterator i = A->begin(); i != A->end(); i++){ Adouble.push_back((*i).toDouble()); } md->setA(Adouble); std::vector<QString>* B = numbers.at('B'); std::vector<double> Bdouble; for(std::vector<QString>::iterator i = B->begin(); i != B->end(); i++){ Bdouble.push_back((*i).toDouble()); } md->setB(Bdouble); std::vector<QString>* k = numbers.at('k'); md->setK(k->at(0).toDouble()); std::vector<QString>* t = numbers.at('t'); md->setT(t->at(0).toDouble()); std::vector<QString>* nr = numbers.at('nr'); md->setNoiseRatio(nr->at(0).toDouble()); return md; }
void Gruvin9xInterface::loadModel(ModelData &model, unsigned int stickMode, int version) { T _model; if ((version == 2 && efile->readRlc2((uint8_t*)&_model, sizeof(T))) || (version == 1 && efile->readRlc1((uint8_t*)&_model, sizeof(T)))) { model = _model; if (stickMode) { applyStickModeToModel(model, stickMode); } } else { model.clear(); } }
const icp_norm_map ModelData::determineSimilarity(const model_map& modelMap, icp_measure normMeasure){ icp_norm_map distanceMap; if (modelMap.empty()) return distanceMap; model_map::const_iterator d_i; icp_matrix icpMat; for (d_i = modelMap.cbegin(); d_i != modelMap.cend(); d_i++){ ModelData* model = d_i->second; const std::string name = d_i->first; if (model == nullptr) continue; distanceMap.emplace(name, -1.0); // Default norm --> should never be negative, so serves as an 'uninitialised', marker. IterClosestPoint::compare(icpMat, model, this, model->cloudIn(), model->cloudOut()); distanceMap[name] = normMeasure(icpMat); } return distanceMap; }
void WeaponManager::LoadWeapon(const char * name, int shootingNodeID , WeaponParams params) { ResourceLoader & resaourceLoader = ResourceLoader::GetResourceLoader(); SoldierWeapon * pSoldierWeapon = new SoldierWeapon(); pSoldierWeapon->SetWeaponParams(params ); static char modName[128]={0}; sprintf(modName, "%s.mod",name); //ModelData * pWeaponModel = resaourceLoader.LoadModel( "M16.mod" ); ModelData * pWeaponModel = resaourceLoader.LoadModel( modName , false, false ); pWeaponModel->GetRoot()->SetVisible(false); pWeaponModel->GetRoot()->SetUseOcclusionCulling(false); //pWeaponModel->GetRoot()->SetScale(0.25); pSoldierWeapon->SetModelData( pWeaponModel ); pSoldierWeapon->SetShootingNode( (Node*)pWeaponModel->mTransforms.GetArray( shootingNodeID ) ); /* Remarked due to DC1 weapon ... static char uiImageName[128]={0}; sprintf(uiImageName, "BLK_%s.pvr",name); PVRTexture * pUITexture = resaourceLoader.LoadTexture( uiImageName , true); pSoldierWeapon->SetUITexture ( pUITexture ); */ mWeaponsMap.Add(name, pSoldierWeapon); mWeaponsName[mWeaponCount] = name; mWeaponCount++; }
void ClassGraph::addNode(const ModelData &model, char const * const className, ClassGraph::eAddNodeTypes addType, int nodeDepth, bool reposition) { const ModelType *type = model.getTypeRef(className); const ModelClassifier *classifier = type->getClass(); if(classifier) { if(mNodes.size() == 0 && mGraphOptions.drawRelationKey) { addRelationKeyNode(); } size_t startSize = mNodes.size(); getRelatedNodesRecurse(model, classifier, addType, nodeDepth, mNodes); if(startSize != mNodes.size()) { mModified = true; } updateGraph(model, reposition); } }
void Contexts::updateOperationList(const ModelData &modelData, OovStringRef const className) { mOperationList.clear(); const ModelClassifier *cls = modelData.getTypeRef(className)->getClass(); if(cls) { for(size_t i=0; i<cls->getOperations().size(); i++) { const ModelOperation *oper = cls->getOperations()[i].get(); std::string opStr = oper->getName(); if(oper->isConst()) { opStr += ' '; opStr += "const"; } mOperationList.appendText(opStr); } mOperationList.sort(); } }
int OpenTxEepromInterface::getSize(ModelData &model) { if (IS_SKY9X(board)) return 0; if (model.isempty()) return 0; // TODO something better uint8_t tmp[EESIZE_RLC_MAX]; efile->EeFsCreate(tmp, EESIZE_RLC_MAX, board); OpenTxModelData open9xModel(model, board, 255, GetCurrentFirmware()->getVariantNumber()); QByteArray eeprom; open9xModel.Export(eeprom); int sz = efile->writeRlc2(0, FILE_TYP_MODEL, (const uint8_t*)eeprom.constData(), eeprom.size()); if (sz != eeprom.size()) { return -1; } return efile->size(0); }
Scheduler::Scheduler( ModelData& md ): data(md.GetData()) { methodsSet.resize(data.GetWFCount()); maxEff = 0.0; xmlWriter = unique_ptr<ScheduleToXML>(new ScheduleToXML(data)); data.SetWfPriorities(); eff = unique_ptr<Efficiency>(new Efficiency(2.00 / data.GetprocessorsCount(), data.GetT())); maxPossible = 0.0; for (int i = 0; i < data.GetResourceCount(); i++){ Intervals initIntervals; data.Resources(i).GetCurrentWindows(initIntervals); vector <BusyIntervals> current; current = initIntervals.GetCurrentIntervals(); for (int j = 0; j < current.size(); j++){ BusyIntervals & processorIntervals = current[j]; for (auto it = processorIntervals.begin(); it != processorIntervals.end(); it++){ for (int k = 0; k < it->second.size(); k++){ maxPossible += eff->EfficiencyByPeriod(1, it->second[k].first, it->second[k].second); } } } } maxPossible = 1.00 - maxPossible; }
Channels::Channels(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, FirmwareInterface * firmware): ModelPanel(parent, model, generalSettings, firmware) { QGridLayout * gridLayout = new QGridLayout(this); bool minimize = false; int col = 1; if (firmware->getCapability(ChannelsName)) { minimize=true; addLabel(gridLayout, tr("Name"), col++); } addLabel(gridLayout, tr("Subtrim"), col++, minimize); addLabel(gridLayout, tr("Min"), col++, minimize); addLabel(gridLayout, tr("Max"), col++, minimize); addLabel(gridLayout, tr("Direction"), col++, minimize); if (IS_TARANIS(GetEepromInterface()->getBoard())) addLabel(gridLayout, tr("Curve"), col++, minimize); if (firmware->getCapability(PPMCenter)) addLabel(gridLayout, tr("PPM Center"), col++, minimize); if (firmware->getCapability(SYMLimits)) addLabel(gridLayout, tr("Linear Subtrim"), col++, true); for (int i=0; i<firmware->getCapability(Outputs); i++) { col = 0; // Channel label QLabel *label = new QLabel(this); label->setText(tr("Channel %1").arg(i+1)); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); gridLayout->addWidget(label, i+1, col++, 1, 1); // Channel name int nameLen = firmware->getCapability(ChannelsName); if (nameLen > 0) { QLineEdit * name = new QLineEdit(this); name->setProperty("index", i); name->setMaxLength(nameLen); QRegExp rx(CHAR_FOR_NAMES_REGEX); name->setValidator(new QRegExpValidator(rx, this)); name->setText(model.limitData[i].name); connect(name, SIGNAL(editingFinished()), this, SLOT(nameEdited())); gridLayout->addWidget(name, i+1, col++, 1, 1); } // Channel offset limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].offset, -1000, 1000, 0); // Channel min limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].min, -model.getChannelsMax()*10, 0, -1000); // Channel max limitsGroups << new LimitsGroup(firmware, gridLayout, i+1, col++, model.limitData[i].max, 0, model.getChannelsMax()*10, 1000); // Channel inversion QComboBox * invCB = new QComboBox(this); invCB->insertItems(0, QStringList() << tr("---") << tr("INV")); invCB->setProperty("index", i); invCB->setCurrentIndex((model.limitData[i].revert) ? 1 : 0); connect(invCB, SIGNAL(currentIndexChanged(int)), this, SLOT(invEdited())); gridLayout->addWidget(invCB, i+1, col++, 1, 1); // Curve if (IS_TARANIS(GetEepromInterface()->getBoard())) { QComboBox * curveCB = new QComboBox(this); curveCB->setProperty("index", i); int numcurves = firmware->getCapability(NumCurves); for (int j=-numcurves; j<=numcurves; j++) { curveCB->addItem(CurveReference(CurveReference::CURVE_REF_CUSTOM, j).toString(), j); } curveCB->setCurrentIndex(model.limitData[i].curve.value+numcurves); connect(curveCB, SIGNAL(currentIndexChanged(int)), this, SLOT(curveEdited())); gridLayout->addWidget(curveCB, i+1, col++, 1, 1); } // PPM center if (firmware->getCapability(PPMCenter)) { QSpinBox * center = new QSpinBox(this); center->setProperty("index", i); center->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); center->setSuffix("us"); center->setMinimum(1375); center->setMaximum(1625); center->setValue(1500); center->setValue(model.limitData[i].ppmCenter + 1500); connect(center, SIGNAL(editingFinished()), this, SLOT(ppmcenterEdited())); gridLayout->addWidget(center, i+1, col++, 1, 1); } // Symetrical limits if (firmware->getCapability(SYMLimits)) { QCheckBox * symlimits = new QCheckBox(this); symlimits->setProperty("index", i); symlimits->setChecked(model.limitData[i].symetrical); connect(symlimits, SIGNAL(toggled(bool)), this, SLOT(symlimitsEdited())); gridLayout->addWidget(symlimits, i+1, col++, 1, 1); } }
void ClassGraph::getRelatedNodesRecurse(const ModelData &model, const ModelType *type, eAddNodeTypes addType, int maxDepth, std::vector<ClassNode> &nodes) { mBackgroundTaskLevel++; -- maxDepth; if(maxDepth >= 0 && type /* && type->getObjectType() == otClass*/) { const ModelClassifier *classifier = type->getClass(); if(classifier) { addNodeToVector(ClassNode(classifier, getComponentOptions(*type, mGraphOptions)), nodes); if((addType & AN_MemberChildren) > 0) { for(const auto &attr : classifier->getAttributes()) { #if(DEBUG_ADD) DebugAdd("Member", attr->getDeclType()); #endif getRelatedNodesRecurse(model, attr->getDeclType(), addType, maxDepth, nodes); } } if((addType & AN_Superclass) > 0) { for(const auto &assoc : model.mAssociations) { if(assoc->getChild() != nullptr && assoc->getParent() != nullptr) { if(assoc->getChild() == classifier) { #if(DEBUG_ADD) DebugAdd("Super", assoc->getParent()); #endif getRelatedNodesRecurse(model, assoc->getParent(), addType, maxDepth, nodes); } } } } if((addType & AN_Subclass) > 0) { for(const auto &assoc : model.mAssociations) { // Normally the child and parent should not be nullptr. if(assoc->getChild() != nullptr && assoc->getParent() != nullptr) { if(assoc->getParent() == classifier) { #if(DEBUG_ADD) DebugAdd("Subclass", assoc->getChild()); #endif getRelatedNodesRecurse(model, assoc->getChild(), addType, maxDepth, nodes); } } } } if((addType & AN_FuncParamsUsing) > 0) { ConstModelClassifierVector relatedClasses; model.getRelatedFuncInterfaceClasses(*classifier, relatedClasses); for(const auto &cls : relatedClasses) { #if(DEBUG_ADD) DebugAdd("Param Using", cls); #endif getRelatedNodesRecurse(model, cls, addType, maxDepth, nodes); } } if((addType & AN_FuncBodyUsing) > 0) { ConstModelDeclClasses relatedDeclClasses; model.getRelatedBodyVarClasses(*classifier, relatedDeclClasses); for(const auto &rdc : relatedDeclClasses) { #if(DEBUG_ADD) DebugAdd("Body Using", rdc.cl); #endif getRelatedNodesRecurse(model, rdc.getClass(), addType, maxDepth, nodes); } } } if((addType & AN_Templates) > 0) { if(type->isTemplateUseType()) { // Add types pointed to by templates. ConstModelClassifierVector relatedClassifiers; model.getRelatedTypeArgClasses(*type, relatedClassifiers); for(const auto &rc : relatedClassifiers) { #if(DEBUG_ADD) DebugAdd("Templ User", rc); #endif getRelatedNodesRecurse(model, rc, addType, maxDepth, nodes); } addNodeToVector(ClassNode(type, getComponentOptions(*type, mGraphOptions)), nodes); } } int taskId = 0; if(mBackgroundTaskLevel == 1) { taskId = mForegroundTaskStatusListener->startTask("Adding relations.", model.mTypes.size()); } for(size_t i=0; i<model.mTypes.size(); i++) { addRelatedNodesRecurseUserToVector(model, type, model.mTypes[i].get(), addType, maxDepth, nodes); if(mBackgroundTaskLevel == 1) { if(!mForegroundTaskStatusListener->updateProgressIteration( taskId, i, nullptr)) { break; } } } if(mBackgroundTaskLevel == 1) { mForegroundTaskStatusListener->endTask(taskId); } } mBackgroundTaskLevel--; }
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware), selectedSwitch(0) { int channelsMax = model.getChannelsMax(true); QGridLayout * gridLayout = new QGridLayout(this); int col = 1; addLabel(gridLayout, tr("Function"), col++); addLabel(gridLayout, tr("V1"), col++); addLabel(gridLayout, tr("V2"), col++); addLabel(gridLayout, tr("AND Switch"), col++); if (firmware->getCapability(LogicalSwitchesExt)) { addLabel(gridLayout, tr("Duration"), col++); addLabel(gridLayout, tr("Delay"), col++); } lock = true; for (int i=0; i<firmware->getCapability(LogicalSwitches); i++) { // The label QLabel * label = new QLabel(this); label->setProperty("index", i); label->setText(tr("L%1").arg(i+1)); label->setContextMenuPolicy(Qt::CustomContextMenu); label->setMouseTracking(true); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint))); gridLayout->addWidget(label, i+1, 0); // The function csw[i] = new QComboBox(this); csw[i]->setProperty("index", i); connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); gridLayout->addWidget(csw[i], i+1, 1); // V1 cswitchSource1[i] = new QComboBox(this); cswitchSource1[i]->setProperty("index",i); connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int))); gridLayout->addWidget(cswitchSource1[i], i+1, 2); cswitchSource1[i]->setVisible(false); cswitchValue[i] = new QDoubleSpinBox(this); cswitchValue[i]->setMaximum(channelsMax); cswitchValue[i]->setMinimum(-channelsMax); cswitchValue[i]->setAccelerated(true); cswitchValue[i]->setDecimals(0); cswitchValue[i]->setProperty("index", i); connect(cswitchValue[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); gridLayout->addWidget(cswitchValue[i], i+1, 2); cswitchValue[i]->setVisible(false); // V2 QHBoxLayout *v2Layout = new QHBoxLayout(); cswitchSource2[i] = new QComboBox(this); cswitchSource2[i]->setProperty("index", i); connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int))); v2Layout->addWidget(cswitchSource2[i]); cswitchSource2[i]->setVisible(false); cswitchOffset[i] = new QDoubleSpinBox(this); cswitchOffset[i]->setProperty("index",i); cswitchOffset[i]->setMaximum(channelsMax); cswitchOffset[i]->setMinimum(-channelsMax); cswitchOffset[i]->setAccelerated(true); cswitchOffset[i]->setDecimals(0); connect(cswitchOffset[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); cswitchOffset[i]->setVisible(false); v2Layout->addWidget(cswitchOffset[i]); cswitchOffset2[i] = new QDoubleSpinBox(this); cswitchOffset2[i]->setProperty("index",i); cswitchOffset2[i]->setMaximum(channelsMax); cswitchOffset2[i]->setMinimum(-channelsMax); cswitchOffset2[i]->setAccelerated(true); cswitchOffset2[i]->setDecimals(0); connect(cswitchOffset2[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); cswitchOffset2[i]->setVisible(false); v2Layout->addWidget(cswitchOffset2[i]); cswitchTOffset[i] = new QTimeEdit(this); cswitchTOffset[i]->setProperty("index",i); cswitchTOffset[i]->setAccelerated(true); connect(cswitchTOffset[i],SIGNAL(editingFinished()),this,SLOT(edited())); v2Layout->addWidget(cswitchTOffset[i]); cswitchTOffset[i]->setVisible(false); gridLayout->addLayout(v2Layout, i+1, 3); // AND cswitchAnd[i] = new QComboBox(this); cswitchAnd[i]->setProperty("index", i); connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); gridLayout->addWidget(cswitchAnd[i], i+1, 4); if (firmware->getCapability(LogicalSwitchesExt)) { // Duration cswitchDuration[i] = new QDoubleSpinBox(this); cswitchDuration[i]->setProperty("index", i); cswitchDuration[i]->setSingleStep(0.1); cswitchDuration[i]->setMaximum(25); cswitchDuration[i]->setMinimum(0); cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setDecimals(1); connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double))); gridLayout->addWidget(cswitchDuration[i], i+1, 5); // Delay cswitchDelay[i] = new QDoubleSpinBox(this); cswitchDelay[i]->setProperty("index", i); cswitchDelay[i]->setSingleStep(0.1); cswitchDelay[i]->setMaximum(25); cswitchDelay[i]->setMinimum(0); cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setDecimals(1); connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double))); gridLayout->addWidget(cswitchDelay[i], i+1, 6); } }
void DiscreteObject::setModel(ModelData md){ setParameters(md.getB(), md.getA(), md.getK(), md.getNoiseRatio()); }
DiscreteObject::DiscreteObject(ModelData md){ DiscreteObject(md.getB(), md.getA(), md.getK(), md.getNoiseRatio()); }
void ClassGraph::updateConnections(const ModelData &modelData) { mConnectMap.clear(); // Diagram *node1, Diagram *node2 for(size_t ni=0; ni<mNodes.size(); ni++) { const ModelType *type = mNodes[ni].getType(); if(type) { if(mGraphOptions.drawTemplateRelations) { // Go through templates if(type->isTemplateUseType()) { ConstModelClassifierVector relatedClassifiers; modelData.getRelatedTypeArgClasses(*type, relatedClassifiers); for(auto const &cl : relatedClassifiers) { insertConnection(ni, cl, ClassConnectItem(ctTemplateDependency)); } } } const ModelClassifier *classifier = type->getClass(); if(classifier) { // Get attributes of classifier, and get the decl type for(const auto &attr : classifier->getAttributes()) { insertConnection(ni, attr->getDeclType(), ClassConnectItem(ctAggregation, attr->isConst(), attr->isRefer(), attr->getAccess())); } if(mGraphOptions.drawOperParamRelations) { // Get operations parameters of classifier, and get the decl type ConstModelDeclClasses declClasses; modelData.getRelatedFuncParamClasses(*classifier, declClasses); for(const auto &declCl : declClasses) { const ModelDeclarator *decl = declCl.getDecl(); insertConnection(ni, declCl.getClass(), ClassConnectItem(ctFuncParam, decl->isConst(), decl->isRefer(), Visibility())); } } if(mGraphOptions.drawOperBodyVarRelations) { // Get operations parameters of classifier, and get the decl type ConstModelDeclClasses declClasses; modelData.getRelatedBodyVarClasses(*classifier, declClasses); for(const auto &declCl : declClasses) { const ModelDeclarator *decl = declCl.getDecl(); insertConnection(ni, declCl.getClass(), ClassConnectItem(ctFuncVar, decl->isConst(), decl->isRefer(), Visibility())); } } // Go through associations, and get related classes. for(const auto &assoc : modelData.mAssociations) { size_t n1Index = NO_INDEX; size_t n2Index = NO_INDEX; if(assoc->getChild() == classifier) { n1Index = getNodeIndex(assoc->getParent()); n2Index = ni; } else if(assoc->getParent() == classifier) { n1Index = ni; n2Index = getNodeIndex(assoc->getChild()); } if(n1Index != NO_INDEX && n2Index != NO_INDEX) { insertConnection(n1Index, n2Index, ClassConnectItem(ctIneritance, assoc->getAccess())); } } } } } }
ProblemData* InputData ( Problem *problem ) { #ifdef PARALLEL // Get the run suffix to enable viewing with paraview int myPID = 0, numProcs=1, strSize=30; MPI_Comm_rank(MPI_COMM_WORLD, &myPID), MPI_Comm_size(MPI_COMM_WORLD, &numProcs); int numDigits = std::floor(std::log10(numProcs))+1; char *exoSuffix=(char*) alloca(sizeof(char)*strSize), formatStr[] = ".%i.%0\0\0\0\0\0\0\0\0", *nemFolder=(char*) alloca(sizeof(char)*strSize); std::strncpy(exoSuffix,"\0",strSize), std::strncpy(nemFolder,"\0",strSize); std::sprintf(formatStr+6,"%ii",numDigits); std::sprintf(exoSuffix,formatStr,numProcs,myPID); std::sprintf(nemFolder,"./nem-%i/",numProcs); #endif // Local variables ParseInputHelper parseInputHelper = ParseInputHelper(); // Create the ProblemData,MeshData,SolverData, and ModelData ProblemData* pd = problem->GetProblemData(); MeshData* meshData = pd->CreateMeshDataStruct(); SolverData* solverData = pd->CreateSolverDataStruct(); ModelData* modelData = pd->CreateModelDataStruct(); meshData->mMeshFileData = new MeshFileData(); solverData->mTimeSolverData = new TimeSolverData(); solverData->mNonlinearSolverDataList.push_back(new NonlinearSolverData()); solverData->mLinearSolverDataList.push_back(new LinearSolverData()); modelData->mModelFileData = new ModelFileData(); modelData->mStrucModelData = new StrucModelData(); SolutionData* solutionData = new SolutionData(); modelData->mSolutionData.push_back( solutionData ); ///Set Problem and Mesh meshData->SetMeshId ( 1 ); meshData->mMeshFileData->mMeshFileType = MESH_EXODUS; const char* InputMeshName = "beam2D.g"; #ifdef PARALLEL std::sprintf(meshData->mMeshFileData->mMeshFileBase, "%s%s" , nemFolder, InputMeshName ); std::sprintf(meshData->mMeshFileData->mMeshFile , "%s%s%s", nemFolder, InputMeshName, exoSuffix ); #else std::sprintf(meshData->mMeshFileData->mMeshFileBase, "%s", InputMeshName ); std::sprintf(meshData->mMeshFileData->mMeshFile , "%s", InputMeshName ); #endif /// Time Integration options solverData->SetSolverId ( 1 ); solverData->mTimeSolverData->mType = TIME_SOLVER_FEMDOC_BDF; solverData->mTimeSolverData->mBdfOrder = 2; solverData->mTimeSolverData->mTime = 0.0; solverData->mTimeSolverData->mTimeIts = sNumIts; solverData->mTimeSolverData->mTimeItList[0] = solverData->mTimeSolverData->mTimeIts; solverData->mTimeSolverData->mDt = sTimeStep; solverData->mTimeSolverData->mDtList[0] = solverData->mTimeSolverData->mDt; // solverData->mTimeSolverData->mMaxTime = solverData->mTimeSolverData->mTimeIts*solverData->mTimeSolverData->mDt; solverData->mTimeSolverData->mBeta = 0.25; // Newmark Alpha solverData->mTimeSolverData->mGamma = 0.5; // Newmark Delta solverData->mTimeSolverData->mAlphaF = 0.0; solverData->mTimeSolverData->mAlphaM = 0.0; solverData->mTimeSolverData->mTotResNorm = 1.0e-12; solverData->mTimeSolverData->mTotResNormDrop = 1.0e-12; solverData->mTimeSolverData->mNondimDivisor = 1.0; solverData->mTimeSolverData->mJacCheck = false; solverData->mTimeSolverData->mNaNCheck = false; solverData->mTimeSolverData->mReinitByStandaloneFile = true; const char* tempPath = "tempDir/"; solverData->mTimeSolverData->mSolVecDir = new char[200]; strcpy(solverData->mTimeSolverData->mSolVecDir,tempPath); /// Newton solver and linear solver options solverData->mNonlinearSolverDataList[0]->mType = NONLINEAR_SOLVER_FEMDOC_NEWTON; solverData->mNonlinearSolverDataList[0]->mMaxItsList[0] = 10; solverData->mNonlinearSolverDataList[0]->mRelaxation = 1.0; solverData->mNonlinearSolverDataList[0]->mRlxList[0] = solverData->mNonlinearSolverDataList[0]->mRelaxation; solverData->mNonlinearSolverDataList[0]->mTotResNormDrop = 1.0e-3; solverData->mNonlinearSolverDataList[0]->mTotResNorm = 1.0e-20; /// Linear solver options solverData->mLinearSolverDataList[0]->mSparseMatrixType = SPARSE_MATRIX_TRILINOS_EPETRA_FECRS; // solverData->mLinearSolverDataList[0]->mType = LINSOL_TRILINOS_AMESOS; //#ifdef PARALLEL // solverData->mLinearSolverDataList[0]->mMethod = LINSOL_AMESOS_MUMPS; //#else // solverData->mLinearSolverDataList[0]->mMethod = LINSOL_AMESOS_UMFPACK; //#endif // solverData->mLinearSolverDataList[0]->mExport = LINSOL_EXPORT_MATLAB; solverData->mLinearSolverDataList[0]->mType = LINSOL_TRILINOS_AZTEC; solverData->mLinearSolverDataList[0]->mMethod = LINSOL_AZTEC_GMRES; solverData->mLinearSolverDataList[0]->mPreconditioner = LINSOL_PREC_AZTEC_DD_ILUT; solverData->mLinearSolverDataList[0]->mKrylovSpace = 500; solverData->mLinearSolverDataList[0]->mMaxIts = 3000; solverData->mLinearSolverDataList[0]->mDropTol = 1.0e-09; solverData->mLinearSolverDataList[0]->mGraphFill = 1; solverData->mLinearSolverDataList[0]->mIlutFill = 7.0; solverData->mLinearSolverDataList[0]->mPolyOrder = 3; solverData->mLinearSolverDataList[0]->mAlphaThresh = 0.0; solverData->mLinearSolverDataList[0]->mRhoThresh = 0.0; solverData->mLinearSolverDataList[0]->mEpsilon = 1.0e-09; solverData->mLinearSolverDataList[0]->mOverlap = 1; solverData->mLinearSolverDataList[0]->mReorder = 1; solverData->mLinearSolverDataList[0]->mHardBreak = false; solverData->mLinearSolverDataList[0]->mOutput = LINSOL_OUTPUT_ALL; /// Model Data modelData->SetModelId( 1 ); modelData->mMeshId = 1; modelData->mSolverId = 1; modelData->mModelFileData->mModelFileType = MODEL_FEMDOC; modelData->mStrucModelData->mRedDimType = PLANE_STRAIN; // strcpy(modelData->mModelFileData->mIniLevelSetFile,"./IniLSStrucBeam.so"); modelData->mXFemCurvatureSearchRadius = sCurvatureSearchRadius; modelData->mXFemCurvatureSpringStiff = sCurvatureSpringStiff; modelData->mdScalar_ds_byAdv = false; /// Solution writing format solutionData->mSolnFormatType = SF_EXODUS; const char* OutputMeshBase = "beam2D.e-s"; solutionData->mSaveIC = sSaveIC; solutionData->mOptSaveFreq = 1; solutionData->mSaveOpt = true; solutionData->mIsXFem = (sXfemBlockElemType!=NON_XFEM_ELEMENT); strcpy(solutionData->mSolnFileBase,OutputMeshBase); strcpy(solutionData->mSolnFileName,OutputMeshBase); #ifdef PARALLEL std::sprintf(solutionData->mSolnFileBase, "%s%s", nemFolder, OutputMeshBase ); std::sprintf(solutionData->mSolnFileName, "%s%s", nemFolder, OutputMeshBase ); #else std::sprintf(solutionData->mSolnFileBase, "%s", OutputMeshBase ); std::sprintf(solutionData->mSolnFileName, "%s", OutputMeshBase ); #endif /// Post Processing Output Variables parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_UX , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_UY , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_UX_XFEM , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_UY_XFEM , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_NP_LEVELSET , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_STRUC_SXX , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_STRUC_SYY , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_STRUC_SZZ , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_STRUC_SXY , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_STRUC_SHY , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables (solutionData, SOL_STRUC_SVM , ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables( solutionData, SOL_OBJ_SENS, ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables( solutionData, SOL_CONST_1_SENS, ELEM_VAR, 1, sBSetIds ); parseInputHelper.CreateNodalOutputVariables( solutionData, SOL_INTERFACE_CURVATURE_BEAM_LAGRANGE, ELEM_VAR, 1, sBSetIds ); // for (UInt ie = 0; ie <(sNumDofsPerNodeMax*MAX_NUM_ENRICHMENTS); ++ie) // for (UInt ie = 0; ie <(sNumDofsPerNodeMax*MAX_NUM_ENRICHMENTS_2D); ++ie) // NOTE:: Only use if code was compiled with the hack MAX_NUM_ENRICHMENTS=MAX_NUM_ENRICHMENTS_2D // parseInputHelper.CreateNodalOutputVariables (solutionData, (SolVarType) (SOL_XFEM000+ie), ELEM_VAR, 1, sBSetIds); parseInputHelper.CreateBlockSetOutputVariables(solutionData, SOL_EP_MAIN_PHASE , 1, sBSetIds ); parseInputHelper.CreateBlockSetOutputVariables(solutionData, SOL_STRUC_STEN , 1, sBSetIds ); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_VOLUME_PHASE_1, ELEM_VAR, 1, sBSetIds , 0, NULL); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_VOLUME_PHASE_2, ELEM_VAR, 1, sBSetIds , 0, NULL); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_STRAIN_ENERGY, ELEM_VAR, 1, sBSetIds , 0, NULL); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_PERIMETER, ELEM_VAR, 1, sBSetIds , 0, NULL); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_CURVATURE_TYPE, ELEM_VAR, 1, sBSetIds , 0, NULL); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_UX, ELEM_VAR, 1, sBSetIds , 1, (sNSetIds+sLoadNSSetIndx)); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_UY, ELEM_VAR, 1, sBSetIds , 1, (sNSetIds+sLoadNSSetIndx)); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_UX_SQ, ELEM_VAR, 1, sBSetIds , 1, (sNSetIds+sLoadNSSetIndx)); parseInputHelper.CreateGlobalOutputVariables (solutionData, GSOL_UY_SQ, ELEM_VAR, 1, sBSetIds , 1, (sNSetIds+sLoadNSSetIndx)); return pd; }
LogicalSwitchesPanel::LogicalSwitchesPanel(QWidget * parent, ModelData & model, GeneralSettings & generalSettings, Firmware * firmware): ModelPanel(parent, model, generalSettings, firmware), selectedSwitch(0) { Stopwatch s1("LogicalSwitchesPanel"); int channelsMax = model.getChannelsMax(true); QStringList headerLabels; headerLabels << "#" << tr("Function") << tr("V1") << tr("V2") << tr("AND Switch"); if (firmware->getCapability(LogicalSwitchesExt)) { headerLabels << tr("Duration") << tr("Delay"); } TableLayout * tableLayout = new TableLayout(this, firmware->getCapability(LogicalSwitches), headerLabels); s1.report("header"); lock = true; for (int i=0; i<firmware->getCapability(LogicalSwitches); i++) { // The label QLabel * label = new QLabel(this); label->setProperty("index", i); label->setText(tr("L%1").arg(i+1)); label->setContextMenuPolicy(Qt::CustomContextMenu); label->setMouseTracking(true); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); connect(label, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(csw_customContextMenuRequested(QPoint))); tableLayout->addWidget(i, 0, label); // The function csw[i] = new QComboBox(this); csw[i]->setProperty("index", i); connect(csw[i], SIGNAL(currentIndexChanged(int)), this, SLOT(edited())); tableLayout->addWidget(i, 1, csw[i]); // V1 QHBoxLayout *v1Layout = new QHBoxLayout(); cswitchSource1[i] = new QComboBox(this); cswitchSource1[i]->setProperty("index",i); connect(cswitchSource1[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v1Edited(int))); v1Layout->addWidget(cswitchSource1[i]); cswitchSource1[i]->setVisible(false); cswitchValue[i] = new QDoubleSpinBox(this); cswitchValue[i]->setMaximum(channelsMax); cswitchValue[i]->setMinimum(-channelsMax); cswitchValue[i]->setAccelerated(true); cswitchValue[i]->setDecimals(0); cswitchValue[i]->setProperty("index", i); connect(cswitchValue[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); v1Layout->addWidget(cswitchValue[i]); cswitchValue[i]->setVisible(false); tableLayout->addLayout(i, 2, v1Layout); // V2 QHBoxLayout *v2Layout = new QHBoxLayout(); cswitchSource2[i] = new QComboBox(this); cswitchSource2[i]->setProperty("index", i); connect(cswitchSource2[i], SIGNAL(currentIndexChanged(int)), this, SLOT(v2Edited(int))); v2Layout->addWidget(cswitchSource2[i]); cswitchSource2[i]->setVisible(false); cswitchOffset[i] = new QDoubleSpinBox(this); cswitchOffset[i]->setProperty("index",i); cswitchOffset[i]->setMaximum(channelsMax); cswitchOffset[i]->setMinimum(-channelsMax); cswitchOffset[i]->setAccelerated(true); cswitchOffset[i]->setDecimals(0); connect(cswitchOffset[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); cswitchOffset[i]->setVisible(false); v2Layout->addWidget(cswitchOffset[i]); cswitchOffset2[i] = new QDoubleSpinBox(this); cswitchOffset2[i]->setProperty("index",i); cswitchOffset2[i]->setMaximum(channelsMax); cswitchOffset2[i]->setMinimum(-channelsMax); cswitchOffset2[i]->setAccelerated(true); cswitchOffset2[i]->setDecimals(0); connect(cswitchOffset2[i], SIGNAL(valueChanged(double)), this, SLOT(edited())); cswitchOffset2[i]->setVisible(false); v2Layout->addWidget(cswitchOffset2[i]); cswitchTOffset[i] = new QTimeEdit(this); cswitchTOffset[i]->setProperty("index",i); cswitchTOffset[i]->setAccelerated(true); connect(cswitchTOffset[i],SIGNAL(editingFinished()),this,SLOT(edited())); v2Layout->addWidget(cswitchTOffset[i]); cswitchTOffset[i]->setVisible(false); tableLayout->addLayout(i, 3, v2Layout); // AND cswitchAnd[i] = new QComboBox(this); cswitchAnd[i]->setProperty("index", i); connect(cswitchAnd[i], SIGNAL(currentIndexChanged(int)), this, SLOT(andEdited(int))); tableLayout->addWidget(i, 4, cswitchAnd[i]); if (firmware->getCapability(LogicalSwitchesExt)) { // Duration cswitchDuration[i] = new QDoubleSpinBox(this); cswitchDuration[i]->setProperty("index", i); cswitchDuration[i]->setSingleStep(0.1); cswitchDuration[i]->setMaximum(25); cswitchDuration[i]->setMinimum(0); cswitchDuration[i]->setAccelerated(true); cswitchDuration[i]->setDecimals(1); connect(cswitchDuration[i], SIGNAL(valueChanged(double)), this, SLOT(durationEdited(double))); tableLayout->addWidget(i, 5, cswitchDuration[i]); // Delay cswitchDelay[i] = new QDoubleSpinBox(this); cswitchDelay[i]->setProperty("index", i); cswitchDelay[i]->setSingleStep(0.1); cswitchDelay[i]->setMaximum(25); cswitchDelay[i]->setMinimum(0); cswitchDelay[i]->setAccelerated(true); cswitchDelay[i]->setDecimals(1); connect(cswitchDelay[i], SIGNAL(valueChanged(double)), this, SLOT(delayEdited(double))); tableLayout->addWidget(i, 6, cswitchDelay[i]); } }
void Villager::loadResources() { ModelData data = ShaderUtil::loadModel("villager"); verticesVBO = data.getVerticesVBO(); normalsVBO = data.getNormalsVBO(); boneWeightsVBO = data.getBoneWeightsVBO(); boneIndicesVBO = data.getBoneIndicesVBO(); vertCount = data.getVertCount(); baseSkeleton = data.getSkeleton(); std::vector<GLenum> shadersUsed {GL_VERTEX_SHADER, GL_FRAGMENT_SHADER}; shaderProgram = ShaderUtil::createProgram("Villager", shadersUsed, true); sMVPHandle = glGetUniformLocation(shaderProgram, "uMVP"); sSunHandle = glGetUniformLocation(shaderProgram, "uSunDirection"); sNormalMatrixHandle = glGetUniformLocation(shaderProgram, "uNormalMatrix"); sBoneWeightsHandle = glGetAttribLocation(shaderProgram, "iBoneWeights"); sBoneIndicesHandle = glGetAttribLocation(shaderProgram, "iBoneIndices"); sPositionHandle = glGetAttribLocation(shaderProgram, "iPosition"); sNormalHandle = glGetAttribLocation(shaderProgram, "iNormal"); sBoneMatricesHandle = glGetUniformLocation(shaderProgram, "uBoneMatrices"); glGenVertexArrays(1, &VAO); glBindVertexArray(VAO); glUseProgram(shaderProgram); //------------------------------------------------------------------------------ // Load Vertex Data //------------------------------------------------------------------------------ glBindBuffer(GL_ARRAY_BUFFER, verticesVBO); glEnableVertexAttribArray(sPositionHandle); glVertexAttribPointer(sPositionHandle, 3, GL_FLOAT, GL_FALSE, 0, NULL); //------------------------------------------------------------------------------ // Load Normal Data //------------------------------------------------------------------------------ glBindBuffer(GL_ARRAY_BUFFER, normalsVBO); glEnableVertexAttribArray(sNormalHandle); glVertexAttribPointer(sNormalHandle, 3, GL_FLOAT, GL_FALSE, 0, NULL); //------------------------------------------------------------------------------ // Load Bone Weight Data //------------------------------------------------------------------------------ glBindBuffer(GL_ARRAY_BUFFER, boneWeightsVBO); glEnableVertexAttribArray(sBoneWeightsHandle); glVertexAttribPointer(sBoneWeightsHandle, 3, GL_FLOAT, GL_FALSE, 0, NULL); //------------------------------------------------------------------------------ // Load Bone Indices Data //------------------------------------------------------------------------------ glBindBuffer(GL_ARRAY_BUFFER, boneIndicesVBO); glEnableVertexAttribArray(sBoneIndicesHandle); glVertexAttribPointer(sBoneIndicesHandle, 3, GL_FLOAT, GL_FALSE, 0, NULL); glUseProgram(0); glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); }