Game::Game(int width, int height, char pattern, int xOffset, int yOffset, int generations, int pauseLength) { // hard-coded because the user shouldn't be concerned with a buffer buffer = 5; this->width = width + 2 * buffer; this->height = height + 2 * buffer; this->generations = generations; this->pauseLength = pauseLength; // build that grid grid = new int*[this->width]; for (int col = 0; col < this->width; ++col) { grid[col] = new int[this->height]; } // make sure everything is DEAD clearGrid(); // on that bed of dead cells, throw a picture of life setPatternVector(pattern, xOffset, yOffset); initializePattern(); }
/******************************************************************** * Default Constructor * Initializes the grid spaces. ********************************************************************/ Grid :: Grid() { // Set up my precious defaults. clearGrid(); curRow = 0; curCol = 0; initDraw(); }
void TicTacToe::checkGameCondition() { if (checkDraw()) { ++mDrawCount; ui->drawCount->setText(QString("%1").arg(mDrawCount)); clearGrid(); } else if (checkUserWin()) { ++mUserScore; ui->userScore->setText(QString("%1").arg(mUserScore)); clearGrid(); } else { computerPlay(); if(checkComputerWin()) { ++mComputerScore; ui->computerScore->setText(QString("%1").arg(mComputerScore)); clearGrid(); } } }
/// Adds a graph to the scene, including all data points and meta-information. void DiagramScene::addGraph(DiagramList* list) { setDiagramBoundaries(list); adjustScaling(); _xLabel->setPlainText(list->getXLabel()); _yLabel->setPlainText(list->getYLabel()); _xUnit->setPlainText(list->getXUnit()); _yUnit->setPlainText(list->getYUnit()); clearGrid(); constructGrid(); _lists.push_back(list); for (int i = 0; i < _lists.size(); i++) drawGraph(_lists[i]); update(); }
void TfrmRetrieved::init( const LCDbProject* p_proj ) { this->ActiveControl = btnOK; clearGrid(); // proj = p_proj; grdSamples->Cells[0][0] = "Sample ID"; grdSamples->Cells[1][0] = "Cryovial ID"; grdSamples->Cells[2][0] = "Aliquot Type"; grdSamples->Cells[3][0] = "Box Name"; grdSamples->Cells[4][0] = "Rack Name"; grdSamples->Cells[5][0] = "Tank Name"; for( int i = 0; i < grdSamples->ColCount; i++ ) { grdSamples->ColWidths[i] = (int)(grdSamples->ClientWidth * 0.16); } Retrieve(); }
// called in the constructor.. and when reinit needs to occur // initalizes GridSquares to the grid bool Grid::initGrid(){ if(m_theGrid){ clearGrid(); } //if(!m_theGrid){ m_theGrid = new GridSquare**[width_grid_x]; //} for (int i = 0; i < width_grid_x; ++i){ //if(!m_theGrid[i]){ m_theGrid[i] = new GridSquare*[height_grid_y]; //} for (int j = 0; j < height_grid_y; ++j) { m_theGrid[i][j] = new GridSquare(i, j, NULL); } } return true; }
/* * This controls where the cursor moves to next. * Press w to go up * Press a to go left * Press s to go down * Press d to go right */ void control(unsigned char c, point * p, int (*board)[width]){ if(c == 'w'){ goUp(p, board); } if(c == 'a'){ goLeft(p, board); } if(c == 's'){ goDown(p,board); } if(c == 'd'){ goRight(p,board); } //9 corresponds to Tab if(c == 9){ clearGrid(board, p); } }
int main(int argc, char** argv){ unsigned char command; //This will track what keys are pressed during use if(argc != 3){ printf("To use this program, please specify the height and width of the grid you want to draw on.\n"); exit(-1); } //height and width are global variables defined in the header height = atoi(argv[1]); width = atoi(argv[2]); int board[height][width]; //This will keep track of the state of the board point p = {0,0}; //point is where the sketcher is currently at clearGrid(board, &p); while(1){ drawGrid(board); control(kbhit(), &p, board); fflush(stdout); } }
//--------------------------------------------------------------------------- void satpassdialog::on_activeSatBtn_clicked() { QDateTime utc = getSelectedUTC(); TRig *rig = mw->getRig(); TSat *sat; int i; QApplication::setOverrideCursor(Qt::WaitCursor); m_ui->tableWidget->setSortingEnabled(false); clearGrid(m_ui->tableWidget); for(i=0; i<satList->Count; i++) { sat = (TSat *) satList->ItemAt(i); if(sat->isActive()) sat->SatellitePasses(rig, m_ui->tableWidget, utc, 1); } m_ui->tableWidget->setSortingEnabled(true); m_ui->tableWidget->sortItems(AOS_COL_NR); QApplication::restoreOverrideCursor(); }
/* gAdjust: */ static void gAdjust (Agraph_t* g, double temp, bport_t* pp, Grid* grid) { Agnode_t* n; Agedge_t* e; if (temp <= 0.0) return; clearGrid (grid); for (n = agfstnode(g); n; n = agnxtnode(g,n)) { DISP(n)[0] = DISP(n)[1] = 0; addGrid (grid, floor(n->u.pos[0]/Cell), floor(n->u.pos[1]/Cell), n); } for (n = agfstnode(g); n; n = agnxtnode(g,n)) { for (e = agfstout(g,n); e; e = agnxtout(g,e)) if (n != e->head) applyAttr (n, e->head, e); } walkGrid (grid, gridRepulse); updatePos (g, temp, pp); }
void TicTacToe::on_endGameButton_clicked() { clearGrid(); emit returnToWelcomeSignal(mName); }
int runVegas(void) { int i; double sd; double avgi; char mess[25]; FILE * iprt = NULL; int mode=1; void * pscr=NULL; static int n_Line=7; i=imkmom(inP1,inP2); if(veg_Ptr&&veg_Ptr->ndim!=i)clearGrid(); if(!veg_Ptr) veg_Ptr=vegas_init(i,50); if(nin_int == 2) strcpy(mess, "Cross section[pb]"); else strcpy(mess, " Width[Gev] "); /* ** save current session parameters */ w_sess__(NULL); /* ** open protocol and resulting files */ { char fname[50]; sprintf(fname,"%sprt_%d",outputDir,nSess); iprt=fopen(fname,"a"); if(ftell(iprt)==0) { fprintf(iprt," CalcHEP kinematics module \n The session parameters:\n"); w_sess__(iprt); fprintf(iprt,"===================================\n"); } } /* ** initkinematics */ while(correctHistList()) editHist(); /* *** Main cycle */ if(!integral.old || n_Line==7) { n_Line=7; scrcolor(Blue, BGmain); // printLn(iprt,&n_Line," #IT %20s Error %% nCall chi**2",mess); printLn(iprt,&n_Line," #IT %s Error[%%] nCalls Eff. chi^2",mess); } for(;;) { static int worn=1; char strmen[]="\030" " nSess = N2_1 " " nCalls = N1_1 " " Set Distributions " "*Start integration " " Display Distributions " " Clear statistic " " Freeze grid OFF " " Clear grid " " Event Cubes NCUBE " " Generate Events "; improveStr(strmen,"N1_1","%d",integral.ncall[0]); improveStr(strmen,"N2_1","%d",integral.itmx[0]); improveStr(strmen,"NCUBE","%d",EventGrid); if(integral.freeze) improveStr(strmen,"OFF","ON"); menu1(54,7,"",strmen,"n_veg_*",&pscr,&mode); switch(mode) { case 0: if(iprt) fclose(iprt); return 0; case 1: correctInt(50,12,"Enter new value ",&integral.itmx[0],1); break; case 2: correctLong(50,12,"Enter new value ",&integral.ncall[0],1); break; case 3: editHist(); break; case 4: if(veg_Ptr->fMax && !integral.freeze) { if(!mess_y_n(15,15,"You have event generator prepared.\n" " The answer 'Y' will start Vegas session \nwhich destroys it." " To save the event generator answer 'N' \nand set " " ' Freeze grid' ON")) break; else { free(veg_Ptr->fMax); veg_Ptr->fMax=NULL; veg_Ptr->nCubes=0;} } for (i = 1; i <= integral.itmx[0]; ++i) { double sum; char errtxt[100]=""; int k; if(integral.ncall[0]==0) break; nCall=0; negPoints=0; badPoints=0; hFill=1; if(vegas_int(veg_Ptr, integral.ncall[0],1.5*(!integral.freeze), func_, &avgi, &sd) ) break; integral.old=1; negPoints/=nCall; badPoints/=nCall; integral.nCallTot+=nCall; scrcolor(FGmain,BGmain); printLn(iprt,&n_Line,"%4d %12.4E %10.2E %8d %s", ++integral.n_it, avgi,avgi? 100*sd/(double)fabs(avgi):0.,nCall,effInfo()); if(negPoints<0) sprintf(errtxt+strlen(errtxt)," Negative points %.1G%%;", -100*negPoints/(avgi-2*negPoints)); if(badPoints) sprintf(errtxt+strlen(errtxt), "Bad Precision %.1G%%;",100*badPoints/(avgi-2*negPoints)); if(errtxt[0]) { scrcolor(Red,BGmain); printLn(iprt,&n_Line,"%s",errtxt); } integral.s0+=sd*sd; integral.s1+=avgi; integral.s2+=avgi*avgi; } integral.In=integral.s1/integral.n_it; integral.dI=sqrt(integral.s0)/integral.n_it; if(integral.n_it<=1 || integral.s0==0 ) integral.khi2=0; else integral.khi2=(integral.s2-integral.s1*integral.s1/integral.n_it)*integral.n_it/(integral.n_it-1)/fabs(integral.s0); scrcolor(FGmain,BGmain); printLn(iprt,&n_Line," < > %12.4E %10.2E %8d %7.7s %-7.1G" , integral.In, fabs(integral.In)? 100*integral.dI/(double)fabs(integral.In):0., integral.nCallTot, effInfo(), integral.khi2); if(histTab.strings) { char fname[20]; FILE * d; sprintf(fname,"distr_%d",nSess); d=fopen(fname,"w"); wrt_hist2(d,Process); fclose(d); } messanykey(54,11,"Integration is over"); /* integral.freeze=0; */ break; case 5: showHist(54,10,Process); break; case 6: clearStatistics(-1); messanykey(54,13,"Old results for integral\n" "and distributions\nare deleted."); break; case 7: integral.freeze=!integral.freeze; break; case 8: if(!integral.freeze || mess_y_n(15,15,"The information for Event Generator will be lost\n OK?")) { int ndim=veg_Ptr->ndim; vegas_finish(veg_Ptr); veg_Ptr=vegas_init(ndim,50); messanykey(57,11,"OK"); } break; case 9: if(correctLong(50,12,"Enter new value ",&EventGrid,1)) { if(veg_Ptr->fMax) {free(veg_Ptr->fMax); veg_Ptr->fMax=NULL;veg_Ptr->nCubes=0;}} break; case 10: if( !veg_Ptr || !veg_Ptr->fMax) { char * mess="Before event generation one has to launch Vegas session with freezed grid\n" "to prepare generator"; if(blind) { printf("%s\n",mess); sortie(200);} else messanykey(4,13,mess); } else runEvents(); } } }
int main() { //prototypes for main void printTitle(), setGridSize(), clearGrid(int grid[column_size][row_size]), playerTurn(int player, int grid[column_size][row_size]); int checkWinner(int grid[column_size][row_size]), continueGame(); //variable initilisation. int player, winner; printTitle(); do { //construction of new game player = 1; //resets player winner = 0; // resets winner setGridSize(); int grid[column_size][row_size]; // constructs grid clearGrid(grid); // sets all grid values to 0 clearScreen(); //game plays out inside until winner or draw. while(winner == 0) { playerTurn(player, grid); winner = checkWinner(grid); if(winner == 0) { //switches player if(player == 1) { player = 2; } else { player = 1; } } else { //clears screen and prints grid between turns. clearScreen(); printGrid(grid); spacer(); //spacer called repeatedly to move print to center of console printf("\n\n"); spacer(); if(winner != 3) //checks if winner was a player or a draw. A winner of '3' is a draw { printf("Winner is Player %d!!!", winner); } else { printf("Draw!!!"); } } } //starts a new game if true }while(continueGame()); return(0); }
/******************************************************************** * update() * This method is in charge of always keeping the grid up to date. * It needs info from the mouse in order to do this. ********************************************************************/ void Grid :: update(const Input & input) { char state = NONE; bool same = true; // STEP 1 - UPDATE COORDS if (input.didMouseMove()) { int row = (int) (input.mouseX() / x1); int col = (int) (input.mouseY() / y1); // Make sure the spaces keep their bounds. if (row > 2) row = 2; else if (row < 0) row = 0; if (col > 2) col = 2; else if (col < 0) col = 0; // DEBUG //std::cout << "ROW: " << row << " | COL: " << col << std::endl; same = (curRow == row && curCol == col); if (!same) { curRow = row; curCol = col; } } // STEP 2 - FIGURE OUT STATUS if (input.mousePressed() && input.mouseDown()) { // Reason for the and, if you press a mouse quickly enough, // it will release and press in the same turn. When it is // released, it will no longer be down. We don't want mouse // input to be that quick. state = PRESS; } else if (input.mouseDown()) { if (!same) refreshGrid(); //if (gridStates[curRow][curCol] == SELECT) //state = SELECT; //else //state = DOWN; state = DOWN; } else if (input.mouseReleased()) { clearGrid(); state = RELEASE; } else { if (!same) clearGrid(); state = HOVER; } // STEP 3 - UPDATE GRID gridStates[curRow][curCol] = state; // STEP 4 - UPDATE TO GL glUseProgram(mprogram); glUniform2f(glGetUniformLocation(mprogram, "mpos"), input.mouseX(), input.mouseY()); }
int runVegas(void) { int i; double sd; double avgi; char mess[25]; FILE * iprt = NULL; int mode=1; void * pscr=NULL; static int n_Line=0; if(blind) vegas_control=NULL; else vegas_control=infoLine; i=imkmom(inP1,inP2); if(veg_Ptr&&veg_Ptr->dim!=i)clearGrid(); if(!veg_Ptr) veg_Ptr=vegas_init(i,func_,50); if(nin_int == 2) strcpy(mess, "Cross section[pb]"); else strcpy(mess, " Width[Gev] "); /* ** save current session parameters */ w_sess__(NULL); /* ** open protocol and resulting files */ { char fname[50]; sprintf(fname,"%sprt_%d",outputDir,nSess); iprt=fopen(fname,"a"); } /* ** initkinematics */ while(correctHistList()) editHist(); if(integral.old) { if(!n_Line) n_Line=9;} else { w_sess__(iprt); n_Line=8; } /* *** Main cycle */ for(;;) { int fz; char strmen[]="\030" " nSess = N2_1 " " nCalls = N1_1 " " Set Distributions " "*Start integration " " Display Distributions " " Clear statistic " " Freeze grid OFF " " Clear grid " " Event Cubes NCUBE " " Num. of events=NE " " Generate Events "; if(integral.freeze) { fz=1; improveStr(strmen,"OFF","ON"); improveStr(strmen,"NCUBE","%d",EventGrid); } else { fz=0; strmen[ 030*8+2]=0; } improveStr(strmen,"N1_1","%d",integral.ncall[fz]); improveStr(strmen,"N2_1","%d",integral.itmx[fz]); improveStr(strmen,"NE","%d",nEvents); menu1(54,7,"",strmen,"n_veg_*",&pscr,&mode); switch(mode) { case 0: w_sess__(NULL); if(iprt) fclose(iprt); return 0; case 1: correctInt(50,12,"Enter new value ", integral.itmx+fz,1); break; case 2: correctLong(50,12,"Enter new value ",integral.ncall+fz,1);break; case 3: editHist(); break; case 4: if(veg_Ptr->fMax && !integral.freeze) { free(veg_Ptr->fMax); veg_Ptr->fMax=NULL; veg_Ptr->evnCubes=0; } if(!veg_Ptr->fMax && integral.freeze) { setEventCubes(veg_Ptr, EventGrid); EventGrid=veg_Ptr->evnCubes; } for (i = 1; i <= integral.itmx[fz]; ++i) { char errtxt[100]=""; long nCall; if(integral.ncall[0]==0) break; negPoints=0; badPoints=0; hFill=1; nCall=vegas_int(veg_Ptr, integral.ncall[fz],1.5*(!fz),nPROCSS,&avgi, &sd); if(nCall<0) { messanykey(10,10,"NaN in integrand"); break;} if(nCall==0) break; integral.old=1; negPoints/=nCall; badPoints/=nCall; integral.nCallTot+=nCall; scrcolor(FGmain,BGmain); printLn(iprt,&n_Line,"%4d %12.4E %10.2E %8d %s", ++integral.n_it, avgi,avgi? 100*sd/(double)fabs(avgi):0.,nCall,effInfo()); if(negPoints<0) sprintf(errtxt+strlen(errtxt)," Negative points %.1G%%;", -100*negPoints/(avgi-2*negPoints)); if(badPoints) sprintf(errtxt+strlen(errtxt), "Bad Precision %.1G%%;",100*badPoints/(avgi-2*negPoints)); if(errtxt[0]) { scrcolor(Red,BGmain); printLn(iprt,&n_Line,"%s",errtxt); } integral.s0+=sd*sd; integral.s1+=avgi; integral.s2+=avgi*avgi; } integral.In=integral.s1/integral.n_it; integral.dI=sqrt(integral.s0)/integral.n_it; if(integral.n_it<=1 || integral.s0==0 ) integral.khi2=0; else integral.khi2=(integral.s2-integral.s1*integral.s1/integral.n_it)*integral.n_it/(integral.n_it-1)/fabs(integral.s0); scrcolor(FGmain,BGmain); printLn(iprt,&n_Line," < > %12.4E %10.2E %8d %7.7s %-7.1G" , integral.In, fabs(integral.In)? 100*integral.dI/(double)fabs(integral.In):0., integral.nCallTot, effInfo(), integral.khi2); if(histTab.strings) { char fname[20]; FILE * d; sprintf(fname,"distr_%d",nSess); d=fopen(fname,"w"); wrt_hist2(d,Process); fclose(d); } messanykey(54,11,"Integration is over"); /* integral.freeze=0; */ break; case 5: showHist(54,10,Process); break; case 6: clearStatistics(-1); messanykey(54,13,"Old results for integral\n" "and distributions\nare deleted."); break; case 7: if(veg_Ptr->fMax && integral.freeze) { if(mess_y_n(15,15,"You have event generator prepared.\n" " Setting the flag \"OFF\" will destroy it." " Press 'Y' to confirm.")) integral.freeze=0; } else integral.freeze=!integral.freeze; break; case 8: if(!integral.freeze || mess_y_n(15,15,"The information for Event Generator will be lost\n OK?")) { int ndim=veg_Ptr->dim; vegas_finish(veg_Ptr); veg_Ptr=vegas_init(ndim,func_,50); messanykey(57,11,"OK"); } break; case 9: if(correctLong(50,12,"Enter new value ",&EventGrid,1)) { if(veg_Ptr->fMax) {free(veg_Ptr->fMax); veg_Ptr->fMax=NULL;} printf("EventGrid=%d\n",EventGrid); setEventCubes(veg_Ptr, EventGrid); EventGrid=veg_Ptr->evnCubes; } break; case 10: correctInt(50,15,"",&nEvents,1); break; case 11: if( !veg_Ptr || !veg_Ptr->fMax) { char * mess="Before event generation one has to launch Vegas session with freezed grid\n" "to prepare generator"; if(blind) { printf("%s\n",mess); sortie(200);} else messanykey(4,13,mess); } else runEvents(); } } }
/* MapObjectPropsPanel::setupType * Adds all relevant properties to the grid for [objtype] *******************************************************************/ void MapObjectPropsPanel::setupType(int objtype) { // Nothing to do if it was already this type if (last_type == objtype) return; // Get map format int map_format = theMapEditor->currentMapDesc().format; // Clear property grid clearGrid(); btn_add->Show(false); // Hide buttons if not needed if (no_apply || mobj_props_auto_apply) { btn_apply->Show(false); btn_reset->Show(false); } else if (!no_apply) { btn_apply->Show(); btn_reset->Show(); } // Vertex properties if (objtype == MOBJ_VERTEX) { // Set main tab name stc_sections->SetPageText(0, "Vertex"); // Add 'basic' group wxPGProperty* g_basic = pg_properties->Append(new wxPropertyCategory("General")); // Add X and Y position addIntProperty(g_basic, "X Position", "x"); addIntProperty(g_basic, "Y Position", "y"); last_type = MOBJ_VERTEX; } // Line properties else if (objtype == MOBJ_LINE) { // Set main tab name stc_sections->SetPageText(0, "Line"); // Add 'General' group wxPGProperty* g_basic = pg_properties->Append(new wxPropertyCategory("General")); // Add side indices addIntProperty(g_basic, "Front Side", "sidefront"); addIntProperty(g_basic, "Back Side", "sideback"); // Add 'Special' group if (!propHidden("special")) { wxPGProperty* g_special = pg_properties->Append(new wxPropertyCategory("Special")); // Add special MOPGActionSpecialProperty* prop_as = new MOPGActionSpecialProperty("Special", "special"); prop_as->setParent(this); properties.push_back(prop_as); pg_properties->AppendIn(g_special, prop_as); // Add args (hexen) if (map_format == MAP_HEXEN) { for (unsigned a = 0; a < 5; a++) { // Add arg property MOPGIntProperty* prop = (MOPGIntProperty*)addIntProperty(g_special, S_FMT("Arg%u", a+1), S_FMT("arg%u", a)); // Link to action special args[a] = prop; } } else // Sector tag otherwise { //addIntProperty(g_special, "Sector Tag", "arg0"); MOPGTagProperty* prop_tag = new MOPGTagProperty(MOPGTagProperty::TT_SECTORTAG, "Sector Tag", "arg0"); prop_tag->setParent(this); properties.push_back(prop_tag); pg_properties->AppendIn(g_special, prop_tag); } // Add SPAC if (map_format == MAP_HEXEN) { MOPGSPACTriggerProperty* prop_spac = new MOPGSPACTriggerProperty("Trigger", "spac"); prop_spac->setParent(this); properties.push_back(prop_spac); pg_properties->AppendIn(g_special, prop_spac); } } if (!hide_flags) { // Add 'Flags' group wxPGProperty* g_flags = pg_properties->Append(new wxPropertyCategory("Flags")); // Add flags for (int a = 0; a < theGameConfiguration->nLineFlags(); a++) addLineFlagProperty(g_flags, theGameConfiguration->lineFlag(a), S_FMT("flag%u", a), a); } // --- Sides --- pg_props_side1->Show(true); pg_props_side2->Show(true); stc_sections->AddPage(pg_props_side1, "Front Side"); stc_sections->AddPage(pg_props_side2, "Back Side"); // 'General' group 1 wxPGProperty* subgroup = pg_props_side1->Append(new wxPropertyCategory("General", "side1.general")); addIntProperty(subgroup, "Sector", "side1.sector"); // 'Textures' group 1 if (!propHidden("texturetop")) { subgroup = pg_props_side1->Append(new wxPropertyCategory("Textures", "side1.textures")); addTextureProperty(subgroup, "Upper Texture", "side1.texturetop", 0); addTextureProperty(subgroup, "Middle Texture", "side1.texturemiddle", 0); addTextureProperty(subgroup, "Lower Texture", "side1.texturebottom", 0); } // 'Offsets' group 1 if (!propHidden("offsetx")) { subgroup = pg_props_side1->Append(new wxPropertyCategory("Offsets", "side1.offsets")); addIntProperty(subgroup, "X Offset", "side1.offsetx"); addIntProperty(subgroup, "Y Offset", "side1.offsety"); } // 'General' group 2 subgroup = pg_props_side2->Append(new wxPropertyCategory("General", "side2.general")); addIntProperty(subgroup, "Sector", "side2.sector"); // 'Textures' group 2 if (!propHidden("texturetop")) { subgroup = pg_props_side2->Append(new wxPropertyCategory("Textures", "side2.textures")); addTextureProperty(subgroup, "Upper Texture", "side2.texturetop", 0); addTextureProperty(subgroup, "Middle Texture", "side2.texturemiddle", 0); addTextureProperty(subgroup, "Lower Texture", "side2.texturebottom", 0); } // 'Offsets' group 2 if (!propHidden("offsetx")) { subgroup = pg_props_side2->Append(new wxPropertyCategory("Offsets", "side2.offsets")); addIntProperty(subgroup, "X Offset", "side2.offsetx"); addIntProperty(subgroup, "Y Offset", "side2.offsety"); } } // Sector properties else if (objtype == MOBJ_SECTOR) { // Set main tab name stc_sections->SetPageText(0, "Sector"); // Add 'General' group wxPGProperty* g_basic = pg_properties->Append(new wxPropertyCategory("General")); // Add heights if (!propHidden("heightfloor")) addIntProperty(g_basic, "Floor Height", "heightfloor"); if (!propHidden("heightceiling")) addIntProperty(g_basic, "Ceiling Height", "heightceiling"); // Add tag if (!propHidden("id")) { MOPGTagProperty* prop_tag = new MOPGTagProperty(MOPGTagProperty::TT_SECTORTAG, "Tag/ID", "id"); prop_tag->setParent(this); properties.push_back(prop_tag); pg_properties->AppendIn(g_basic, prop_tag); } // Add 'Lighting' group if (!propHidden("lightlevel")) { wxPGProperty* g_light = pg_properties->Append(new wxPropertyCategory("Lighting")); // Add light level addIntProperty(g_light, "Light Level", "lightlevel"); } // Add 'Textures' group if (!propHidden("texturefloor")) { wxPGProperty* g_textures = pg_properties->Append(new wxPropertyCategory("Textures")); // Add textures addTextureProperty(g_textures, "Floor Texture", "texturefloor", 1); addTextureProperty(g_textures, "Ceiling Texture", "textureceiling", 1); } // Add 'Special' group if (!propHidden("special")) { wxPGProperty* g_special = pg_properties->Append(new wxPropertyCategory("Special")); // Add special MOPGSectorSpecialProperty* prop_special = new MOPGSectorSpecialProperty("Special", "special"); prop_special->setParent(this); properties.push_back(prop_special); pg_properties->AppendIn(g_special, prop_special); } } // Thing properties else if (objtype == MOBJ_THING) { // Set main tab name stc_sections->SetPageText(0, "Thing"); // Add 'General' group wxPGProperty* g_basic = pg_properties->Append(new wxPropertyCategory("General")); // Add position addIntProperty(g_basic, "X Position", "x"); addIntProperty(g_basic, "Y Position", "y"); // Add z height if (map_format != MAP_DOOM && !propHidden("height")) addIntProperty(g_basic, "Z Height", "height"); // Add angle if (!propHidden("angle")) { MOPGAngleProperty* prop_angle = new MOPGAngleProperty("Angle", "angle"); prop_angle->setParent(this); properties.push_back(prop_angle); pg_properties->AppendIn(g_basic, prop_angle); } // Add type if (!propHidden("type")) { MOPGThingTypeProperty* prop_tt = new MOPGThingTypeProperty("Type", "type"); prop_tt->setParent(this); properties.push_back(prop_tt); pg_properties->AppendIn(g_basic, prop_tt); } // Add id if (map_format != MAP_DOOM && !propHidden("id")) { MOPGTagProperty* prop_id = new MOPGTagProperty(MOPGTagProperty::TT_THINGID, "ID", "id"); prop_id->setParent(this); properties.push_back(prop_id); pg_properties->AppendIn(g_basic, prop_id); } if (map_format == MAP_HEXEN && !propHidden("special")) { // Add 'Scripting Special' group wxPGProperty* g_special = pg_properties->Append(new wxPropertyCategory("Scripting Special")); // Add special MOPGActionSpecialProperty* prop_as = new MOPGActionSpecialProperty("Special", "special"); prop_as->setParent(this); properties.push_back(prop_as); pg_properties->AppendIn(g_special, prop_as); // Add 'Args' group wxPGProperty* g_args = pg_properties->Append(new wxPropertyCategory("Args")); for (unsigned a = 0; a < 5; a++) { MOPGIntProperty* prop = (MOPGIntProperty*)addIntProperty(g_args, S_FMT("Arg%u", a+1), S_FMT("arg%u", a)); args[a] = prop; } } if (!hide_flags) { // Add 'Flags' group wxPGProperty* g_flags = pg_properties->Append(new wxPropertyCategory("Flags")); // Add flags for (int a = 0; a < theGameConfiguration->nThingFlags(); a++) addThingFlagProperty(g_flags, theGameConfiguration->thingFlag(a), S_FMT("flag%u", a), a); } } // Set all bool properties to use checkboxes pg_properties->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, true); last_type = objtype; Layout(); }
/* MapObjectPropsPanel::setupTypeUDMF * Adds all relevant UDMF properties to the grid for [objtype] *******************************************************************/ void MapObjectPropsPanel::setupTypeUDMF(int objtype) { // Nothing to do if it was already this type if (last_type == objtype) return; // Clear property grids clearGrid(); // Hide buttons if not needed if (no_apply || mobj_props_auto_apply) { btn_apply->Show(false); btn_reset->Show(false); } else if (!no_apply) { btn_apply->Show(); btn_reset->Show(); } // Set main tab title if (objtype == MOBJ_VERTEX) stc_sections->SetPageText(0, "Vertex"); else if (objtype == MOBJ_LINE) stc_sections->SetPageText(0, "Line"); else if (objtype == MOBJ_SECTOR) stc_sections->SetPageText(0, "Sector"); else if (objtype == MOBJ_THING) stc_sections->SetPageText(0, "Thing"); // Go through all possible properties for this type vector<udmfp_t> props = theGameConfiguration->allUDMFProperties(objtype); sort(props.begin(), props.end()); for (unsigned a = 0; a < props.size(); a++) { // Skip if hidden if ((hide_flags && props[a].property->isFlag()) || (hide_triggers && props[a].property->isTrigger())) { hide_props.push_back(props[a].property->getProperty()); continue; } if (VECTOR_EXISTS(hide_props, props[a].property->getProperty())) continue; addUDMFProperty(props[a].property, objtype); } // Add side properties if line type if (objtype == MOBJ_LINE) { // Add side tabs pg_props_side1->Show(true); pg_props_side2->Show(true); stc_sections->AddPage(pg_props_side1, "Front Side"); stc_sections->AddPage(pg_props_side2, "Back Side"); // Get side properties vector<udmfp_t> sprops = theGameConfiguration->allUDMFProperties(MOBJ_SIDE); sort(sprops.begin(), sprops.end()); // Front side for (unsigned a = 0; a < sprops.size(); a++) { // Skip if hidden if ((hide_flags && sprops[a].property->isFlag()) || (hide_triggers && sprops[a].property->isTrigger())) { hide_props.push_back(sprops[a].property->getProperty()); continue; } if (VECTOR_EXISTS(hide_props, sprops[a].property->getProperty())) continue; addUDMFProperty(sprops[a].property, objtype, "side1", pg_props_side1); } // Back side for (unsigned a = 0; a < sprops.size(); a++) { // Skip if hidden if ((hide_flags && sprops[a].property->isFlag()) || (hide_triggers && sprops[a].property->isTrigger())) { hide_props.push_back(sprops[a].property->getProperty()); continue; } if (VECTOR_EXISTS(hide_props, sprops[a].property->getProperty())) continue; addUDMFProperty(sprops[a].property, objtype, "side2", pg_props_side2); } } // Set all bool properties to use checkboxes pg_properties->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, true); // Remember arg properties for passing to type/special properties (or set // to NULL if args don't exist) for (unsigned arg = 0; arg < 5; arg++) args[arg] = pg_properties->GetProperty(S_FMT("arg%u", arg)); last_type = objtype; Layout(); }
int monte_carlo_menu(void) { static int r=0; int mode=1; void * pscr=NULL; void (*quit)(int)=f3_key[7]; char menutxt[]="\030" " Subprocess " " IN state " " Model parameters " " Constraints " " QCD alpha & scales " " Breit-Wigner " " Aliases " " Cuts " " Phase space mapping " " Monte Carlo simulation " " Easy "; if(nout_int!=2 ) menutxt[menutxt[0]*10+1]=0; if(nin_int==1) improveStr(menutxt,"Easy", "Total width"); else improveStr(menutxt,"Easy", "1D integration"); wrtprc_(); for(;;) { infor(); f3_key[7]=quit; menu1(54,4,"",menutxt,"n_mc_*",&pscr, &mode); if(mode==1||mode==2||mode==3||mode==5||mode==7)f3_key[7]=NULL; switch (mode) { case 0: return 0; case 1: r=r|3*sub_men__(); break; case 2: r=r|in_setting(); break; case 3: r=r|change_parameter(54,7,0); break; case 4: { int modeC=1; for(;;) { char menuC[]="\030" " All Constraints " " Masses,Widths,Branching"; void * pscrC=NULL; menu1(54,6,"",menuC,"n_constr_*",&pscrC, &modeC); switch(modeC) { case 0: break; case 1: show_depend(54,7); break; case 2: show_spectrum(54,9); break; } if(!modeC) break; } break; } case 5: r=r|qcdmen_(); break; case 6: r=r|w_men__(); break; case 7: do r=r|(3*edittable(1,4,&compTab,1,"n_comp",0)); while (fillCompositeArray()); break; case 8: do r=r|(3*edittable(1,4,&cutTab,1,"n_cut",0)); while (fillCutArray()); break; case 9: r=r|mappingMenu(); break; case 10: if(nout_int==1 && !sf_num[0] && !sf_num[1] ) { if(blind) return 1; messanykey(15,15,"Phase space integration for 2->1 processes\n needs distribution functions."); break; } if(checkEnergy()) { if(blind==1) { char fname[50]; int i,j; sprintf(fname,"events_%d.txt", nSess); FILE * f=fopen(fname,"w"); fprintf(f,"#%s\n", VERSION_); fprintf(f,"#Type %d -> %d\n", nin_int,nout_int); fprintf(f,"#Initial_state "); if(nin_int==1) fprintf(f," P1=0\n"); else { fprintf(f," P1_3=0 P2_3=0\n"); wrt_sf__(f); } fprintf(f,"#PROCESS "); for(i=1;i<=nin_int+nout_int; i++) { int pcode; char * pname=pinf_int(Nsub,i,NULL,&pcode); fprintf(f," %d(%s)", pcode, pname); if(i==nin_int) fprintf(f," ->"); } fprintf(f,"\n"); fprintf(f,"#MASSES "); for(i=0;i<nin_int+nout_int;i++) { REAL m; pinf_int(Nsub,i+1,&m,NULL); fprintf(f," %.10E", (double)m); } fprintf(f,"\n"); fprintf(f,"#Cross_section(Width) %E\n",0.); fprintf(f,"#Number_of_events %10d\n",0); fprintf(f,"#Sum_of_weights %12.4E %12.4E \n",0.,0.); fprintf(f,"#Events "); if(nin_int==2) fprintf(f," P1_3 [Gev] P2_3 [Gev] "); for(i=1;i<=nout_int; i++) for(j=1;j<=3;j++) fprintf(f," P%d_%d [Gev] ",i+nin_int,j); integral.old=1; fclose(f); return 1; } messanykey(15,15,"Energy is too small!"); break; } if(fillCutArray()) { if(blind) return 2; messanykey(15,15,"Can not evaluate cut limits"); break; } case 11: if(mode==11) { void (*f10_tmp)(int); w_sess__(NULL); f10_tmp=f3_key[7]; f3_key[7]=f10_key_prog_for22; if(nin_int==1) decay12(); else { REAL m1,m2, Pcm; pinf_int(Nsub,1,&m1,NULL); pinf_int(Nsub,2,&m2,NULL); if(sf_num[0] && sf_mass[0]>m1) m1= sf_mass[0]; if(sf_num[1] && sf_mass[1]>m2) m2= sf_mass[1]; incomkin(m1,m2,inP1,inP2,NULL,&Pcm,NULL); if(sf_num[0]||sf_num[1]||nCuts) messanykey(10,10,"Structure functions and cuts are ignored\n"); cs_numcalc(Pcm); } f3_key[7]= f10_tmp; r_sess__(NULL); break; } else if(fillRegArray()) { if(blind) return 3; messanykey(15,15, "Can not evaluate regularization paremeters"); break; } if(mode==10) runVegas(); r=0; break; } //printf("r=%d\n",r); if(r) clearEventMax(); if(r&2) clearGrid(); if(r&1)newSession(); } }
int monte_carlo_menu(void) { static int r=0; int mode=1; void * pscr=NULL; void * pscr_mem=NULL; void (*quit)(int)=f3_key[7]; char menutxt[]="\030" " Subprocess " " IN state " " Model parameters " " Constraints " " QCD coupling " " Breit-Wigner " " Aliases " " Cuts " " Phase space mapping " " Monte Carlo simulation " " Easy "; if(nout_int!=2 ) menutxt[menutxt[0]*10+1]=0; if(nin_int==1) improveStr(menutxt,"Easy", "Total width"); else improveStr(menutxt,"Easy", "1D intergration"); get_text(1,10,80,24,&pscr_mem); wrtprc_(); for(;;) { infor(); f3_key[7]=quit; menu1(54,4,"",menutxt,"n_mc_*",&pscr, &mode); if(mode==1||mode==2||mode==3||mode==5||mode==7)f3_key[7]=NULL; switch (mode) { case 0: put_text(&pscr_mem); return 0; case 1: r=r|3*sub_men__(); break; case 2: r=r|in_setting(); break; case 3: r=r|change_parameter(54,7,0); break; case 4: { int modeC=1; for(;;) { char menuC[]="\030" " All Constraints " " Masses,Widths,Branching"; void * pscrC=NULL; menu1(54,6,"",menuC,"n_constr_*",&pscrC, &modeC); switch(modeC) { case 0: put_text(&pscr_mem); break; case 1: show_depend(54,7); break; case 2: show_spectrum(54,9); break; } if(!modeC) break; } break; } case 5: r=r|qcdmen_(); break; case 6: r=r|w_men__(); break; case 7: do r=r|(3*edittable(1,4,&compTab,1,"n_comp",0)); while (fillCompositeArray()); break; case 8: do r=r|(3*edittable(1,4,&cutTab,1,"n_cut",0)); while (fillCutArray()); break; case 9: r=r|mappingMenu(); break; case 10: if(nout_int==1 && !sf_num[0] && !sf_num[1] ) { if(blind) return 1; messanykey(15,15,"Phase space integration for 2->1 processes\n needs distribution functions."); break; } if(checkEnergy()) { if(blind) return 1; messanykey(15,15,"Energy is too small!"); break; } if(fillCutArray()) { if(blind) return 2; messanykey(15,15,"Can not evaluate cuts limlts"); break; } case 11: if(mode==11) { void (*f10_tmp)(int); w_sess__(NULL); f10_tmp=f3_key[7]; f3_key[7]=f10_key_prog_for22; if(nin_int==1) decay12(); else { REAL m1,m2, Pcm; pinf_int(Nsub,1,&m1,NULL); pinf_int(Nsub,2,&m2,NULL); incomkin(m1,m2,inP1,inP2,NULL,&Pcm,NULL); if(sf_num[0]||sf_num[1]||nCuts) messanykey(10,10,"Structure functions and cuts are ignored\n"); cs_numcalc(Pcm); } f3_key[7]= f10_tmp; r_sess__(NULL); break; } else if(fillRegArray()) { if(blind) return 3; messanykey(15,15, "Can not evaluate regularization paremeters"); break; } if(mode==10) runVegas(); r=0; break; } if(r) clearEventMax(); if(r&2) clearGrid(); if(r&1)newSession(); } }