void SceneGraphTreeModel::removeNode(NodeUnrecPtr nodeToBeRemoved) { NodeRefPtr parent = nodeToBeRemoved->getParent(); TreePath pathOfNode = createPath(nodeToBeRemoved); if(parent!=NULL) { UInt32 ChildIndex(parent->findChild(nodeToBeRemoved)); produceTreeNodesWillBeRemoved(pathOfNode.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, nodeToBeRemoved)); parent->subChild(nodeToBeRemoved); produceTreeNodesRemoved(pathOfNode.getParentPath(),std::vector<UInt32>(1, ChildIndex),std::vector<boost::any>(1, nodeToBeRemoved)); if(parent->getNChildren() == 0) { if(parent->getParent() != NULL) { std::vector<UInt32> childIndices; childIndices.push_back(parent->getParent()->findChild(parent)); std::vector<boost::any> ChildUserObjects; for(UInt32 i(0) ; i< childIndices.size() ; ++i) { ChildUserObjects.push_back(boost::any(NodeUnrecPtr(parent->getParent()->getChild(childIndices[i])))); } produceTreeNodesChanged(createPath(parent->getParent()), childIndices, ChildUserObjects); } } } }
void generateKMLForSICD(xml::lite::Element* docXML, six::sicd::ComplexData* data) { std::vector<six::LatLonAlt> v; // Lets go ahead and try to add the ARP poly v.push_back(data->geoData->scp.llh); v.push_back(scene::Utilities::ecefToLatLon(data->scpcoa->arpPos)); docXML->addChild(createPath(v, "arpToSceneCenter", "LineString")); // Time associated with start six::DateTime dateTime = data->timeline->collectStart; size_t durationInSeconds = (size_t) data->timeline->collectDuration; six::Vector3 atTimeX; for (size_t i = 0; i < durationInSeconds; ++i) { atTimeX = data->position->arpPoly(i); v[1] = scene::Utilities::ecefToLatLon(atTimeX); xml::lite::Element* arpPolyXML = createPath(v, "arpPoly", "LineString"); six::DateTime dt(dateTime.getTimeInMillis() + i * 1000); arpPolyXML->addChild(createTimeSnapshot(dt)); docXML->addChild(arpPolyXML); } }
/* MCMC Var-Cov tuning matrix */ st_mcmc_update *initMCMCUpdate(char *dir) { st_mcmc_update *mcmc_update; dir = addInputPath(dir); char *tuning_file = createPath(dir, "tuning.csv"); gsl_matrix *tuning = readMatrix(tuning_file); char *fixed_file = createPath(dir, "fixed.csv"); gsl_vector *fixed = readVector(fixed_file); if(tuning->size1 != tuning->size2 || tuning->size1 != fixed->size) { printf("Error in initMCMCUpdate\n"); exit(GSL_FAILURE); } gsl_vector *z = gsl_vector_alloc(fixed->size); mcmc_update = (st_mcmc_update *) malloc(sizeof(st_mcmc_update)); mcmc_update->tuning = tuning; mcmc_update->fixed=fixed; mcmc_update->z = z; mcmc_update->always_accept = 1; int i; for(i=0; i<fixed->size; i++) mcmc_update->always_accept *= (int) VGET(mcmc_update->fixed, i); return(mcmc_update); }
void createPath(TreeNode *root,int sum,vector<int> path,vector<vector<int> >& res){ path.push_back(root->val); if(!root->left&&!root->right){ if(root->val==sum) res.push_back(path); } else{ if(root->left) createPath(root->left,sum-root->val,path,res); if(root->right) createPath(root->right,sum-root->val,path,res); } }
/* Public initialisations functions */ st_parts_at * initPrior(char* dir) { dir = addInputPath(dir); st_parts_at *prior_parts; char *residual_file= createPath(dir, "residuals.csv"); char *species_prior_file= createPath(dir, "species_prior.csv"); prior_parts = (st_parts_at *) malloc(sizeof(st_part_at)); prior_parts->sps = readMatrix(species_prior_file); prior_parts->res = readMatrix(residual_file); return(prior_parts); }
void TrackSpArcSItem::init() { // Track // // inSpiral_ = trackSpArcS_->getInSpiral(); arc_ = trackSpArcS_->getArc(); outSpiral_ = trackSpArcS_->getOutSpiral(); // Selection/Highlighting // // //setAcceptHoverEvents(true); //setFlag(QGraphicsItem::ItemIsMovable, true); //setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); // Slider // // factorHandle_ = new TrackSparcsHandle(this); updateFactorHandle(); // Color & Path // // //updateColor(); setBrush(QBrush(ODD::instance()->colors()->brightGreen())); setPen(QPen(ODD::instance()->colors()->darkGreen())); createPath(); }
/* * Update position */ void OSCItem::updatePosition() { path_ = createPath(selectedObject_); path_->translate(pos_ ); setPath(*path_); }
void DiagramDrawItem::setDimension(QPointF newPos) { prepareGeometryChange(); myPos2=newPos; myPolygon=createPath(); setPolygon(myPolygon); }
void DiagramDrawItem::setPos2(QPointF newPos) { prepareGeometryChange(); myPos2=mapFromScene(newPos); myPolygon=createPath(); setPolygon(myPolygon); }
// Constructor MainMenuItem::MainMenuItem(QWidget *parent, ITEM_TYPE type):QWidget(parent){ int x, y; // Adjust position and dimention according to the item type switch (type) { case START: this->pos.x = 407; x = 277; this->pos.y = 220; y = 49; break; case INSTRUCTION: this->pos.x = 395; x = 291; this->pos.y = 290; y = 36; break; case QUIT: this->pos.x = 488; x = 103; this->pos.y = 350; y = 37; break; case NEXT: this->pos.x = 965; x = 77; this->pos.y = 440; y = 25; break; case FINISH: this->pos.x = 960; x = 95; this->pos.y = 440; y = 25; break; default: break; } this->selected = false; this->type = type; QString path = createPath(); this->image = new QImage(); this->image->load(path); this->rect.setRect(pos.x, pos.y, x, y); }
void LayoutSVGShape::updateShapeFromElement() { createPath(); m_fillBoundingBox = calculateObjectBoundingBox(); m_strokeBoundingBox = calculateStrokeBoundingBox(); }
void QtResourceViewPrivate::createPaths() { if (!m_resourceModel) return; const QString root(QLatin1Char(':')); QMap<QString, QString> contents = m_resourceModel->contents(); QMapIterator<QString, QString> itContents(contents); while (itContents.hasNext()) { const QString filePath = itContents.next().key(); const QFileInfo fi(filePath); QString dirPath = fi.absolutePath(); m_pathToContents[dirPath].append(fi.fileName()); while (!m_pathToParentPath.contains(dirPath) && dirPath != root) { // create all parent paths const QFileInfo fd(dirPath); const QString parentDirPath = fd.absolutePath(); m_pathToParentPath[dirPath] = parentDirPath; m_pathToSubPaths[parentDirPath].append(dirPath); dirPath = parentDirPath; } } QQueue<QPair<QString, QTreeWidgetItem *> > pathToParentItemQueue; pathToParentItemQueue.enqueue(qMakePair(root, static_cast<QTreeWidgetItem *>(0))); while (!pathToParentItemQueue.isEmpty()) { QPair<QString, QTreeWidgetItem *> pathToParentItem = pathToParentItemQueue.dequeue(); const QString path = pathToParentItem.first; QTreeWidgetItem *item = createPath(path, pathToParentItem.second); QStringList subPaths = m_pathToSubPaths.value(path); QStringListIterator itSubPaths(subPaths); while (itSubPaths.hasNext()) pathToParentItemQueue.enqueue(qMakePair(itSubPaths.next(), item)); } }
int MissionWidget::checkStatus(void){ if(!sendAction->isConnected()){ statusErrorBox->setVisible(true); lblError->setText("Robot Offline"); return ERROR_ROBOT; } QProcess procRun; procRun.start(createPath("checkCam.sh")); procRun.waitForFinished( ); QString output( procRun.readAllStandardOutput()); procRun.close(); qDebug()<< "Camera check "+output; if(!output.compare("live\n")) return STATUS_OK; else{ statusErrorBox->setVisible(true); lblError->setText("Camera Offline"); return ERROR_CAMERA; } }
void MainWindow::start_game(QString music_name) { cur_scene = game; sound_menu->stop(); Phonon::MediaObject *sound_start = new Phonon::MediaObject(this); createPath(sound_start, new Phonon::AudioOutput(Phonon::MusicCategory, this)); sound_start->setCurrentSource(Phonon::MediaSource(":/sound/start.mp3")); sound_start->play(); QDir dir_music(QDir::home().absoluteFilePath(QString(".musicman/songs/%1/").arg(music_name))); music_guitar = new Phonon::MediaObject(this); music_guitar->setCurrentSource(Phonon::MediaSource(dir_music.absoluteFilePath("guitar.mp3"))); music_guitar_output = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(music_guitar, music_guitar_output); music_song = new Phonon::MediaObject(this); music_song->setCurrentSource(Phonon::MediaSource(dir_music.absoluteFilePath("song.mp3"))); music_song_output = new Phonon::AudioOutput(Phonon::MusicCategory, this); Phonon::createPath(music_song, music_song_output); canvas = new Canvas(this); Midi midi(dir_music.absoluteFilePath("notes.musicman").toStdString()); midi.parse(); canvas->setMidi(midi); canvas->setTotalTime(music_song->totalTime()); canvas->resize(this->size()); canvas->show(); connect(timer, SIGNAL(timeout()), SLOT(redraw_canvas())); timer->start(20); }
void Evaluator::createPathWithDate(){ time_t curTime; time(&curTime); string subPath = ctime(&curTime); subPath = subPath.substr(0,10); createPath(subPath.data()); }
void OSCBridgeItem::init() { // Hover Events // // setAcceptHoverEvents(true); // setSelectable(); setFlag(ItemIsFocusable); // Save a tunnel // tunnel_ = dynamic_cast<Tunnel *>(bridge_); if (getTopviewGraph()) // not for profile graph { // Text // // bridgeTextItem_ = new BridgeTextItem(this, bridge_); bridgeTextItem_->setZValue(1.0); // stack before siblings } road_ = bridge_->getParentRoad(); pos_ = road_->getGlobalPoint(bridge_->getSStart()); updateColor(); updatePosition(); createPath(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), cur_scene(main) { ui->setupUi(this); ui->verticalLayout->setAlignment(Qt::AlignCenter); setStyleSheet(QString("QPushButton { font-family: 'Avenir Next'; font-size: 40px; font-weight: bold; }")); timer = new QTimer(this); sound_menu = new Phonon::MediaObject(this); createPath(sound_menu, new Phonon::AudioOutput(Phonon::MusicCategory, this)); sound_menu->setCurrentSource(Phonon::MediaSource(":/sound/menu.mp3")); QObject::connect(sound_menu, SIGNAL(aboutToFinish()), SLOT(menu_sound_finished())); sound_menu->setTransitionTime(-270); sound_menu->play(); musiclist = new QListWidget(this); musiclist->show(); musiclist->setVisible(false); musiclist->setStyleSheet(QString("font-family: 'Avenir Next'; font-size: 40px; font-weight: bold;")); ui->scoreLabel->setVisible(false); ui->nameEdit->setVisible(false); }
std::string generateKML(six::Data* data, const sys::Path& outputDir) { std::string kmlFile = "visualization.kml"; sys::Path kmlPath(outputDir, kmlFile); io::FileOutputStream fos(kmlPath.getPath()); xml::lite::Element* root = new xml::lite::Element("kml", KML_URI); xml::lite::Element* docXML = new xml::lite::Element("Document", KML_URI); root->addChild(docXML); // Add name, and open the document docXML->addChild(new xml::lite::Element("name", KML_URI, data->getName())); docXML->addChild(new xml::lite::Element("open", KML_URI, "1")); // Now add some styles docXML->addChild(createLineStyle("footprint", FOOTPRINT_COLOR, 4)); docXML->addChild(createLineStyle("arpToSceneCenter", "ff0000ff", 2)); docXML->addChild(createLineStyle("arpPoly", "ff00007f", 2)); // Create footprint const six::LatLonCorners corners(data->getImageCorners()); docXML->addChild(createPath(corners, "footprint", "LinearRing")); // Specifics to SICD if (data->getDataType() == six::DataType::COMPLEX) generateKMLForSICD(docXML, (six::sicd::ComplexData*) data); root->prettyPrint(fos); delete root; fos.close(); return kmlPath.getPath(); }
void Settings::merge(const boost::property_tree::ptree& from, boost::property_tree::ptree& to, bool overwrite) { // Is this a single value or a subtree? if (!from.data().empty()) { // Single value if (overwrite || to.data().empty()) { to.put_value(from.data()); } return; } // Subtree for (const auto& fromEntry : from) { // Does the key exist in the destination? auto toIt = to.find(fromEntry.first); if (toIt == to.not_found()) { ptree::ptree child; // Recurse into the new child merge(fromEntry.second, child, overwrite); // Create a path object because ptree uses '.' as a path delimiter // when strings are used ptree::ptree::path_type treePath = createPath(fromEntry.first); to.add_child(treePath, child); } else { // Recurse into the subtrees merge(fromEntry.second, toIt->second, overwrite); } } }
void KWQQuizView::audioPlayFile(const KUrl &soundUrl, bool overwrite) { static KUrl lastUrl; KUrl *url = const_cast<KUrl *>(&soundUrl); if (overwrite) lastUrl = *url; if (url->isEmpty()) { if (lastUrl.isEmpty()) { m_actionCollection->action("quiz_audio_play")->setEnabled(false); return; } url = &lastUrl; } lastUrl = *url; m_actionCollection->action("quiz_audio_play")->setEnabled(true); kDebug() << "Attempting to play sound: " << *url; if (!m_player) { m_player = new Phonon::MediaObject(this); Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::NoCategory, this); createPath(m_player, audioOutput); } else { m_player->stop(); } m_player->setCurrentSource(*url); m_player->play(); }
KNMusicBackendPhononThread::KNMusicBackendPhononThread(QObject *parent) : KNMusicBackendThread(parent) { //Initial the media object and audio output. m_mediaObject=new MediaObject; // m_mediaObject->moveToThread(&m_workingThread); m_mediaObject->setTickInterval(10); m_audioOutput=new AudioOutput(MusicCategory); // m_audioOutput->moveToThread(&m_workingThread); //Initial the state. m_state=KNMusic::StoppedState; //Link the media object and audio output. createPath(m_mediaObject, m_audioOutput); //Link signals. connect(m_mediaObject, &MediaObject::totalTimeChanged, this, &KNMusicBackendPhononThread::onActionDurationChanged); connect(m_mediaObject, &MediaObject::tick, this, &KNMusicBackendPhononThread::onActionPositionChanged); connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), this, SLOT(onActionStateChanged(State,State))); connect(m_mediaObject, SIGNAL(finished()), this, SLOT(onActionFinished())); }
void Box2DRenderer::DrawSolidPolygon (const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { graphics->setColour (getColour (color)); Path p; createPath (p, vertices, vertexCount); graphics->fillPath (p); }
void Box2DRenderer::DrawPolygon (const b2Vec2* vertices, int32 vertexCount, const b2Color& color) { graphics->setColour (getColour (color)); Path p; createPath (p, vertices, vertexCount); graphics->strokePath (p, PathStrokeType (getLineThickness())); }
/* * Update position */ void OSCBridgeItem::updatePosition() { // pos_ = road_->getGlobalPoint(bridge_->getSStart()); updateColor(); createPath(); }
int createEyePath(const RTScene& scene, Rand& rand, int maxVerts, const Ray& initialRay, PathVertex vertices[]) { return createPath(scene, rand, maxVerts, float3(1), initialRay, true, vertices); }
void LayoutSVGShape::updateShapeFromElement() { createPath(); m_fillBoundingBox = calculateObjectBoundingBox(); m_strokeBoundingBox = calculateStrokeBoundingBox(); if (element()) element()->setNeedsResizeObserverUpdate(); }
//see https://en.wikipedia.org/wiki/A*_search_algorithm std::vector<sf::Vector2f> Pathfinder::findPath(const sf::Vector2i& startPos, const sf::Vector2i& goalPos){ if (startPos.x >= 0 && startPos.y >= 0 && goalPos.x >= 0 && goalPos.y >= 0 && startPos.x < m_mapWidth && startPos.y < m_mapHeight && goalPos.x < m_mapWidth && goalPos.y < m_mapHeight) { int size = m_mapWidth * m_mapHeight; int startIndex = startPos.x + (startPos.y * m_mapWidth); int goalIndex = goalPos.x + (goalPos.y * m_mapWidth); Node* start = m_nodes[startIndex]; Node* goal = m_nodes[goalIndex]; if (start != 0 && goal != 0){ //reset nodes for (int i = 0; i < size; i++){ if (m_nodes[i] != 0) m_nodes[i]->reset(); } //pair is fcost,index. storing node pointers causes invalid heap priority_queue<std::pair<int, int>, vector<std::pair<int, int>>, NodeSearchCostComparer> openset; start->setGCost(0); start->setFCost(getHeuristic(start, goal)); start->setOpen(true); openset.push(std::pair<int,int>(start->fCost(), startIndex)); while (openset.size() != 0) { Node* current = m_nodes[openset.top().second]; openset.pop(); if (current == goal) return createPath(startIndex, goalIndex); current->setOpen(false); //remove from open current->setClose(true); //set as closed // if (neighbour != current->getPrevious()){ for (int i = 0; i < 8; i++) { //loop through neighbours int neighbourIndex = getNeighbourIndex(current, i); Node* neighbour = (neighbourIndex == -1) ? 0 : m_nodes[neighbourIndex]; if (neighbour == 0 || neighbour->close() || neighbour == current->getPrevious() || neighbour->walkable() == false) continue; int tenativeGCost = current->gCost() + getCost(m_neighbourOffsets[i]); if (tenativeGCost <= neighbour->gCost()){ neighbour->setPrevious(current); neighbour->setGCost(tenativeGCost); neighbour->setFCost(neighbour->gCost() + getHeuristic(neighbour, goal)); } if (neighbour->open() == false){ //not explored neighbour->setOpen(true); neighbour->setColour(sf::Color(0, 128, 128, 255)); openset.push(std::pair<int,int>(neighbour->fCost(), neighbourIndex)); } } } if (openset.size() == 0) cout << "Couldn't find path." << endl; } } return std::vector<sf::Vector2f>(); }
void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Rectangle: fill=" << m_paint.fill.first << "/" << m_paint.fill.second << " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second); esvg::render::Path listElement = createPath(); mat2 mtx = m_transformMatrix; mtx *= _basicTrans; esvg::render::PointList listPoints; listPoints = listElement.generateListPoints(_level, _myRenderer.getInterpolationRecurtionMax(), _myRenderer.getInterpolationThreshold()); //listPoints.applyMatrix(mtx); esvg::render::SegmentList listSegmentFill; esvg::render::SegmentList listSegmentStroke; esvg::render::Weight tmpFill; esvg::render::Weight tmpStroke; ememory::SharedPtr<esvg::render::DynamicColor> colorFill = esvg::render::createColor(m_paint.fill, mtx); ememory::SharedPtr<esvg::render::DynamicColor> colorStroke; if (m_paint.strokeWidth > 0.0f) { colorStroke = esvg::render::createColor(m_paint.stroke, mtx); } // Check if we need to display background if (colorFill != nullptr) { listSegmentFill.createSegmentList(listPoints); colorFill->setViewPort(listSegmentFill.getViewPort()); listSegmentFill.applyMatrix(mtx); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpFill.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), listSegmentFill); } // check if we need to display stroke: if (colorStroke != nullptr) { listSegmentStroke.createSegmentListStroke(listPoints, m_paint.strokeWidth, m_paint.lineCap, m_paint.lineJoin, m_paint.miterLimit); colorStroke->setViewPort(listSegmentStroke.getViewPort()); listSegmentStroke.applyMatrix(mtx); // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule tmpStroke.generate(_myRenderer.getSize(), _myRenderer.getNumberSubScanLine(), listSegmentStroke); } // add on images: _myRenderer.print(tmpFill, colorFill, tmpStroke, colorStroke, m_paint.opacity); #ifdef DEBUG _myRenderer.addDebugSegment(listSegmentFill); _myRenderer.addDebugSegment(listSegmentStroke); #endif }
void MediumSmartAI::move(){ Character* pChar = currMap->getPlayerChar(); if ((abs(pChar->getXpos() - me->getXpos()) > m_perception || abs(pChar->getYpos() - me->getYpos()) > m_perception) && attacked == false) return; std::string p = createPath(pChar); if (p.length() > 0){ me->setMovement(p[0]); } }
st_data * initData(st_model_at *model_at, char *dir) { dir = addInputPath(dir); int i,j; int line_length = 80; double old_tstep = 0.0; FILE* f; char *pch; char line[line_length]; st_data *current_data, *root_data; char *experiment_file= createPath(dir, "full.csv"); root_data = (st_data *) malloc(sizeof(st_data)); root_data->obser = (double *) malloc(sizeof(double)); root_data->next = NULL; current_data = root_data; f = fopen(experiment_file, "r"); if(NULL == f) { fprintf(stderr, "Cannot open data file %s\n", experiment_file); exit(1); } i=0; j=0; while(fgets(line, line_length, f) != NULL){ j=0; if(i>0){ current_data->next = (st_data *) malloc(sizeof(st_data )); current_data = (current_data->next); current_data->obser = (double *) malloc(sizeof(double)); } pch = strtok(line,","); while (pch != NULL ) { if(j == 0) { current_data->tstep = atof(pch) - old_tstep; old_tstep = atof(pch); } else { current_data->obser = (double *) realloc(current_data->obser, (j*sizeof(double))); current_data->obser[j-1] = atof(pch); } pch = strtok(NULL, ","); j++; } i++; current_data->next = NULL; } current_data = root_data; model_at -> no_obs_sps = (j-1);/*minus 1 for time*/ model_at -> no_obs = i; return(root_data); }