diff --git a/.github/workflows/key4hep.yml b/.github/workflows/key4hep.yml index 46e7265..69f8860 100644 --- a/.github/workflows/key4hep.yml +++ b/.github/workflows/key4hep.yml @@ -1,18 +1,33 @@ -name: keyh4ep -on: [push, pull_request] +name: key4hep +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - build-and-test: - runs-on: ubuntu-latest + build: strategy: matrix: build_type: ["release", "nightly"] - image: ["alma9", "ubuntu22"] + image: ["alma9"] + stack: ["key4hep"] + include: + - build_type: nightly + image: ubuntu24 + stack: key4hep fail-fast: false - + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: key4hep/key4hep-actions/cache-external-data@main - uses: key4hep/key4hep-actions/key4hep-build@main with: build_type: ${{ matrix.build_type }} image: ${{ matrix.image }} + stack: ${{ matrix.stack }} diff --git a/include/ced_menu.h b/include/ced_menu.h index 69b666a..ec71996 100644 --- a/include/ced_menu.h +++ b/include/ced_menu.h @@ -317,20 +317,20 @@ class CED_SubSubMenu{ } - bool isAktive; - string title; - int optionNr; - bool isExtend; - bool isMouseOver; - int x_start; - int x_end; - int y_start; - int y_end; - - bool dead; + bool isAktive{}; + string title{}; + int optionNr{}; + bool isExtend{}; + bool isMouseOver{}; + int x_start{}; + int x_end{}; + int y_start{}; + int y_end{}; + + bool dead{}; private: - vector subsubMenus; + vector subsubMenus{}; }; @@ -483,21 +483,25 @@ class CED_SubMenu{ } } + CED_SubMenu(const CED_SubMenu&) = delete; + CED_SubMenu& operator=(const CED_SubMenu&) = delete; + CED_SubMenu(CED_SubMenu&&) = default; + CED_SubMenu& operator=(CED_SubMenu&&) = default; - string title; - int optionNr; - bool isExtend; - bool isMouseOver; - int x_start; - int x_end; - int y_start; - int y_end; + string title{}; + int optionNr{}; + bool isExtend{}; + bool isMouseOver{}; + int x_start{}; + int x_end{}; + int y_start{}; + int y_end{}; private: - CED_SubSubMenu *selected_submenu; - vector subsubMenus; + CED_SubSubMenu *selected_submenu{}; + vector subsubMenus{}; }; class CED_Menu{ @@ -644,8 +648,8 @@ class CED_Menu{ } private: - vector subMenus; - unsigned x_offset; + vector subMenus{}; + unsigned x_offset{}; }; class CED_PopUpMenu{ @@ -671,8 +675,7 @@ class CED_PopUpMenu{ unsigned maxlength=title.length(); - unsigned i; - for(i=0;(unsigned) ititle.length() > maxlength){ maxlength=subsubMenus.at(i)->title.length(); } @@ -727,8 +730,7 @@ class CED_PopUpMenu{ //selected_submenu->mouseOver(); } - unsigned i; - for(i=0;(unsigned) ix_start=x_start; subsubMenus.at(i)->x_end =x_end; subsubMenus.at(i)->y_start=y_start/*+height */+1+height*i; @@ -817,23 +819,29 @@ class CED_PopUpMenu{ //click_y= } + CED_PopUpMenu(const CED_PopUpMenu&) = delete; + CED_PopUpMenu& operator=(const CED_PopUpMenu&) = delete; + CED_PopUpMenu(CED_PopUpMenu&&) = default; + CED_PopUpMenu& operator=(CED_PopUpMenu&&) = default; + + int size(void){ return(subsubMenus.size()); } - string title; - int optionNr; - bool isExtend; - bool isMouseOver; - int x_start; - int x_end; - int y_start; - int y_end; - int x_click; - int y_click; + string title{}; + int optionNr{}; + bool isExtend{}; + bool isMouseOver{}; + int x_start{}; + int x_end{}; + int y_start{}; + int y_end{}; + int x_click{}; + int y_click{}; private: - vector subsubMenus; - CED_SubSubMenu *selected_submenu; + vector subsubMenus{}; + CED_SubSubMenu *selected_submenu{}; }; diff --git a/src/server/ced_srv.cc b/src/server/ced_srv.cc index 60c6516..abef8a3 100644 --- a/src/server/ced_srv.cc +++ b/src/server/ced_srv.cc @@ -66,7 +66,7 @@ extern int selected_layer; //#define IS_VISIBLE(x) ((1<<((x>>8)&0xff))&ced_visible_layers) //#define IS_VISIBLE(x) ((x < (CED_MAX_LAYER-1) && x >= 0)?ced_visible_layers[x]:false) -#define IS_VISIBLE(x) ((x < (CED_MAX_LAYER-1) && x >= 0)?setting.layer[x]:false) +#define IS_VISIBLE(x) ((x < (CED_MAX_LAYER-1) && (int)x >= 0)?setting.layer[x]:false) /* @@ -426,15 +426,15 @@ void drawPartialLineCylinder(double length, double R /*radius*/, double iR /*inn double phi2=360.0/edges*(i-1); if(360.0-phi <= angle_cut_off){ - double x = cos(2*PI/edges/2)/cos((360.0- (phi-360.0/edges/2)-angle_cut_off)*2*PI/360.0); + double xx = cos(2*PI/edges/2)/cos((360.0- (phi-360.0/edges/2)-angle_cut_off)*2*PI/360.0); if(outer_face){ //outer glBegin(GL_LINE_LOOP); glVertex3d(R*sin(phi2*2*PI/360.0), R*cos(phi2*2*PI/360.0),-length/2); glVertex3d(R*sin(phi2*2*PI/360.0), R*cos(phi2*2*PI/360.0),length/2); - glVertex3d(R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0), length/2); - glVertex3d(R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0), -length/2); + glVertex3d(R*xx*sin((360.0-angle_cut_off)*2*PI/360.0), R*xx*cos((360.0-angle_cut_off)*2*PI/360.0), length/2); + glVertex3d(R*xx*sin((360.0-angle_cut_off)*2*PI/360.0), R*xx*cos((360.0-angle_cut_off)*2*PI/360.0), -length/2); glEnd(); } @@ -444,8 +444,8 @@ void drawPartialLineCylinder(double length, double R /*radius*/, double iR /*inn glBegin(GL_LINE_LOOP); glVertex3d(iR*sin(phi2*2*PI/360.0), iR*cos(phi2*2*PI/360.0),-length/2); glVertex3d(iR*sin(phi2*2*PI/360.0), iR*cos(phi2*2*PI/360.0),length/2); - glVertex3d(iR*x*sin((360.0-angle_cut_off)*2*PI/360.0), iR*x*cos((360.0-angle_cut_off)*2*PI/360.0), length/2); - glVertex3d(iR*x*sin((360.0-angle_cut_off)*2*PI/360.0), iR*x*cos((360.0-angle_cut_off)*2*PI/360.0), -length/2); + glVertex3d(iR*xx*sin((360.0-angle_cut_off)*2*PI/360.0), iR*xx*cos((360.0-angle_cut_off)*2*PI/360.0), length/2); + glVertex3d(iR*xx*sin((360.0-angle_cut_off)*2*PI/360.0), iR*xx*cos((360.0-angle_cut_off)*2*PI/360.0), -length/2); glEnd(); } } @@ -490,9 +490,12 @@ void drawPartialLineCylinder(double length, double R /*radius*/, double iR /*inn */ struct my_point { - double x; - double y; - }; + // Constructor from two doubles which is necessary for c++17 + constexpr my_point(double xx, double yy) : x(xx), y(yy) {} + + double x; + double y; +}; struct T {double a; int b;}; @@ -667,15 +670,15 @@ void drawPartialCylinder(double length, double R /*radius*/, double iR /*inner r double phi2=360.0/edges*(i-1); if(360.0-phi <= angle_cut_off){ - double x = cos(2*PI/edges/2)/cos((360.0- (phi-360.0/edges/2)-angle_cut_off)*2*PI/360.0); + double xx = cos(2*PI/edges/2)/cos((360.0- (phi-360.0/edges/2)-angle_cut_off)*2*PI/360.0); if(outer_face == true){ //outer struct point3d p1 = {R*sin(phi2*2*PI/360.0), R*cos(phi2*2*PI/360.0),-length/2}; struct point3d p2 = {R*sin(phi2*2*PI/360.0), R*cos(phi2*2*PI/360.0),length/2}; - struct point3d p3 = {R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0), length/2}; - struct point3d p4 = {R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0), -length/2}; + struct point3d p3 = {R*xx*sin((360.0-angle_cut_off)*2*PI/360.0), R*xx*cos((360.0-angle_cut_off)*2*PI/360.0), length/2}; + struct point3d p4 = {R*xx*sin((360.0-angle_cut_off)*2*PI/360.0), R*xx*cos((360.0-angle_cut_off)*2*PI/360.0), -length/2}; struct point3d n; calNormals(n,p1,p2,p3); @@ -894,7 +897,7 @@ void drawPartialCylinder(double length, double R /*radius*/, double iR /*inner r //inner_side_points.push_back((my_point){iR*sin(360.0/edges*(i)*2*PI/360.0),iR*cos(360.0/edges*(i)*2*PI/360.0)}); - inner_side_points.push_back((my_point){iR*xl*sin((angle_cut_off_left)*2*PI/360.0),iR*xl*cos((angle_cut_off_left)*2*PI/360.0)}); + inner_side_points.emplace_back(iR*xl*sin((angle_cut_off_left)*2*PI/360.0), iR*xl*cos((angle_cut_off_left)*2*PI/360.0)); i=i+1; @@ -903,13 +906,13 @@ void drawPartialCylinder(double length, double R /*radius*/, double iR /*inner r phi=360.0/edges*i; if(360.0-phi <= angle_cut_off){ x = cos(2*PI/edges/2)/cos((360.0- (phi-360.0/edges/2)-angle_cut_off)*2*PI/360.0); - inner_side_points.push_back((my_point){iR*sin(360.0/edges*(i-1)*2*PI/360.0), iR*cos(360.0/edges*(i-1)*2*PI/360.0)}); - inner_side_points.push_back((my_point){iR*x*sin((360.0-angle_cut_off)*2*PI/360.0), iR*x*cos((360.0-angle_cut_off)*2*PI/360.0)}); + inner_side_points.emplace_back(iR*sin(360.0/edges*(i-1)*2*PI/360.0), iR*cos(360.0/edges*(i-1)*2*PI/360.0)); + inner_side_points.emplace_back(iR*x*sin((360.0-angle_cut_off)*2*PI/360.0), iR*x*cos((360.0-angle_cut_off)*2*PI/360.0)); break; }else{ if(i != 0){ - inner_side_points.push_back((my_point){iR*sin(360.0/edges*(i-1)*2*PI/360.0), iR*cos(360.0/edges*(i-1)*2*PI/360.0)}); - inner_side_points.push_back((my_point){iR*sin(phi*2*PI/360.0), iR*cos(phi*2*PI/360.0)}); + inner_side_points.emplace_back(iR*sin(360.0/edges*(i-1)*2*PI/360.0), iR*cos(360.0/edges*(i-1)*2*PI/360.0)); + inner_side_points.emplace_back(iR*sin(phi*2*PI/360.0), iR*cos(phi*2*PI/360.0)); } } } @@ -933,8 +936,8 @@ void drawPartialCylinder(double length, double R /*radius*/, double iR /*inner r - outer_side_points.push_back((my_point){R*xl*sin((angle_cut_off_left)*2*PI/360.0), R*xl*cos(angle_cut_off_left*2*PI/360.0)}); - outer_side_points.push_back((my_point){R*sin(360.0/edges*(i)*2*PI/360.0),R*cos(360.0/edges*(i)*2*PI/360.0)}); + outer_side_points.emplace_back(R*xl*sin((angle_cut_off_left)*2*PI/360.0), R*xl*cos(angle_cut_off_left*2*PI/360.0)); + outer_side_points.emplace_back(R*sin(360.0/edges*(i)*2*PI/360.0),R*cos(360.0/edges*(i)*2*PI/360.0)); i=i+1; @@ -944,21 +947,21 @@ void drawPartialCylinder(double length, double R /*radius*/, double iR /*inner r if(360.0-phi <= angle_cut_off){ x = cos(2*PI/edges/2)/cos((360.0- (phi-360.0/edges/2)-angle_cut_off)*2*PI/360.0); - outer_side_points.push_back((my_point){R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0)}); + outer_side_points.emplace_back(R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0)); //outer_side_points.push_back((my_point){R*x*sin((360.0-angle_cut_off)*2*PI/360.0), R*x*cos((360.0-angle_cut_off)*2*PI/360.0)}); break; }else{ - outer_side_points.push_back((my_point){R*sin(phi*2*PI/360.0), R*cos(phi*2*PI/360.0)}); + outer_side_points.emplace_back(R*sin(phi*2*PI/360.0), R*cos(phi*2*PI/360.0)); //if(i != 0){ // outer_side_points.push_back((my_point){R*sin(phi*2*PI/360.0), R*cos(phi*2*PI/360.0)}); //} } } - for(unsigned int i=0;iid > biggest_number_picking_text){ @@ -1669,28 +1672,28 @@ static void ced_draw_geotube(CED_GeoTube *c){ } for(; tmpz <= z0-2*(z0-z1); tmpz+=200){ - for(double tmpr=d_i; tmpr < d_o; tmpr+=600){ + for(double tmprr=d_i; tmprr < d_o; tmprr+=600){ for(double y=0;y<2*3.14-2*3.14*cut_angle/360.;y+=0.20){ //z0 left end //z1 middle //right z0-2*(z0-z1) CED_Point tmp2; - tmp2.x = tmpr*sin(y); - tmp2.y = tmpr*cos(y); + tmp2.x = tmprr*sin(y); + tmp2.y = tmprr*cos(y); tmp2.z = tmpz; ced_add_objmap(&tmp2,20,0,c->type,1 ); } } - for(double tmpr=d_i+300; tmpr < d_o; tmpr+=600){ + for(double tmprr=d_i+300; tmprr < d_o; tmprr+=600){ for(double y=0.1;y<2*3.14-2*3.14*cut_angle/360.;y+=0.20){ //z0 left end //z1 middle //right z0-2*(z0-z1) CED_Point tmp2; - tmp2.x = tmpr*sin(y); - tmp2.y = tmpr*cos(y); + tmp2.x = tmprr*sin(y); + tmp2.y = tmprr*cos(y); tmp2.z = tmpz; ced_add_objmap(&tmp2,20,0,c->type,1 ); @@ -2417,7 +2420,7 @@ static void ced_draw_legend(CED_Legend *legend){ break; /** LIN */ case 'b': - strncpy( footer, "LIN", 3 ); + strncpy( footer, "LIN", 4 ); renderBitmapString(x_min-x_offset_legend,y_min-y_offset_legend, font, footer); glEnd(); break; diff --git a/src/server/glced.cc b/src/server/glced.cc index 222fff4..fad86be 100644 --- a/src/server/glced.cc +++ b/src/server/glced.cc @@ -76,6 +76,7 @@ #include #include #include +#include static GLfloat window_width=0.; static GLfloat window_height=0.; @@ -506,8 +507,8 @@ void printFPS(void){ GLfloat w=glutGet(GLUT_SCREEN_WIDTH); GLfloat h=glutGet(GLUT_SCREEN_HEIGHT); ; - int WORLD_SIZE=1000; //static worldsize maybe will get problems in the future... - glOrtho(-WORLD_SIZE*w/h,WORLD_SIZE*w/h,-WORLD_SIZE,WORLD_SIZE, -15*WORLD_SIZE,15*WORLD_SIZE); + int world_size=1000; //static worldsize maybe will get problems in the future... + glOrtho(-world_size*w/h,world_size*w/h,-world_size,world_size, -15*world_size,15*world_size); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -537,6 +538,27 @@ void printFPS(void){ glMatrixMode(GL_MODELVIEW); glPopMatrix(); } + +std::string truncateTo(std::string str, size_t max_len) { + if (str.size() >= max_len) { + auto truncStr = str.substr(0, max_len); + truncStr[max_len-3] = '.'; + truncStr[max_len-2] = '.'; + truncStr[max_len-1] = '.'; + return truncStr; + } + return str; +} + +std::string formatShortcut(int iLayer, const char key, const char *description, + size_t max_len) { + std::stringstream sstr; + sstr << "(" << (isLayerVisible(iLayer) ? "X" : "_") << ") [" << key << "] " + << std::setfill('0') << std::setw(2) << iLayer << ": " << description; + + return truncateTo(sstr.str(), max_len); +} + void printShortcuts(void){ const unsigned int MAX_STR_LEN=30; @@ -602,31 +624,15 @@ void printShortcuts(void){ shortcuts.push_back( "DATA LAYERS:" ); - char label[MAX_STR_LEN+1]; - for(i=0;i= MAX_STR_LEN){ - label[MAX_STR_LEN-3]='.'; - label[MAX_STR_LEN-2]='.'; - label[MAX_STR_LEN-1]='.'; - label[MAX_STR_LEN]=0; - } - shortcuts.push_back(label); + shortcuts.emplace_back(formatShortcut(i, layer_keys[i], layerDescription[i], MAX_STR_LEN)); } shortcuts.push_back( " " ); shortcuts.push_back( "DETECTOR LAYERS: " ); for(i=NUMBER_DATA_LAYER;i= MAX_STR_LEN){ - label[MAX_STR_LEN-3]='.'; - label[MAX_STR_LEN-2]='.'; - label[MAX_STR_LEN-1]='.'; - label[MAX_STR_LEN]=0; - } - shortcuts.push_back(label); + shortcuts.emplace_back(formatShortcut(i, detec_layer_keys[-1 * NUMBER_DATA_LAYER + i], layerDescription[i], MAX_STR_LEN)); } glMatrixMode(GL_PROJECTION); @@ -647,13 +653,13 @@ void printShortcuts(void){ GLfloat w=glutGet(GLUT_WINDOW_WIDTH); GLfloat h=glutGet(GLUT_WINDOW_HEIGHT); ; - int WORLD_SIZE=1000; //static worldsize maybe will get problems in the future... + int world_size=1000; //static worldsize maybe will get problems in the future... //glOrtho(0,w,h, 0,0,15*WORLD_SIZE); //glOrtho(0,w,h,-10,0,15*WORLD_SIZE); - glOrtho(0,w,h,-1*height,0,15*WORLD_SIZE); + glOrtho(0,w,h,-1*height,0,15*world_size); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -1430,7 +1436,7 @@ void loadSettings(int slot){ -void mouseWheel(int button, int dir, int x, int y){ //hauke +void mouseWheel(int, int dir, int, int ){ //hauke if(dir > 0){ selectFromMenu(VIEW_ZOOM_IN); }else{ @@ -1894,7 +1900,7 @@ static void keypressed(unsigned char key, int x, int y) { } } -static void SpecialKey( int key, int x, int y ){ +static void SpecialKey( int key, int, int ){ switch (key) { case GLUT_KEY_RIGHT: mm.mv.z+=50.; @@ -1973,7 +1979,7 @@ static void motion(int x,int y){ glutPostRedisplay(); } -static void timer (int val) +static void timer (int) { //change timer for testing to 1 fd_set fds; @@ -2230,7 +2236,7 @@ void toggleHelpWindow(void){ //hauke // glutSetWindow(mainWindow); } -void updateLayerEntryInPopupMenu(int id){ //id is layer id, not menu id! +void updateLayerEntryInPopupMenu(int){ //id is layer id, not menu id! // char string[200]; // char tmp[41]; // if(id < 0 || id > NUMBER_POPUP_LAYER-1){ @@ -2267,7 +2273,7 @@ void updateScreenshotMenu(void){ // glutChangeToMenuEntry(5,tmp,SAVE_IMAGE100); // } -void updateSaveLoadMenu(int id){ //id is save id, not menu id! +void updateSaveLoadMenu(int){ //id is save id, not menu id! // struct stat s; // // @@ -2291,7 +2297,7 @@ void updateSaveLoadMenu(int id){ //id is save id, not menu id! } -void updateLayerEntryDetector(int id){ //id is layer id, not menu id! +void updateLayerEntryDetector(int){ //id is layer id, not menu id! // char string[200]; // char tmp[101]; // if(id < NUMBER_DATA_LAYER || id > NUMBER_DETECTOR_LAYER+NUMBER_DATA_LAYER-1 || id > CED_MAX_LAYER-1 || id < 0){ @@ -2394,10 +2400,10 @@ void selectFromMenu(int id){ //hauke if(!ced_picking(popupmenu->x_click,popupmenu->y_click ,&mm.mv.x,&mm.mv.y,&mm.mv.z)){ struct __glutSocketList *sock; sock=__glutSockets; - int id = SELECTED_ID; + int sel_id = SELECTED_ID; //printf(" ced_get_selected : socket connected: %d", sock->fd ); if(client_connected){ - send( sock->fd , &id , sizeof(int) , 0 ); + send( sock->fd , &sel_id , sizeof(int) , 0 ); } } break; @@ -2534,7 +2540,7 @@ void selectFromMenu(int id){ //hauke case BGCOLOR_USER: set_bg_color(userDefinedBGColor[0],userDefinedBGColor[1], userDefinedBGColor[2], userDefinedBGColor[3]); - + [[fallthrough]]; case VIEW_RESET: setting.phi_projection = false; // no phi projection @@ -3520,9 +3526,9 @@ void buildPopUpMenu(int x, int y){ } popupmenu->addItem(phicuts); - char tmp[200]; - snprintf(tmp,199,"Z-cut (%.0f)",setting.detector_cut_z[layer-NUMBER_DATA_LAYER]); - CED_SubSubMenu *zcuts=new CED_SubSubMenu(tmp); + char new_tmp[200]; + snprintf(new_tmp,199,"Z-cut (%.0f)",setting.detector_cut_z[layer-NUMBER_DATA_LAYER]); + CED_SubSubMenu *zcuts=new CED_SubSubMenu(new_tmp); zcuts->addItem(new CED_SubSubMenu("Cut at z=-6000", LAYER_CUT_Z_M6000)); zcuts->addItem(new CED_SubSubMenu("Cut at z=-4000", LAYER_CUT_Z_M4000)); zcuts->addItem(new CED_SubSubMenu("Cut at z=-2000", LAYER_CUT_Z_M2000)); @@ -3542,8 +3548,8 @@ void buildPopUpMenu(int x, int y){ - snprintf(tmp,199,"Transparency (%.0f)",100*setting.detector_trans[layer-NUMBER_DATA_LAYER]); - CED_SubSubMenu *trans=new CED_SubSubMenu(tmp); + snprintf(new_tmp,199,"Transparency (%.0f)",100*setting.detector_trans[layer-NUMBER_DATA_LAYER]); + CED_SubSubMenu *trans=new CED_SubSubMenu(new_tmp); trans->addItem(new CED_SubSubMenu(" 0%",LAYER_TRANS0)); trans->addItem(new CED_SubSubMenu(" 40%", LAYER_TRANS40)); trans->addItem(new CED_SubSubMenu(" 60%", LAYER_TRANS60)); @@ -3660,6 +3666,27 @@ void buildPopUpMenu(int x, int y){ popupmenu->x_click=x; // cout << "TODO: x,y: " << x << ", " << y << endl; } + + +std::string formatSubmenuEntry(int iLayer, const char key, + const char *description, size_t max_len) { + std::stringstream sstr; + sstr << (isLayerVisible(iLayer) ? "[X]" : "[ ]") << " " << std::setfill('0') + << std::setw(2) << iLayer; + + // truncate the string such that the description has length max_len + // i.e. add the other chars to the length of the final string + int padding = 7; + + if (key != '0') { + sstr << " [" << key << "]"; + padding = 11; + } + sstr << ": " << description; + + return truncateTo(sstr.str(), max_len + padding); +} + void buildLayerMenus(void){ //std::cout << "enter buildLayerMenus" << std::endl; //if(ced_menu != NULL && detectorlayermenu != NULL && datalayermenu != NULL){ @@ -3669,33 +3696,12 @@ void buildLayerMenus(void){ detectorlayermenu=new CED_SubSubMenu("Detector layers",0); datalayermenu=new CED_SubSubMenu("Data layers",0); int i; - char str[2000]; - unsigned max=150; - char tmp[max+1]; + constexpr unsigned max=150; for(i=0;i max-1){ - snprintf(tmp,max-3,"%s",layerDescription[i]); - sprintf(tmp,"%s...",tmp); - }else{ - sprintf(tmp,"%s",layerDescription[i]); - } - - sprintf(str,"%s %s%i [%c]: %s", isLayerVisible(i)?"[X]":"[ ]", (i < 10)?" ":"" ,i, layer_keys[i], tmp); - //std::cout << str << std::endl; - datalayermenu->addItem(new CED_SubSubMenu(str,LAYER_0+i)); + datalayermenu->addItem(new CED_SubSubMenu(formatSubmenuEntry(i, layer_keys[i], layerDescription[i], max), LAYER_0+i)); } for(i=NUMBER_DATA_LAYER;i max){ - snprintf(tmp,max-3,"%s",layerDescription[i]); - sprintf(tmp,"%s...",tmp); - }else{ - sprintf(tmp,"%s",layerDescription[i]); - } - - sprintf(str,"%s %s%i: %s", isLayerVisible(i)?"[X]":"[ ]",(i < 10)?" ":"" ,i, layerDescription[i]); - detectorlayermenu->addItem(new CED_SubSubMenu(str,DETECTOR1+i-NUMBER_DATA_LAYER)); + detectorlayermenu->addItem(new CED_SubSubMenu(formatSubmenuEntry(i, '0', layerDescription[i], max), DETECTOR1+i-NUMBER_DATA_LAYER)); } @@ -3724,8 +3730,8 @@ void buildMainMenu(void){ layers->addItem(new CED_SubSubMenu("---", AXES)); bool result=true; - for(int i=0;i 100){ std::cout << "Sorry 100x100 are the max value" << std::endl ;