void editorLoad(const char* fn, SDL_Surface* screen) { //Set filename editorFileName(fn); //Init cursor initCursor(&cur); //Read info's for level. pf.levelInfo = mkLevelInfo( fn ); //Load field loadField(&pf, fileName); initDraw(pf.levelInfo, screen); SDL_FreeSurface(stealGfxPtr()->boardImg); stealGfxPtr()->boardImg = loadImg( DATADIR"data/editbg.png" ); selBrickBG = loadImg( DATADIR"data/editselbrick.png" ); saveBtnBG = loadImg( DATADIR"data/edit-save.png" ); saveBtnSprite = cutSprite( saveBtnBG, 0,0, saveBtnBG->w, saveBtnBG->h ); changed=0; selBrick=BRICKSBEGIN; teleState=0; fieldRect.x = HSCREENW - 74; fieldRect.y = HSCREENH - 114; fieldRect.w = HSCREENW + 154; fieldRect.h = HSCREENH + 114; }
void Processor::read(const char *filename,double centre[],double *size, bool constantRadius, bool incrementRadius) { double min[3], max[3]; fr->ReadVertices(filename,vertexList,centre,&scale, min, max, constantRadius, incrementRadius); elecField = loadField("/home/tbmasood/Downloads/1GRM.dx"); std::cout << elecField->dim[0] << " " << elecField->dim[1] << " " << elecField->dim[2] << std::endl; int indices[] = {0,0,0}; std::cout << elecField->data[0] << " " << elecField->getValue(indices) << std::endl; *size = scale; //alcx = new AlphaComplex(vertexList,centre,&scale); alcx = new AlphaComplex(this, vertexList); alcx->BuildSpectrum(); powerDiagram = new PowerDiagram(this, alcx->delcx, vertexList, min, max); proteinRenderer = new ProteinRenderer(vertexList); // powerDiagram->printGraph(); pocket = new Pocket(vertexList,centre,scale,alcx->delcx->DeluanayTrigs.size (),alcx->delcx->DeluanayEdges.size ()); volume = new Volume(vertexList,vertexList.size(),alcx->delcx->DeluanayTrigs.size(),alcx->delcx->DeluanayEdges.size()); isRenderable = true; }
void ObjectBrowserWidget::loadChild(ObjectBrowserItem* parent, const CCopasiContainer* copaParent, bool nField) { unsigned int i; ObjectBrowserItem* last = NULL; CCopasiObject* current = NULL; ObjectList* childStack = new ObjectList(); const CCopasiContainer::objectMap * pObjectList = & copaParent->getObjects(); CCopasiContainer::objectMap::const_iterator it = pObjectList->begin(); CCopasiContainer::objectMap::const_iterator end = pObjectList->end(); if ((copaParent->isVector()) && (nField)) { if ((static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)->size() >= 1) && ((*static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))[0]->isContainer())) {//add attribute list ObjectBrowserItem* fieldChild = new ObjectBrowserItem(parent, NULL, NULL, objectItemList); fieldChild->setObjectType(FIELDATTR); fieldChild->setText(0, "Select by attribute"); fieldChild->setSelectable(false); loadField(fieldChild, const_cast<CCopasiVector < CCopasiObject > *>(static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))); fieldChild->attachKey(); last = fieldChild; } } if (copaParent->isVector()) { for (i = 0; i < static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)->size(); i++) { current = (*static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))[i]; ObjectBrowserItem* currentItem = new ObjectBrowserItem(parent, last, current, objectItemList); last = currentItem; currentItem->setText(0, FROM_UTF8(current->getObjectName())); if (current->isContainer()) { currentItem->setObjectType(CONTAINERATTR); currentItem->attachKey(); if (current->isVector()) currentItem->setText(0, currentItem->text(0) + "[]"); loadChild(currentItem, static_cast< CCopasiContainer * >(current), nField); } else { currentItem->setObjectType(OBJECTATTR); childStack->insert(currentItem); //attach the key later } } } else { while (it != end) { current = it->second; // Skip all strings if (dynamic_cast<CCopasiStaticString *>(current)) { it++; continue; } ObjectBrowserItem* currentItem = new ObjectBrowserItem(parent, last, current, objectItemList); last = currentItem; currentItem->setText(0, FROM_UTF8(current->getObjectName())); if (current->isContainer()) { currentItem->setObjectType(CONTAINERATTR); currentItem->attachKey(); if (current->isVector()) currentItem->setText(0, currentItem->text(0) + "[]"); loadChild(currentItem, static_cast< CCopasiContainer * >(current), nField); } else { currentItem->setObjectType(OBJECTATTR); childStack->insert(currentItem); //attach the key later } it++; } } ObjectBrowserItem* pCurrent; while (childStack->len() > 0) { pCurrent = childStack->pop(); pCurrent->attachKey(); } pdelete(childStack); }
int initGame(SDL_Surface* screen) { if(player()->gameStarted) { printf("ERROR: Called init when a game was running\n"); return(0); } //Only load the back-image once. if( !ptrRestart ) { ptrRestart = loadImg( DATADIR"data/ptr-restart.png" ); ptrRestartRect.x=HSCREENW-160; ptrRestartRect.w=ptrRestartRect.x+ptrRestart->w; ptrRestartRect.y=HSCREENH+120-ptrRestart->h; ptrRestartRect.h=ptrRestartRect.y+ptrRestart->h; } debugNumInit++; initCursor(&cur); restartConfirm=0; //Read info's for level. (this is done instead of using the one in packInfo so it don't need resetting) pf.levelInfo = mkLevelInfo( player()->levelFile ); if(!loadField(&pf, player()->levelFile )) { printf("Error: Couldn't init playfield.\n"); return(0); } if(!initDraw(pf.levelInfo,screen)) { printf("Error: Couldn't init graphics.\n"); return(0); } char* buf = malloc(sizeof(char)*128); sprintf(buf, "themes/%s",pf.levelInfo->soundDir); loadSamples( buf, levelInfo( player()->level)->musicFile ); //Load samples from sounddir, note we use the levelInfo from packInfo for the music since the playlist is hacked onto that. free(buf); txtLoadGameCharSet( pf.levelInfo->fontName ); pf.levelInfo->time *= 1000; //Convert seconds to ms countdown=500; countdownSeconds=3; gameState=GAMESTATECOUNTDOWN; player()->gameStarted=1; //Clear player stats memset( &player()->hsEntry, 0, sizeof( hsEntry_t ) ); //Set the levelNum player()->hsEntry.levelNum = player()->level; startStopImg=0; if(pf.levelInfo->startImg) { gameState=GAMESTATESTARTIMAGE; } //We also simulate the first switch tick here so all looks right at the countdown. switchUpdateAll( &pf ); justWon=0; return(1); }
Streaklines::gatherTimeStep(coOutputPort *port) #endif { std::vector<float> x_coord; std::vector<float> y_coord; std::vector<float> z_coord; std::vector<float> mag; std::vector<int> vertices; std::vector<int> lineList; // number_per_tstep_ int release; int line_label; int no_of_releases = no_ptasks_ / number_per_tstep_; // count number of lines, and vertices int numLines = 0; int numVertices = 0; vector<const coDistributedObject *> sfield; loadField(sfield); for (line_label = 0; line_label < number_per_tstep_; ++line_label) { char startLineFlag = 'y'; for (release = 0; release < no_of_releases; ++release) { // get the last point of pathline with task order == // release * number_per_tstep_ + line_label int task = release * number_per_tstep_ + line_label; PPathline *p_pathline = (PPathline *)(ptasks_[task]); // check if this PTask is still alive or not if (p_pathline->getKeepStatus() != PTask::NOT_SERVICED) { // terminated startLineFlag = 'y'; } else { // still alive vertices.push_back(numVertices); float *x_c = p_pathline->x_c(); float *y_c = p_pathline->y_c(); float *z_c = p_pathline->z_c(); float *m_c = p_pathline->m_c(); if (sfield.size() > 0) { m_c = p_pathline->m_c_interpolate(sfield, sfield); } int no_points = p_pathline->num_points(); x_coord.push_back(x_c[no_points - 1]); y_coord.push_back(y_c[no_points - 1]); z_coord.push_back(z_c[no_points - 1]); mag.push_back(m_c[no_points - 1]); if (startLineFlag == 'y') { startLineFlag = 'n'; lineList.push_back(numVertices); ++numLines; } ++numVertices; } } } if (lines_.size() <= covise_time_) lines_.resize(covise_time_ + 1); #ifndef YAC std::string name = name_line_; char buf[64]; sprintf(buf, "_%d", covise_time_); name += buf; lines_[covise_time_] = new coDoLines(name, numVertices, &x_coord[0], &y_coord[0], &z_coord[0], numVertices, &vertices[0], numLines, &lineList[0]); #else //fixme timestep? coObjInfo lInfo = port->getNewObjectInfo(); lines_[covise_time_] = new coDoLines(lInfo, numVertices, &x_coord[0], &y_coord[0], &z_coord[0], numVertices, &vertices[0], numLines, &lineList[0]); #endif float *x_line, *y_line, *z_line; int *corner_list, *line_list; ((coDoLines *)(lines_[covise_time_]))->getAddresses(&x_line, &y_line, &z_line, &corner_list, &line_list); if (verschiebung[0] != 0.0 || verschiebung[1] != 0.0 || verschiebung[2] != 0.0) { Verschieben(verschiebung, numVertices, x_line, y_line, z_line); } if (magnitude_.size() <= covise_time_) magnitude_.resize(covise_time_ + 1); #ifndef YAC // magnitude name = name_magnitude_; sprintf(buf, "_%d", covise_time_); name += buf; magnitude_[covise_time_] = new coDoFloat(name, numVertices, &mag[0]); #else // fixme timestep? coObjInfo fInfo = port->getNewObjectInfo(); magnitude_[covise_time_] = new coDoFloat(fInfo, numVertices, &mag[0]); #endif if (speciesAttr.length() > 0) magnitude_[covise_time_]->addAttribute("SPECIES", speciesAttr.c_str()); }