void FilterRequest::Execute() { if (!hasDispatched) { result=timeOutCode; setDataSource(DataSource(getDatabase()->getCurrentSource(), getDatabase()->getNetworkId(), getDatabase()->getTransportStreamId())); Detach(); } }
bool FilterRequest::checkFinish() { if (finished) { result=ResultCodeSuccess; setDataSource(DataSource(getDatabase()->getCurrentSource(), getDatabase()->getNetworkId(), getDatabase()->getTransportStreamId())); Detach(); return true; } return false; }
bool FilterRequest::CancelRequest() { if (!hasDispatched) { result=ResultCodeRequestCancelled; setDataSource(DataSource(getDatabase()->getCurrentSource(), getDatabase()->getNetworkId(), getDatabase()->getTransportStreamId())); Detach(); return true; } return false; }
void SpacesInteriorPartitionsGridController::addColumns(const QString &category, std::vector<QString> & fields) { // always show name and selected columns fields.insert(fields.begin(), { NAME, SELECTED }); m_baseConcepts.clear(); for (const auto &field : fields) { if (field == NAME) { addNameLineEditColumn(Heading(QString(NAME), false, false), false, false, CastNullAdapter<model::Space>(&model::Space::name), CastNullAdapter<model::Space>(&model::Space::setName) ); } else { std::function<std::vector<model::ModelObject>(const model::Space &)> allInteriorPartitionSurfaceGroups( [](const model::Space &t_space) { std::vector<model::ModelObject> allModelObjects; auto interiorPartitionSurfaceGroups = t_space.interiorPartitionSurfaceGroups(); allModelObjects.insert(allModelObjects.end(), interiorPartitionSurfaceGroups.begin(), interiorPartitionSurfaceGroups.end()); return allModelObjects; } ); std::function<std::vector<model::ModelObject>(const model::Space &)> allInteriorPartitionSurfaces( [allInteriorPartitionSurfaceGroups](const model::Space &t_space) { std::vector<model::ModelObject> allModelObjects; for (auto interiorPartitionSurfaceGroup : allInteriorPartitionSurfaceGroups(t_space)) { auto interiorPartitionSurfaces = interiorPartitionSurfaceGroup.cast<model::InteriorPartitionSurfaceGroup>().interiorPartitionSurfaces(); for (auto interiorPartitionSurface : interiorPartitionSurfaces) { allModelObjects.push_back(interiorPartitionSurface); } } return allModelObjects; } ); std::function<std::vector<boost::optional<model::ModelObject> >(const model::Space &)> allInteriorPartitionSurfaceInteriorPartitionSurfaceGroups( [allInteriorPartitionSurfaceGroups](const model::Space &t_space) { std::vector<boost::optional<model::ModelObject> > allModelObjects; for (auto interiorPartitionSurfaceGroup : allInteriorPartitionSurfaceGroups(t_space)) { auto interiorPartitionSurfaces = interiorPartitionSurfaceGroup.cast<model::InteriorPartitionSurfaceGroup>().interiorPartitionSurfaces(); for (auto interiorPartitionSurface : interiorPartitionSurfaces) { auto group = interiorPartitionSurface.interiorPartitionSurfaceGroup(); if (group) { allModelObjects.push_back(*group); } else { allModelObjects.emplace_back(); } } } return allModelObjects; } ); if (field == SELECTED) { auto checkbox = QSharedPointer<QCheckBox>(new QCheckBox()); checkbox->setToolTip("Check to select all rows"); connect(checkbox.data(), &QCheckBox::stateChanged, this, &SpacesInteriorPartitionsGridController::selectAllStateChanged); connect(checkbox.data(), &QCheckBox::stateChanged, this->gridView(), &OSGridView::gridRowSelectionChanged); addSelectColumn(Heading(QString(SELECTED), false, false, checkbox), "Check to select this row", DataSource( allInteriorPartitionSurfaces, true ) ); } else if (field == INTERIORPARTITIONGROUPNAME) { addNameLineEditColumn(Heading(QString(INTERIORPARTITIONGROUPNAME), true, false), false, false, CastNullAdapter<model::InteriorPartitionSurfaceGroup>(&model::InteriorPartitionSurfaceGroup::name), CastNullAdapter<model::InteriorPartitionSurfaceGroup>(&model::InteriorPartitionSurfaceGroup::setName), boost::optional<std::function<void(model::InteriorPartitionSurfaceGroup *)>>(), DataSource( allInteriorPartitionSurfaceInteriorPartitionSurfaceGroups, true) ); } else if (field == INTERIORPARTITIONNAME) { addNameLineEditColumn(Heading(QString(INTERIORPARTITIONNAME), true, false), false, false, CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::name), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::setName), boost::optional<std::function<void(model::InteriorPartitionSurface *)>>(), DataSource( allInteriorPartitionSurfaces, true) ); } else if (field == CONSTRUCTIONNAME) { m_constructionColumn = 4; addDropZoneColumn(Heading(QString(CONSTRUCTIONNAME), true, false), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::construction), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::setConstruction), boost::optional<std::function<void(model::InteriorPartitionSurface*)> >(NullAdapter(&model::InteriorPartitionSurface::resetConstruction)), boost::optional<std::function<bool(model::InteriorPartitionSurface*)> >(NullAdapter(&model::InteriorPartitionSurface::isConstructionDefaulted)), DataSource( allInteriorPartitionSurfaces, true ) ); } else if (field == CONVERTTOINTERNALMASS) { addCheckBoxColumn(Heading(QString(CONVERTTOINTERNALMASS), true, false), std::string("Check to enable convert to InternalMass."), NullAdapter(&model::InteriorPartitionSurface::converttoInternalMass), NullAdapter(&model::InteriorPartitionSurface::setConverttoInternalMass), DataSource( allInteriorPartitionSurfaces, true ) ); } else if (field == SURFACEAREA) { std::function<bool(model::InteriorPartitionSurface *, double)> setter( [](model::InteriorPartitionSurface *t_interiorPartitionSurface, double t_arg) { return t_interiorPartitionSurface->setSurfaceArea(t_arg); } ); addValueEditColumn(Heading(QString(SURFACEAREA)), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::surfaceArea), setter//, //boost::optional<std::function<void(model::ModelObject *)>>(), //boost::optional<std::function<bool(model::ModelObject *)>>()//, //DataSource( //allInteriorPartitionSurfaces, //true //) ); //boost::optional<double> surfaceArea() const; // TODO this optional is causing troubles //bool setSurfaceArea(boost::optional<double> surfaceArea); //bool setSurfaceArea(double surfaceArea); //void resetSurfaceArea(); } else if (field == DAYLIGHTINGSHELFNAME) { //boost::optional<DaylightingDeviceShelf> daylightingDeviceShelf() const; } else { // unhandled OS_ASSERT(false); } } } }
/* public */ MMSSwitcher::MMSSwitcher(MMSPluginData *plugindata) : osdhandler(NULL), centralhandler(NULL) { /* switcher instantiated by plugin */ if(plugindata) { /* get access to the plugin handler */ this->plugindata = plugindata; if (this->plugindata->getType()->getName()=="OSD_PLUGIN") { this->osdhandler = this->pluginmanager->getOSDPluginHandler(this->plugindata->getId()); this->showPreviewThread = new MMSSwitcherThread(this); } else if (this->plugindata->getType()->getName()=="CENTRAL_PLUGIN") { this->centralhandler = this->pluginmanager->getCentralPluginHandler(this->plugindata->getId()); this->showPreviewThread = new MMSSwitcherThread(this); } plugin_data_t *pd = new plugin_data_t; pd->plugindata = *plugindata; pd->switcher = this; plugins.insert(std::make_pair(plugindata->getId(), pd)); return; } /* switcher start */ DEBUGMSG("MMSSwitcher", "startup"); this->windowmanager = NULL; this->pluginmanager = NULL; this->inputmanager = NULL; this->curr_plugin = -1; this->window = NULL; try { /* get the active osd and central plugins */ DataSource source = DataSource(config.getConfigDBDBMS(), config.getConfigDBDatabase(), config.getConfigDBAddress(), config.getConfigDBPort(), config.getConfigDBUser(), config.getConfigDBPassword()); /* load switcher dialog */ this->window = (MMSMainWindow*)dm.loadDialog(config.getData() + "/themes/" + config.getTheme() + "/switcher.xml"); if(!this->window) throw MMSError(0, "Error loading switchers root window"); /* get access to the menu bar */ this->menuBar = (MMSChildWindow *)this->window->findWindow(SWITCHER_MENUBAR); if(!this->menuBar) throw MMSError(0, "Error loading switchers menuBar childwindow"); this->menu = dynamic_cast<MMSMenuWidget*>(this->menuBar->findWidget(SWITCHER_MENU)); if(!this->menu) throw MMSError(0, "Error loading switchers menu"); /* get access to the static menu bar */ this->menuBar_static = (MMSChildWindow *)this->window->findWindow(SWITCHER_MENUBAR_STATIC); if (this->menuBar_static) this->menu_static = dynamic_cast<MMSMenuWidget*>(this->menuBar_static->findWidget(SWITCHER_MENU_STATIC)); else this->menu_static = NULL; /* fill the menu */ MMSPluginService service(&source); addPluginsToMenu(service.getOSDPlugins()); addPluginsToMenu(service.getCentralPlugins()); /* show the menu bar */ if (this->menuBar_static) { this->menuBar_static->show(); this->menuBar_static->waitUntilShown(); } this->menuBar->show(); /* connect onBeforeScroll callback of the menu widget */ menu->onBeforeScroll->connect(sigc::mem_fun(this,&MMSSwitcher::onBeforeScroll)); /* connect onSelectItem callback of the menu widget */ menu->onSelectItem->connect(sigc::mem_fun(this,&MMSSwitcher::onSelectItem)); /* connect onReturn callback of the menu widget */ menu->onReturn->connect(sigc::mem_fun(this,&MMSSwitcher::onReturn)); /* create inputs */ // subscribeKey(MMSKEY_MENU); // subscribeKey(MMSKEY_BACKSPACE); /* start my update thread */ this->switcherThread = new MMSSwitcherThread(this, NULL, NULL, NULL, NULL); this->switcherThread->start(); } catch(MMSError &error) { DEBUGMSG("Switcher", "Abort due to: " + error.getMessage()); throw error; } }
int main(int argc, char **argv) { //Initialise SDL SDL_Init(SDL_INIT_EVERYTHING); //Setup screen SDL_Surface *screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE); //Load Terrain OpenTerrain_Heightmap MyHeightmap; MyHeightmap.LoadFromImage("heightmap.png"); OpenTerrain_DataSource_Heightmap DataSource(&MyHeightmap); OpenTerrain_Terrain MyTerrain; MyTerrain.SetupValues.ChunkSize = 32; MyTerrain.SetupValues.ChunksX = 8; MyTerrain.SetupValues.ChunksY = 8; MyTerrain.SetupValues.LODLevelCount = 1; MyTerrain.Setup(&DataSource, 0); //Lock Screen LockScreen(screen); //Draw terrain unsigned int ChunkVerticesAccross = MyTerrain.ChunkSize + 1; for(unsigned int Chunk = 0; Chunk < MyTerrain.LODLevels[0].ChunkCount; Chunk++) { //Get chunk OpenTerrain_Chunk* ChunkPtr = &MyTerrain.LODLevels[0].Chunks[Chunk]; //Calculate chunk position on screen unsigned int ChunkX = ChunkPtr->PosX * ChunkVerticesAccross; unsigned int ChunkY = ChunkPtr->PosY * ChunkVerticesAccross; //Loop through vertices for(unsigned int Y = 0; Y < ChunkVerticesAccross; Y++) { for(unsigned int X = 0; X < ChunkVerticesAccross; X++) { //Get luminance and draw pixel unsigned char Luminance = ChunkPtr->Vertices[Y * ChunkVerticesAccross + X] * 255; DrawPixel(screen, ChunkX + X, ChunkY + Y, Luminance, Luminance, Luminance); } } } //Unlock screen and update UnlockScreen(screen); SDL_UpdateRect(screen, 0, 0, 256, 256); //Event loop SDL_Event event; while(true) { while ( SDL_PollEvent(&event) ) { switch (event.type) { case SDL_QUIT: exit(0); break; } } } //Return 0 return 0; }
void FacilityShadingGridController::addColumns(const QString &category, std::vector<QString> & fields) { // always show name and selected columns // show type next to name, since it comes from the groups fields.insert(fields.begin(), { NAME, TYPE, SELECTED }); m_baseConcepts.clear(); for (const auto &field : fields) { if (field == NAME) { addNameLineEditColumn(Heading(QString(NAME), false, false), false, false, CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::name), CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::setName) ); } // Evan note: TODO to correctly use this column we need a new control -- // a dropzone for spaces, and a combo box with site and building as choices else if (field == TYPE) { std::function<std::vector<std::string>()> choices( []() { std::vector<std::string> choices{ "Site", "Building", "Space" }; return choices; } ); addComboBoxColumn(Heading(QString(TYPE)), std::function<std::string(const std::string &)>(static_cast<std::string(*)(const std::string&)>(&openstudio::toString)), choices, CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::shadingSurfaceType), CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::setShadingSurfaceType), boost::optional<std::function<void(model::ShadingSurfaceGroup*)>>(), boost::optional<std::function<bool(model::ShadingSurfaceGroup*)>>() ); } else { std::function<std::vector<model::ModelObject>(const model::ShadingSurfaceGroup &)> allShadingSurfaces( [](const model::ShadingSurfaceGroup &t_shadingSurfaceGroup) { std::vector<model::ModelObject> allModelObjects; auto shadingSurfaces = t_shadingSurfaceGroup.shadingSurfaces(); allModelObjects.insert(allModelObjects.end(), shadingSurfaces.begin(), shadingSurfaces.end()); return allModelObjects; } ); if (field == SELECTED) { auto checkbox = QSharedPointer<QCheckBox>(new QCheckBox()); checkbox->setToolTip("Check to select all rows"); connect(checkbox.data(), &QCheckBox::stateChanged, this, &FacilityShadingGridController::selectAllStateChanged); connect(checkbox.data(), &QCheckBox::stateChanged, this->gridView(), &OSGridView::gridRowSelectionChanged); addSelectColumn(Heading(QString(SELECTED), false, false, checkbox), "Check to select this row", DataSource( allShadingSurfaces, true ) ); } else if (field == SHADINGSURFACENAME) { addLoadNameColumn(Heading(QString(SHADINGSURFACENAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::name), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setName), boost::optional<std::function<void(model::ShadingSurface *)>>( std::function<void(model::ShadingSurface *)>( [](model::ShadingSurface *t_ss) { t_ss->remove(); } ) ), DataSource( allShadingSurfaces, true ) ); } else if (field == CONSTRUCTIONNAME) { addDropZoneColumn(Heading(QString(CONSTRUCTIONNAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::construction), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setConstruction), boost::optional<std::function<void(model::ShadingSurface*)> >(NullAdapter(&model::ShadingSurface::resetConstruction)), boost::optional<std::function<bool(model::ShadingSurface*)> >(NullAdapter(&model::ShadingSurface::isConstructionDefaulted)), DataSource( allShadingSurfaces, true ) ); } else if (field == TRANSMITTANCESCHEDULENAME) { std::function<bool(model::ShadingSurface *, const model::Schedule &)> setter( [](model::ShadingSurface *t_shadingSurface, const model::Schedule &t_schedule) { auto copy = t_schedule; return t_shadingSurface->setTransmittanceSchedule(copy); } ); addDropZoneColumn(Heading(QString(TRANSMITTANCESCHEDULENAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::transmittanceSchedule), setter, boost::optional<std::function<void(model::ShadingSurface*)>>(CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::resetTransmittanceSchedule)), boost::optional<std::function<bool(model::ShadingSurface*)> >(), DataSource( allShadingSurfaces, true ) ); } else { // unhandled OS_ASSERT(false); } } } }