void elvis_CB( Widget w , XtPointer cd , XtPointer cb ) { XmDrawingAreaCallbackStruct * cbs = (XmDrawingAreaCallbackStruct *) cb ; XExposeEvent * ev = (XExposeEvent *) cbs->event ; int start , end ; static int ncall = 0 ; if( cbs->reason != XmCR_EXPOSE || ev->count > 0 ) return ; STATUS("enter elvis_CB") ; if( need_plot ){ make_plot() ; set_X11_background( XtDisplay(w) , XtWindow(w) , 255,255,255 ) ; } XClearWindow( XtDisplay(w) , XtWindow(w) ) ; #if 1 if( ncall%2 == 0 ) set_active_memplot( "Elvis" ) ; else set_active_memplot( "Pelvis" ) ; ncall++ ; #endif STATUS("XClearWindow") ; start = end = 0 ; #if 0 memplot_to_X11( XtDisplay(w) , XtWindow(w) ) ; #else memplot_to_X11_free( XtDisplay(w) , XtWindow(w) ) ; #endif return ; }
int main(int argc, char *argv[]) { RGBPic *p; PLOT *plot; p=make_RGBPic(800,600); RGBPic_clear_area(p,COLOR(60,80,50),0,0,p->width,p->height); plot=make_plot(640,480); plot->lower_x=3.1415; plot->upper_x=12423; plot->lower_y=2.34E-10; plot->upper_y=43.5E-8; draw_grid(p,plot,50,50); free_plot(plot); //RGBPic_printf(p,30,30,COLOR(255,240,210),COLOR(1,2,3),"Hello all !\n line 2 %d %p",argc,p); //RGBPic_printf_v(p,300,300,COLOR(255,240,210),COLOR(1,2,3),"Hello all 2 !\n line 2 %d %p",argc,p); RGBPic_draw_line(p,COLOR(40,255,80), 40,50,60,70); RGBPic_draw_line(p,COLOR(250,255,80), 30,50,60,30); RGBPic_dump_ppm("test1.ppm",p); free_RGBPic(p); return 0; }
int main(int argc, char** argv) { // -------------------------------------------------------------------- // get job files and program options std::vector<std::string> vecScans; std::string strOutFile; bool bFlip = 0; std::string strVec0, strVec1; t_vec vec0, vec1; // normal args opts::options_description args("Extracts scan positions into a figure"); args.add(boost::shared_ptr<opts::option_description>( new opts::option_description("scan-file", opts::value<decltype(vecScans)>(&vecScans), "scan file"))); args.add(boost::shared_ptr<opts::option_description>( new opts::option_description("flip-y", opts::bool_switch(&bFlip), "flip y axis"))); args.add(boost::shared_ptr<opts::option_description>( new opts::option_description("out-file", opts::value<decltype(strOutFile)>(&strOutFile), "output file"))); args.add(boost::shared_ptr<opts::option_description>( new opts::option_description("vec0", opts::value<decltype(strVec0)>(&strVec0), "first scattering plane vector"))); args.add(boost::shared_ptr<opts::option_description>( new opts::option_description("vec1", opts::value<decltype(strVec1)>(&strVec1), "second scattering plane vector"))); // positional args opts::positional_options_description args_pos; args_pos.add("scan-file", -1); opts::basic_command_line_parser<char> clparser(argc, argv); clparser.options(args); clparser.positional(args_pos); opts::basic_parsed_options<char> parsedopts = clparser.run(); opts::variables_map opts_map; opts::store(parsedopts, opts_map); opts::notify(opts_map); if(argc <= 1) { std::ostringstream ostrHelp; ostrHelp << "Usage: " << argv[0] << " [options] <scan-file 1> <scan-file 2> ... <scan-file n>\n"; ostrHelp << args; tl::log_info(ostrHelp.str()); return -1; } if(vecScans.size() == 0) { tl::log_err("No scan files given."); return -1; } if(strVec0.size()) vec0 = tl::str_to_var<decltype(vec0)>("[3](" + strVec0 + ")"); if(strVec1.size()) vec1 = tl::str_to_var<decltype(vec1)>("[3](" + strVec1 + ")"); // -------------------------------------------------------------------- // first scan file serves as reference std::unique_ptr<tl::FileInstrBase<t_real>> ptrScan( tl::FileInstrBase<t_real>::LoadInstr(vecScans[0].c_str())); if(!ptrScan) { tl::log_err("Invalid scan file: \"", vecScans[0], "\"."); return -1; } // get scattering plane if not already given as program arg if(vec0.size() != 3) { auto arrVec0 = ptrScan->GetScatterPlane0(); vec0 = tl::make_vec<t_vec>({arrVec0[0],arrVec0[1],arrVec0[2]}); } if(vec1.size() != 3) { auto arrVec1 = ptrScan->GetScatterPlane1(); vec1 = tl::make_vec<t_vec>({arrVec1[0],arrVec1[1],arrVec1[2]}); } if(bFlip) vec1 = -vec1; tl::log_info("Scattering plane: ", vec0, ", ", vec1, "."); std::vector<t_vec> vecAllHKL, vecAllPos; vecAllHKL.reserve(argc-2); vecAllPos.reserve(argc-2); // first scan position auto vecPos = get_coord<t_vec, t_real>(vec0, vec1, *ptrScan); tl::log_info(vecPos.first, " rlu -> ", vecPos.second, "."); if(vecPos.second.size() != 2) { tl::log_err("Invalid scan position for file \"", vecScans[0], "\"."); return -1; } vecAllHKL.push_back(vecPos.first); vecAllPos.push_back(vecPos.second); // load other files for(int iFile=1; iFile<vecScans.size(); ++iFile) { std::unique_ptr<tl::FileInstrBase<t_real>> ptrScanOther( tl::FileInstrBase<t_real>::LoadInstr(vecScans[iFile].c_str())); if(!ptrScanOther) { tl::log_err("Invalid scan file: \"", vecScans[iFile], "\"."); continue; } // remaining scan positions auto vecPosOther = get_coord<t_vec, t_real>(vec0, vec1, *ptrScanOther); tl::log_info(vecPos.first, " rlu -> ", vecPos.second, "."); if(vecPosOther.second.size() != 2) { tl::log_err("Invalid scan position for file \"", vecScans[iFile], "\"."); continue; } vecAllHKL.push_back(vecPosOther.first); vecAllPos.push_back(vecPosOther.second); } if(!make_plot(strOutFile, vec0, vec1, vecAllHKL, vecAllPos, bFlip)) { tl::log_err("No scan positions found."); return -1; } return 0; }