void WinEDA_MainFrame::RecreateBaseHToolbar(void) /***************************************************/ { if ( m_HToolBar != NULL ) return; m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); SetToolBar(m_HToolBar); // Set up toolbar m_HToolBar->AddTool(ID_NEW_PROJECT, BITMAP(new_project_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Create new project descriptor")); m_HToolBar->AddTool(ID_LOAD_PROJECT, BITMAP(open_project_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Select an existing project descriptor")); m_HToolBar->AddTool(ID_SAVE_PROJECT, BITMAP(save_project_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Save current project descriptor")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_SAVE_AND_ZIP_FILES, BITMAP(zip_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Archive all project files")); // after adding the buttons to the toolbar, must call Realize() to reflect // the changes m_HToolBar->Realize(); }
static void DoPrintPrint( void * junk ) /* * Called when print:print button is clicked. * Print all the printable pages and mark them * non-print. */ { wIndex_t x, y; int copy, copies; long noDecoration; if (pageCount == 0) { NoticeMessage( MSG_PRINT_NO_PAGES, _("Ok"), NULL ); return; } wPrefGetInteger( "print", "nodecoration", &noDecoration, 0 ); print_d.CoOrd2Pix = page_d.CoOrd2Pix = mainD.CoOrd2Pix; wSetCursor( wCursorWait ); if (!wPrintDocStart( Title1, pageCount, &copies )) { wSetCursor( wCursorNormal ); return; } if (copies <= 0) copies = 1; for ( copy=1; copy<=copies; copy++) { if ( printOrder == 0 ) { for (x=bm.x0; x<bm.x1; x++) for (y=bm.y1-1; y>=bm.y0; y--) if (!PrintPage( x, y )) goto quitPrinting; } else { for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) if (!PrintPage( x, y )) goto quitPrinting; } for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) if (BITMAP(bm,x,y)) { if (copy < copies) MarkPage( x, y ); else BITMAP(bm,x,y) = 0; } } quitPrinting: wPrintDocEnd(); wSetCursor( wCursorNormal ); Reset(); /* undraws grid, resets pagecount, etc */ }
void WinEDA_GerberFrame::ReCreateOptToolbar(void) /************************************************/ { if ( m_OptionsToolBar ) return; // creation du tool bar options m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, BITMAP(grid_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Display Grid OFF")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, BITMAP(polar_coord_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Display Polar Coord ON")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, "", BITMAP(unit_inch_xpm), _("Units = Inch"), wxITEM_CHECK ); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, "", BITMAP(unit_mm_xpm), _("Units = mm"), wxITEM_CHECK ); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, BITMAP(cursor_shape_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Change Cursor Shape")); m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, BITMAP(pad_sketch_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Show Spots Sketch")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, BITMAP(showtrack_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Show Lines Sketch")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_DCODES, BITMAP(show_dcodenumber_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Show dcode number")); m_OptionsToolBar->Realize(); SetToolbars(); }
void WinEDA_ModuleEditFrame::ReCreateOptToolbar(void) /*********************************************************/ { if ( m_OptionsToolBar ) return; // creation du tool bar options m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, BITMAP(grid_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Display Grid OFF")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, BITMAP(polar_coord_xpm), _("Display Polar Coord ON"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, BITMAP(unit_inch_xpm), _("Units = Inch"), wxITEM_CHECK ); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, BITMAP(unit_mm_xpm), _("Units = mm"), wxITEM_CHECK ); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, BITMAP(cursor_shape_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Change Cursor Shape")); m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH, BITMAP(pad_sketch_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Show Pads Sketch")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, BITMAP(text_sketch_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Show Texts Sketch")); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, BITMAP(show_mod_edge_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Show Edges Sketch")); m_OptionsToolBar->Realize(); SetToolbars(); }
void WinEDA_PcbFrame::ReCreateAuxVToolbar(void) /*********************************************/ /* Create the auxiliary vertical right toolbar, showing tools fo microwave applications */ { if( m_AuxVToolBar ) return; m_AuxVToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_AUX_V_TOOLBAR, FALSE); // Set up toolbar m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_SELF_CMD, BITMAP(mw_Add_Line_xpm), wxNullBitmap, TRUE, -1,-1, (wxObject *) NULL, _("Create line of specified length for microwave applications") ); m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_GAP_CMD, BITMAP(mw_Add_Gap_xpm), wxNullBitmap, TRUE, -1,-1, (wxObject *) NULL, _("Create gap of specified length for microwave applications") ); m_AuxVToolBar->AddSeparator(); m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_STUB_CMD, BITMAP(mw_Add_Stub_xpm), wxNullBitmap, TRUE, -1,-1, (wxObject *) NULL, _("Create stub of specified length for microwave applications") ); m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_STUB_ARC_CMD, BITMAP(mw_Add_stub_arc_xpm), wxNullBitmap, TRUE, -1,-1, (wxObject *) NULL, _("Create stub (arc) of specified length for microwave applications") ); m_AuxVToolBar->AddTool(ID_PCB_MUWAVE_TOOL_FUNCTION_SHAPE_CMD, BITMAP(mw_Add_Shape_xpm), wxNullBitmap, TRUE, -1,-1, (wxObject *) NULL, _("Create a polynomial shape for microwave applications") ); m_AuxVToolBar->Realize(); SetToolbars(); }
static void PrintClear( void ) /* * Called when print:clear button is clicked. * Flip the status of all printable pages * (Thus making them non-print) */ { wIndex_t x, y; for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) if (BITMAP(bm,x,y)) { BITMAP(bm,x,y) = 0; MarkPage( x, y ); } pageCount = 0; ParamLoadMessage( &printPG, I_PAGECNT, _("0 pages") ); ParamDialogOkActive( &printPG, FALSE ); }
/* * function: make dependency check, for make sure the pwr dependency is reasonable. * return 0: if reasonable. * -1: if not reasonable. */ static int check_cfg(void) { int ret = 0; int i = 0; //make sure bus parent is exist. if (0 != temp_standby_data.cpux_clk_state.bus_change) { for (i=0; i<BUS_NUM; i++) { if((CLK_SRC_LOSC == temp_standby_data.cpux_clk_state.bus_factor[i].src) &&\ !(temp_standby_data.cpux_clk_state.osc_en & BITMAP(OSC_LOSC_BIT)) ){ ret = -1; } if((CLK_SRC_HOSC == temp_standby_data.cpux_clk_state.bus_factor[i].src) &&\ !(temp_standby_data.cpux_clk_state.osc_en & BITMAP(OSC_HOSC_BIT)) ){ ret = -2; } if((CLK_SRC_PLL6 == temp_standby_data.cpux_clk_state.bus_factor[i].src) &&\ !(temp_standby_data.cpux_clk_state.init_pll_dis & BITMAP(PM_PLL_PERIPH)) ){ ret = -3; } } } //check hold_flag is reasonable. if(1 == temp_standby_data.soc_io_state.hold_flag && \ (temp_standby_data.soc_pwr_dm_state.state & temp_standby_data.soc_pwr_dm_state.sys_mask & BITMAP(VDD_SYS_BIT))){ ret = -11; //when vdd_sys is ON, no need to set hold_flag; } //make sure selfresh flag is reasonable if(0 == temp_standby_data.soc_dram_state.selfresh_flag){ //when selfresh is disable, then VDD_SYS_BIT is needed if(!(temp_standby_data.soc_pwr_dm_state.state & temp_standby_data.soc_pwr_dm_state.sys_mask & BITMAP(VDD_SYS_BIT))){ ret = -21; } } if(-1 == ret){ printk("func: %s, ret = %d. \n", __func__, ret); dump_stack(); } return ret; }
static void SelectPage( coOrd pos ) { int x, y; BOOL_T selected; /*PrintUpdate();*/ pos.x -= currPrintGrid.orig.x; pos.y -= currPrintGrid.orig.y; Rotate( &pos, zero, -currPrintGrid.angle ); x = (int)floor(pos.x/currPrintGrid.size.x); y = (int)floor(pos.y/currPrintGrid.size.y); if ( x<bm.x0 || x>=bm.x1 || y<bm.y0 || y>=bm.y1) return; selected = BITMAP( bm, x, y ); pageCount += (selected?-1:1); BITMAP( bm, x, y ) = !selected; MarkPage( x, y ); sprintf( message, _("%d pages"), pageCount ); ParamLoadMessage( &printPG, I_PAGECNT, message ); ParamDialogOkActive( &printPG, pageCount!=0 ); }
void WinEDA_MainFrame::CreateCommandToolbar(void) /*************************************************/ { #define SEPAR 20 int sizex, sizey,width; wxBitmapButton * Butt; wxPoint pos; // delete and recreate the toolbar if( m_VToolBar ) return; m_CommandWin->GetClientSize(&sizex, &sizey); width = 300; // Set up toolbar width = 32; pos.x = 20; pos.y = 20; Butt = new wxBitmapButton(m_CommandWin, ID_TO_EESCHEMA, BITMAP(icon_eeschema_xpm), pos ); Butt->SetToolTip(_("EeSchema (Schematic editor)")); pos.x += width + SEPAR; Butt = new wxBitmapButton(m_CommandWin,ID_TO_CVPCB, BITMAP(icon_cvpcb_xpm), pos ); Butt->SetToolTip(_("Cvpcb (Componants to modules)")); pos.x += width + SEPAR; Butt = new wxBitmapButton(m_CommandWin, ID_TO_PCB, BITMAP(a_icon_pcbnew_xpm), pos ); Butt->SetToolTip(_("Pcbnew ( board editor )")); pos.x += width + SEPAR; Butt = new wxBitmapButton(m_CommandWin, ID_TO_GERBVIEW, BITMAP(icon_gerbview_xpm), pos ); Butt->SetToolTip(_("GerbView ( Gerber viewer )")); }
void WinEDA_ModuleEditFrame::ReCreateVToolbar(void) /********************************************************/ { if( m_VToolBar ) return; m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); // Set up toolbar m_VToolBar->AddTool(ID_NO_SELECT_BUTT, wxEmptyString, BITMAP(cursor_xpm), wxEmptyString, wxITEM_CHECK ); m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_MODEDIT_ADD_PAD, wxEmptyString, BITMAP(pad_xpm), _("Add Pads"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_LINE_COMMENT_BUTT, wxEmptyString, BITMAP(add_polygon_xpm), _("Add graphic line or polygon"), wxITEM_CHECK); m_VToolBar->AddTool(ID_PCB_CIRCLE_BUTT, wxEmptyString, BITMAP(add_circle_xpm), _("Add graphic circle"), wxITEM_CHECK); m_VToolBar->AddTool(ID_PCB_ARC_BUTT, wxEmptyString, BITMAP(add_arc_xpm), _("Add graphic arc"), wxITEM_CHECK); m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, wxEmptyString, BITMAP(add_text_xpm), _("Add Text"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_MODEDIT_PLACE_ANCHOR, wxEmptyString, BITMAP(anchor_xpm), _("Place anchor"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_MODEDIT_DELETE_ITEM_BUTT, wxEmptyString, BITMAP(delete_body_xpm), _("Delete items"), wxITEM_CHECK); m_VToolBar->Realize(); SetToolbars(); }
void DumpMap( char * f, ANGLE_T a, ANGLE_T b ) { wIndex_t x, y; lprintf( f, a, b ); for (y=bm.y1-1; y>=bm.y1; y--) { for (x=bm.x0; x<bm.x1; x++) if (BITMAP(bm,x,y)) { lprintf( "X"); } else { lprintf( " "); } lprintf( "\n"); } }
static void DrawPrintGrid( void ) /* * Draw a grid using currPrintGrid.orig, currPrintGrid.angle, currPrintGrid.size. * Drawing it twice erases the grid. * Also hilite any marked pages. */ { wIndex_t x, y; DrawGrid( &tempD, &mapD.size, currPrintGrid.size.x, currPrintGrid.size.y, 0, 0, currPrintGrid.orig, currPrintGrid.angle, wDrawColorBlack, TRUE ); for (y=bm.y0; y<bm.y1; y++) for (x=bm.x0; x<bm.x1; x++) if (BITMAP(bm,x,y)) { MarkPage( x, y ); } }
void WinEDA_GerberFrame::ReCreateVToolbar(void) /**********************************************/ { if( m_VToolBar ) return; m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); // Set up toolbar m_VToolBar->AddTool(ID_NO_SELECT_BUTT, BITMAP(cursor_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL ); m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT,TRUE); #if 0 m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_COMPONENT_BUTT, BITMAP(component_button), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Add Flashes")); m_VToolBar->AddTool(ID_BUS_BUTT, BITMAP(bus_button), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Add Lines")); m_VToolBar->AddTool(ID_JUNCTION_BUTT, BITMAP(junction_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Add Mires")); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, BITMAP(tool_text_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Add Text")); #endif m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_PCB_DELETE_ITEM_BUTT, BITMAP(delete_body_xpm), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, _("Delete items")); m_VToolBar->Realize(); SetToolbars(); }
static void emit_bitmap(FILE *f, int beg, int end, const char *name) { int i, n, row; unsigned char buffer[10000]; const int small = (beg >= 256) ? 1 : 0; for (n=0, i=beg; i<end; i++) n += WIDTH(charset[i&0xff].bitrows[small]) - 1; fprintf(f, "\tstatic const unsigned char %s[6][%d] = {\n", name, (n+7)/8); for (row=0; row<6; row++) { int l = 0; int base = 0; int b; fprintf(f, "\t\t{\n\t\t\t"); for (i=0; i<10000; i++) buffer[i] = 0; for (i=beg; i<end; i++) { const int width = WIDTH(charset[i&0xff].bitrows[small]); const int bitrow = charset[i&0xff].bitrows[2 * row+small]; /* Sanity check the width of this character */ if (WIDTH(bitrow) != width) { fprintf(stderr, "Character %04o bitmap row %d has wrong width of %d (should be %d)\n", i, row+1, WIDTH(bitrow), width); exit(1); } for (b=0; b<width-1; b++, base++) { if (BITMAP(bitrow) & (1 << b)) buffer[base / 8] |= (1 << (base % 8)); } } for (i=0; i< (n+7)/8; i++) { fprintf(f, "%3u,%s", buffer[i], (l++ % 12) == 11 ? "\n\t\t\t" : " "); } fprintf(f, "\n\t\t},\n"); } fprintf(f, "\t};\n"); }
int frmMain::_l_init_with_lua_app(lua_State *L) { lua_rawgeti(L, LUA_ENVIRONINDEX, 1); frmMain *pThis = reinterpret_cast<frmMain*>(lua_touserdata(L, -1)); lua_pop(L, 1); lua_getfield(L, 1, "getBitmapDir"); lua_pushvalue(L, 1); lua_call(L, 1, 1); wxString sBitmapDir = lua_tostring(L, -1); lua_pop(L, 1); wxRibbonPage* pHomePage = pThis->m_pHomePage; wxRibbonPanel* pFilePanel = new wxRibbonPanel(pHomePage, wxID_ANY, wxT("File")); wxRibbonButtonBar* pFileButtons = new FullSizeButtonBar(pFilePanel, wxID_ANY); #define BITMAP(name) wxBitmap(sBitmapDir + (wxT(name) wxT("32.png")), wxBITMAP_TYPE_PNG) pFileButtons->AddButton(wxID_NEW, wxT("New"), BITMAP("new")); pFileButtons->AddButton(wxID_OPEN, wxT("Load"), BITMAP("open")); pFileButtons->AddHybridButton(wxID_SAVE, wxT("Save"), BITMAP("save")); wxRibbonPanel* pViewPanel = new wxRibbonPanel(pHomePage, wxID_ANY, wxT("View")); wxRibbonButtonBar* pViewButtons = new FullSizeButtonBar(pViewPanel, wxID_ANY); pViewButtons->AddToggleButton(ID_VIEW_WALLS, wxT("Walls"), BITMAP("transparent_walls")); pViewButtons->ToggleButton(ID_VIEW_WALLS, pThis->m_bViewWalls = true); pViewButtons->AddToggleButton(ID_VIEW_FLAGS, wxT("Flags"), BITMAP("flags")); pViewButtons->ToggleButton(ID_VIEW_FLAGS, pThis->m_bViewFlags = false); pViewButtons->AddToggleButton(ID_VIEW_PARCELS, wxT("Parcels"), BITMAP("parcels")); pViewButtons->ToggleButton(ID_VIEW_PARCELS, pThis->m_bViewParcels = false); #undef BITMAP pThis->m_pRibbon->Realise(); return 0; }
static void ChangeDim( void ) { int x, y, x0, x1, y0, y1; coOrd p0; int size; bitmap_t tmpBm; BOOL_T selected; MapGrid( zero, mapD.size, 0.0, currPrintGrid.orig, currPrintGrid.angle, currPrintGrid.size.x, currPrintGrid.size.y, &x0, &x1, &y0, &y1 ); #ifdef LATER d0 = sqrt( mapD.size.x * mapD.size.x + mapD.size.y * mapD.size.y ); Translate( &p1, currPrintGrid.orig, currPrintGrid.angle, d0 ); p0 = currPrintGrid.orig; ClipLine( &p0, &p1, zero, 0.0, mapD.size ); d1 = FindDistance( currPrintGrid.orig, p1 ); y1 = (int)ceil(d1/currPrintGrid.size.y); Translate( &p1, currPrintGrid.orig, currPrintGrid.angle+180, d0 ); p0 = currPrintGrid.orig; ClipLine( &p0, &p1, zero, 0.0, mapD.size ); d1 = FindDistance( currPrintGrid.orig, p1 ); y0 = -(int)floor(d1/currPrintGrid.size.y); Translate( &p1, currPrintGrid.orig, currPrintGrid.angle+90, d0 ); p0 = currPrintGrid.orig; ClipLine( &p0, &p1, zero, 0.0, mapD.size ); d1 = FindDistance( currPrintGrid.orig, p1 ); x1 = (int)ceil(d1/currPrintGrid.size.x); Translate( &p1, currPrintGrid.orig, currPrintGrid.angle+270, d0 ); p0 = currPrintGrid.orig; ClipLine( &p0, &p1, zero, 0.0, mapD.size ); d1 = FindDistance( currPrintGrid.orig, p1 ); x0 = -(int)floor(d1/currPrintGrid.size.x); #endif if ( x0==bm.x0 && x1==bm.x1 && y0==bm.y0 && y1==bm.y1 ) return; size = (x1-x0) * (y1-y0); if (size > bm0.memsize) { bm0.bm = MyRealloc( bm0.bm, size ); bm0.memsize = size; } bm0.x0 = x0; bm0.x1 = x1; bm0.y0 = y0; bm0.y1 = y1; memset( bm0.bm, 0, bm0.memsize ); pageCount = 0; if (bm.bm) { for ( x=bm.x0; x<bm.x1; x++ ) { for ( y=bm.y0; y<bm.y1; y++ ) { selected = BITMAP( bm, x, y ); if (selected) { p0.x = bm.orig.x + x * bm.size.x + bm.size.x/2.0; p0.y = bm.orig.y + y * bm.size.y + bm.size.y/2.0; Rotate( &p0, bm.orig, bm.angle ); p0.x -= currPrintGrid.orig.x; p0.y -= currPrintGrid.orig.y; Rotate( &p0, zero, -currPrintGrid.angle ); x0 = (int)floor(p0.x/currPrintGrid.size.x); y0 = (int)floor(p0.y/currPrintGrid.size.y); if ( x0>=bm0.x0 && x0<bm0.x1 && y0>=bm0.y0 && y0<bm0.y1 ) { if ( BITMAP( bm0, x0, y0 ) == FALSE ) { pageCount++; BITMAP( bm0, x0, y0 ) = TRUE; } } } } } } tmpBm = bm0; bm0 = bm; bm = tmpBm; bm.orig = currPrintGrid.orig; bm.size = currPrintGrid.size; bm.angle = currPrintGrid.angle; sprintf( message, _("%d pages"), pageCount ); ParamLoadMessage( &printPG, I_PAGECNT, message ); ParamDialogOkActive( &printPG, pageCount!=0 ); }
void WinEDA_GerberFrame::ReCreateHToolbar(void) /***********************************************/ { int layer = 0; GERBER_Descr * gerber_layer = NULL; int ii; // delete and recreate the toolbar if ( m_HToolBar != NULL ) return; if ( GetScreen() ) { layer = GetScreen()->m_Active_Layer; gerber_layer = g_GERBER_Descr_List[layer]; } m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); SetToolBar(m_HToolBar); // Set up toolbar m_HToolBar->AddTool(ID_NEW_BOARD, BITMAP(new_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("New World") ); m_HToolBar->AddTool(ID_LOAD_FILE, BITMAP(open_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Open existing Layer")); #if 0 m_HToolBar->AddTool(ID_SAVE_PROJECT, BITMAP(save_button), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Save World")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_SHEET_SET, BITMAP(sheetset_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("page settings (size, texts)")); #endif m_HToolBar->AddSeparator(); #if 0 m_HToolBar->AddTool(wxID_CUT, BITMAP(cut_button), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Cut selected item")); m_HToolBar->AddTool(wxID_COPY, BITMAP(copy_button), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Copy selected item")); m_HToolBar->AddTool(wxID_PASTE, BITMAP(paste_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Paste")); #endif m_HToolBar->AddTool(ID_UNDO_BUTT, BITMAP(undelete_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Undelete")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_GEN_PRINT, BITMAP(print_button), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Print World")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, BITMAP(zoom_in_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("zoom + (F1)")); m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, BITMAP(zoom_out_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("zoom - (F2)")); m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, BITMAP(repaint_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("redraw (F3)")); m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, BITMAP(zoom_optimal_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("auto zoom")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_FIND_ITEMS, BITMAP(find_xpm), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, _("Find D Codes")); wxArrayString choices; m_HToolBar->AddSeparator(); for ( ii = 0; ii < 32 ; ii ++ ) { wxString msg; msg = _("Layer "); msg << ii+1; choices.Add(msg); } m_SelLayerBox = new wxComboBox(m_HToolBar, ID_TOOLBARH_PCB_SELECT_LAYER,"", wxDefaultPosition, wxSize(150, -1), choices, wxCB_READONLY); m_SelLayerBox->SetSelection( GetScreen()->m_Active_Layer ); m_HToolBar->AddControl(m_SelLayerBox); m_HToolBar->AddSeparator(); choices.Clear(); choices.Add( _("No tool")); for ( ii = 0; ii < MAX_TOOLS ; ii ++ ) { wxString msg; msg = _("Tool "); msg << ii + FIRST_DCODE; choices.Add(msg); } m_SelLayerTool = new wxComboBox(m_HToolBar, ID_TOOLBARH_GERBER_SELECT_TOOL,"", wxDefaultPosition, wxSize(150, -1), choices, wxCB_READONLY); m_HToolBar->AddControl(m_SelLayerTool); // after adding the buttons to the toolbar, must call Realize() to reflect // the changes m_HToolBar->Realize(); SetToolbars(); }
void WinEDA_ModuleEditFrame::ReCreateHToolbar(void) /***************************************************/ { // Cecreate the toolbar if ( m_HToolBar != NULL ) return; m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); SetToolBar(m_HToolBar); // Set up toolbar m_HToolBar->AddTool(ID_LIBEDIT_SELECT_CURRENT_LIB, wxEmptyString, BITMAP(open_library_xpm), _("Select working library")); m_HToolBar->AddTool(ID_MODEDIT_SAVE_LIBMODULE, wxEmptyString, BITMAP(save_library_xpm), _("Save Module in working library")); m_HToolBar->AddTool(ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART, wxEmptyString, BITMAP(new_library_xpm), _("Create new library and save current module")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_LIBEDIT_DELETE_PART, wxEmptyString, BITMAP(delete_xpm), _("Delete part in current library")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_MODEDIT_NEW_MODULE, wxEmptyString, BITMAP(new_footprint_xpm), _("New Module")); m_HToolBar->AddTool(ID_MODEDIT_LOAD_MODULE, wxEmptyString, BITMAP(module_xpm), _("Load module from lib")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, wxEmptyString, BITMAP(load_module_board_xpm), _("Load module from current BOARD")); m_HToolBar->AddTool(ID_MODEDIT_SAVE_MODULE_IN_BOARD, wxEmptyString, BITMAP(repl_module_board_xpm), _("Replace module in current BOARD")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_LIBEDIT_IMPORT_PART, wxEmptyString, BITMAP(import_module_xpm), _("import module")); m_HToolBar->AddTool(ID_LIBEDIT_EXPORT_PART, wxEmptyString, BITMAP(export_module_xpm), _("export module")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_MODEDIT_EDIT_MODULE_PROPERTIES, wxEmptyString, BITMAP(module_options_xpm), _("Module Properties")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_GEN_PRINT, wxEmptyString, BITMAP(print_button), _("Print Module")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), _("zoom + (F1)")); m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString,BITMAP(zoom_out_xpm), _("zoom - (F2)")); m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString,BITMAP(repaint_xpm), _("redraw (F3)")); m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString,BITMAP(zoom_optimal_xpm), _("auto zoom")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_MODEDIT_UNDO, wxEmptyString, BITMAP(undo_xpm), _("Undo last edition")); m_HToolBar->AddTool(ID_MODEDIT_REDO, wxEmptyString, BITMAP(redo_xpm), _("Redo the last undo command")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_MODEDIT_PAD_SETTINGS, wxEmptyString, BITMAP(options_pad_xpm), _("Pad Settings")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_MODEDIT_CHECK, wxEmptyString, BITMAP(module_check_xpm), _("Module Check")); // after adding the buttons to the toolbar, must call Realize() to reflect // the changes m_HToolBar->Realize(); SetToolbars(); }
/* FrontEnd - invokes the loader, parser, disassembler (if asm1), icode rewritter, and displays any useful information. */ void FrontEnd(char *filename, PCALL_GRAPH *pcallGraph) { PPROC pProc; PSYM psym; int i, c; FILE *fp = fopen(filename, "rb"); if (fp == NULL) fatalError(CANNOT_OPEN, filename); MZ_Header *hdr = read_mz_header(fp); if (hdr == NULL) { // .com not handled for now fprintf(stderr, "%s: File format not recognized\n", filename); fclose(fp); exit(EXIT_FAILURE); } // Load program into memory LoadImage(fp, hdr); if (option.verbose) { displayLoadInfo(hdr); } /* Do depth first flow analysis building call graph and procedure list, and attaching the I-code to each procedure */ parse(pcallGraph); if (option.asm1) { printf("%s: writing assembler file %s\n", progname, asm1_name); } // Search through code looking for impure references and flag them for (pProc = pProcList; pProc; pProc = pProc->next) { for (i = 0; i < pProc->Icode.numIcode; i++) { if (pProc->Icode.icode[i].ll.flg & (SYM_USE | SYM_DEF)) { psym = &symtab.sym[pProc->Icode.icode[i].ll.caseTbl.numEntries]; for (c = psym->label; c < psym->label + psym->size; c++) { if (BITMAP(c, BM_CODE)) { pProc->Icode.icode[i].ll.flg |= IMPURE; pProc->flg |= IMPURE; break; } } } } // Print assembler listing if (option.asm1) disassem(1, pProc); } if (option.Interact) { interactDis(pProcList, 0); // Interactive disassembler } // Converts jump target addresses to icode offsets for (pProc = pProcList; pProc; pProc = pProc->next) bindIcodeOff(pProc); // Print memory bitmap if (option.Map) displayMemMap(); }
void WinEDA_ViewlibFrame::ReCreateHToolbar(void) /****************************************************/ { int ii; EDA_LibComponentStruct * RootLibEntry = NULL, * CurrentLibEntry = NULL; bool asdeMorgan = FALSE, state; if ( (g_CurrentViewLibraryName != wxEmptyString) && (g_CurrentViewComponentName != wxEmptyString) ) { RootLibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), g_CurrentViewLibraryName.GetData(), FIND_ROOT); if ( RootLibEntry && LookForConvertPart(RootLibEntry) > 1 ) asdeMorgan = TRUE; CurrentLibEntry = FindLibPart(g_CurrentViewComponentName.GetData(), g_CurrentViewLibraryName.GetData(), FIND_ALIAS); } if ( m_HToolBar == NULL ) { m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); SetToolBar(m_HToolBar); // Set up toolbar m_HToolBar->AddTool(ID_LIBVIEW_SELECT_LIB, wxEmptyString, BITMAP(library_xpm), _("Select library to browse")); m_HToolBar->AddTool(ID_LIBVIEW_SELECT_PART, wxEmptyString, BITMAP(add_component_xpm), _("Select part to browse")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_LIBVIEW_PREVIOUS, wxEmptyString, BITMAP(lib_previous_xpm), _("Display previous part")); m_HToolBar->AddTool(ID_LIBVIEW_NEXT, wxEmptyString, BITMAP(lib_next_xpm), _("Display next part")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), _("zoom + (F1)")); m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm), _("zoom - (F2)")); m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm), _("redraw (F3)")); m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm), _("1:1 zoom")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, wxEmptyString, BITMAP(morgan1_xpm), _("Show as \"De Morgan\" normal part"), wxITEM_CHECK); m_HToolBar->AddTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, wxEmptyString, BITMAP(morgan2_xpm), _("Show as \"De Morgan\" convert part"), wxITEM_CHECK); m_HToolBar->AddSeparator(); SelpartBox = new WinEDAChoiceBox(m_HToolBar, ID_LIBVIEW_SELECT_PART_NUMBER, wxDefaultPosition, wxSize(150,-1)); m_HToolBar->AddControl(SelpartBox); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_LIBVIEW_VIEWDOC, wxEmptyString, BITMAP(datasheet_xpm), _("View component documents") ); m_HToolBar->EnableTool(ID_LIBVIEW_VIEWDOC, FALSE); if ( m_IsModal ) // The lib browser is called from a "load component" command { m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_LIBVIEW_CMP_EXPORT_TO_SCHEMATIC, wxEmptyString, BITMAP(export_xpm), _("Export to schematic") ); } // after adding the buttons to the toolbar, must call Realize() to reflect // the changes m_HToolBar->Realize(); } // Must be AFTER Realize(): m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, (g_ViewConvert <= 1) ? TRUE : FALSE); m_HToolBar->ToggleTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, (g_ViewConvert >= 2) ? TRUE : FALSE ); m_HToolBar->EnableTool(ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT, asdeMorgan); m_HToolBar->EnableTool(ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT, asdeMorgan); int jj = 1; if( RootLibEntry ) jj = MAX(RootLibEntry->m_UnitCount, 1); SelpartBox->Clear(); for ( ii = 0; ii < jj ; ii ++ ) { wxString msg; msg.Printf( _("Part %c"), 'A' + ii); SelpartBox->Append(msg); } SelpartBox->SetSelection(0); state = FALSE; if ( CurrentLibEntry && jj > 1 ) state = TRUE; SelpartBox->Enable(state); state = FALSE; if( CurrentLibEntry && (CurrentLibEntry->m_DocFile != wxEmptyString) ) state = TRUE; m_HToolBar->EnableTool(ID_LIBVIEW_VIEWDOC, state); }
void WinEDA_PcbFrame::ReCreateVToolbar(void) /********************************************/ /* Create the main vertical right toolbar, showing usual tools */ { if( m_VToolBar ) return; m_VToolBar = new WinEDA_Toolbar(TOOLBAR_TOOL, this, ID_V_TOOLBAR, FALSE); // Set up toolbar m_VToolBar->AddTool(ID_NO_SELECT_BUTT, wxEmptyString, BITMAP(cursor_xpm), wxEmptyString, wxITEM_CHECK ); m_VToolBar->ToggleTool(ID_NO_SELECT_BUTT, TRUE); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_PCB_HIGHLIGHT_BUTT, wxEmptyString, BITMAP(net_hightlight_xpm), _("Net highlight"), wxITEM_CHECK ); m_VToolBar->AddTool(ID_PCB_SHOW_1_RATSNEST_BUTT, wxEmptyString, BITMAP(tool_ratsnet_xpm), _("Display local ratsnest (pad or module)"), wxITEM_CHECK ); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_COMPONENT_BUTT, wxEmptyString, BITMAP(module_xpm), _("Add modules"), wxITEM_CHECK); m_VToolBar->AddTool(ID_TRACK_BUTT, wxEmptyString, BITMAP(add_tracks_xpm), _("Add Tracks an vias"), wxITEM_CHECK); m_VToolBar->AddTool(ID_PCB_ZONES_BUTT, wxEmptyString, BITMAP(add_zone_xpm), _("Add Zones"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_LINE_COMMENT_BUTT, wxEmptyString, BITMAP(add_dashed_line_xpm), _("Add graphic line or polygon"), wxITEM_CHECK); m_VToolBar->AddTool(ID_PCB_CIRCLE_BUTT, wxEmptyString, BITMAP(add_circle_xpm), _("Add graphic circle"), wxITEM_CHECK); m_VToolBar->AddTool(ID_PCB_ARC_BUTT, wxEmptyString, BITMAP(add_arc_xpm), _("Add graphic arc"), wxITEM_CHECK); m_VToolBar->AddTool(ID_TEXT_COMMENT_BUTT, wxEmptyString, BITMAP(add_text_xpm), _("Add Text"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_PCB_COTATION_BUTT, wxEmptyString, BITMAP(add_cotation_xpm), _("Add Cotation"), wxITEM_CHECK); m_VToolBar->AddTool(ID_PCB_MIRE_BUTT, wxEmptyString, BITMAP(add_mires_xpm), _("Add Mires"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_PCB_DELETE_ITEM_BUTT, wxEmptyString, BITMAP(delete_body_xpm), _("Delete items"), wxITEM_CHECK); m_VToolBar->AddSeparator(); m_VToolBar->AddTool(ID_PCB_PLACE_OFFSET_COORD_BUTT, wxEmptyString, BITMAP(pcb_offset_xpm), _("Offset adjust for drill and place files"), wxITEM_CHECK); m_VToolBar->Realize(); SetToolbars(); }
void WinEDA_PcbFrame::ReCreateOptToolbar(void) /*********************************************/ // Create the left vertical toolbar (option selections) { if ( m_OptionsToolBar ) return; // creation du tool bar options m_OptionsToolBar = new WinEDA_Toolbar(TOOLBAR_OPTION, this, ID_OPT_TOOLBAR, FALSE); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_DRC_OFF, wxEmptyString, BITMAP(drc_off_xpm), _("Drc OFF"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, BITMAP(grid_xpm), _("Display Grid OFF"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString, BITMAP(polar_coord_xpm), _("Display Polar Coord ON"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString, BITMAP(unit_inch_xpm), _("Units = Inch"), wxITEM_CHECK ); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString, BITMAP(unit_mm_xpm), _("Units = mm"), wxITEM_CHECK ); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString, BITMAP(cursor_shape_xpm), _("Change Cursor Shape"), wxITEM_CHECK); m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_RATSNEST, wxEmptyString, BITMAP(general_ratsnet_xpm), _("Show General Ratsnest"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_MODULE_RATSNEST,wxEmptyString, BITMAP(local_ratsnet_xpm), _("Show Module Ratsnest when moving"), wxITEM_CHECK); m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_AUTO_DEL_TRACK, wxEmptyString, BITMAP(auto_delete_track_xpm), _("Enable Auto Del Track"), wxITEM_CHECK); m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_ZONES,wxEmptyString, BITMAP(show_zone_xpm), _("Show Zones"), wxITEM_CHECK); m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_PADS_SKETCH,wxEmptyString, BITMAP(pad_sketch_xpm), _("Show Pads Sketch"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,wxEmptyString, BITMAP(showtrack_xpm), _("Show Tracks Sketch"), wxITEM_CHECK); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, wxEmptyString, BITMAP(palette_xpm), _("Hight Contrast Mode Display"), wxITEM_CHECK); m_OptionsToolBar->ToggleTool(ID_TB_OPTIONS_SHOW_HIGHT_CONTRAST_MODE, DisplayOpt.ContrastModeDisplay); #ifdef MUWAVE_ENBL m_OptionsToolBar->AddSeparator(); m_OptionsToolBar->AddTool(ID_TB_OPTIONS_SHOW_EXTRA_VERTICAL_TOOLBAR1, wxEmptyString, BITMAP(mw_toolbar_xpm), _("Display auxiliary vertical toolbar (tools for micro wave applications)\n This is a very experimental feature (under development)"), wxITEM_CHECK); #endif m_OptionsToolBar->Realize(); SetToolbars(); }
int Evaluate(Board* board) { BITMAP wp = board->whitepawns; BITMAP bp = board->blackpawns; BITMAP wb = board->whitebishops; BITMAP bb = board->blackbishops; BITMAP wn = board->whiteknights; BITMAP bn = board->blackknights; BITMAP wr = board->whiterooks; BITMAP br = board->blackrooks; int score = board->material; // white pawns : while(wp != BITMAP(0)) { int square = PopBit(&wp); score += PawnTable[square]; } while(bp != BITMAP(0)) { int square = PopBit(&bp); score -= PawnTable[Mirror64[square]]; } while(wb != BITMAP(0)) { int square = PopBit(&wb); score += BishopTable[square]; } while(bb != BITMAP(0)) { int square = PopBit(&bb); score -= BishopTable[Mirror64[square]]; } while(wn != BITMAP(0)) { int square = PopBit(&wn); score += KnightTable[square]; } while(bn != BITMAP(0)) { int square = PopBit(&bn); score -= KnightTable[Mirror64[square]]; } while(wr != BITMAP(0)) { int square = PopBit(&wr); score += RookTable[square]; } while(br != BITMAP(0)) { int square = PopBit(&br); score -= RookTable[Mirror64[square]]; } if(board->side == WHITE) return score; else return -score; }
void WinEDA3D_DrawFrame::ReCreateHToolbar(void) /*********************************************/ { if ( m_HToolBar != NULL ) { // simple mise a jour de la liste des fichiers anciens SetToolbars(); return; } m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); SetToolBar(m_HToolBar); // Set up toolbar m_HToolBar->AddTool(ID_RELOAD3D_BOARD, "", BITMAP(import3d_xpm), _("Reload board")); #ifdef __WINDOWS__ // do not work properly under linux m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_TOOL_SCREENCOPY_TOCLIBBOARD, "", BITMAP(copy_button), _("Copy 3D Image to Clipboard")); #endif m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, "", BITMAP(zoom_in_xpm), _("zoom + (F1)")); m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, "", BITMAP(zoom_out_xpm), _("zoom - (F2)")); m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, "", BITMAP(repaint_xpm), _("redraw (F3)")); m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, "", BITMAP(zoom_optimal_xpm), _("auto zoom")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ROTATE3D_X_POS, "", BITMAP(rotate_pos_X_xpm), _("Rotate X ->") ); m_HToolBar->AddTool(ID_ROTATE3D_X_NEG, "", BITMAP(rotate_neg_X_xpm), _("Rotate X <-") ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ROTATE3D_Y_POS, "", BITMAP(rotate_pos_Y_xpm), _("Rotate Y ->") ); m_HToolBar->AddTool(ID_ROTATE3D_Y_NEG, "", BITMAP(rotate_neg_Y_xpm), _("Rotate Y <-") ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ROTATE3D_Z_POS, "", BITMAP(rotate_pos_Z_xpm), _("Rotate Z ->") ); m_HToolBar->AddTool(ID_ROTATE3D_Z_NEG, "", BITMAP(rotate_neg_Z_xpm), _("Rotate Z <-") ); m_HToolBar->Realize(); // SetToolbars(); }
/*************************************************************************** * load_piece_style() * Load a piece style from the given file. ***************************************************************************/ static piece_style * load_piece_style(const char *filename) { piece_style *retval; char buf[2048]; FILE *fin = fopen(filename,"rt"); int i; if (!fin) { Debug("fopen(%s)\n",filename); return NULL; } Calloc(retval,piece_style *,sizeof(piece_style)); fgets(buf,sizeof(buf),fin); if (feof(fin)) { Debug("unexpected EOF after name in [%s]\n",filename); free(retval); return NULL; } if (strchr(buf,'\n')) *(strchr(buf,'\n')) = 0; retval->name = strdup(buf); if (fscanf(fin,"%d",&retval->num_piece) != 1) { Debug("malformed piece count in [%s]\n",filename); free(retval->name); free(retval); return NULL; } Calloc(retval->shape,piece *,(retval->num_piece)*sizeof(piece)); for (i=0;i<retval->num_piece;i++) { int x,y,rot,counter; do { fgets(buf,sizeof(buf),fin); if (feof(fin)) PANIC("unexpected EOF in [%s], before piece %d",filename,i+1); } while (buf[0] == '\n'); retval->shape[i].dim = strlen(buf) - 1; if (retval->shape[i].dim <= 0) PANIC("piece %d malformed height/width in [%s]", i,filename); #ifdef DEBUG Debug("... loading piece %d (%d by %d)\n",i, retval->shape[i].dim, retval->shape[i].dim); #endif for (rot=0;rot<4;rot++) { Malloc(retval->shape[i].bitmap[rot], unsigned char *, retval->shape[i].dim * retval->shape[i].dim); } counter = 1; for (y=0;y<retval->shape[i].dim;y++) { for (x=0;x<retval->shape[i].dim;x++) { BITMAP(retval->shape[i],0,x,y) = (buf[x] != '.') ? counter++ : 0; } if (y != retval->shape[i].dim - 1) do { fgets(buf,sizeof(buf),fin); if (feof(fin)) PANIC("unexpected EOF in [%s]",filename); } while (buf[0] == '\n'); } retval->shape[i].num_color = counter-1; for (rot=1;rot<4;rot++) { for (y=0;y<retval->shape[i].dim;y++) for (x=0;x<retval->shape[i].dim;x++) { BITMAP(retval->shape[i],rot,x,y) = BITMAP(retval->shape[i],rot-1, (retval->shape[i].dim - 1) - y, x); } } /* end: for rot = 0..4 */ #ifdef DEBUG for (y=0;y<retval->shape[i].dim;y++) { for (rot=0;rot<4;rot++) { for (x=0;x<retval->shape[i].dim;x++) { printf("%d", BITMAP(retval->shape[i],rot,x,y)); } printf("\t"); } printf("\n"); } #endif } Debug("Piece Style [%s] loaded (%d pieces).\n",retval->name, retval->num_piece); return retval; }
static void PrintSnapShot( void ) /* * Called when print:SnapShot button is clicked. * Set scale and orientation so the whole layout is printed on one page. */ { coOrd size; ANGLE_T scaleX, scaleY; long scaleH, scaleV; int i; coOrd pageSize; POS_T t; PrintClear(); DrawPrintGrid(); SetPageSize( FALSE ); pageSize = realPageSize; if (pageSize.x > pageSize.y) { t = pageSize.x; pageSize.x = pageSize.y; pageSize.y = t; } size = mapD.size; scaleH = 1; for (i=0;i<3;i++) { size = mapD.size; size.x += 0.75*scaleH; size.y += 0.75*scaleH; if (printGaudy) size.y += 1.0*scaleH; scaleX = size.x/pageSize.x; scaleY = size.y/pageSize.y; scaleH = (long)ceil(max( scaleX, scaleY )); } scaleV = 1; for (i=0;i<3;i++) { size = mapD.size; size.x += 0.75*scaleV; size.y += 0.75*scaleV; if (printGaudy) size.y += 1.0*scaleV; scaleX = size.x/pageSize.y; scaleY = size.y/pageSize.x; scaleV = (long)ceil(max( scaleX, scaleY )); } if ( scaleH <= scaleV ) { printScale = scaleH; printFormat = PORTRAIT; } else { printScale = scaleV; printFormat = LANDSCAPE; } SetPageSize( TRUE ); /* if (printFormat == LANDSCAPE) { currPrintGrid.orig.x = -0.5*printScale; currPrintGrid.orig.y = maxPageSize.x-0.5*printScale; currPrintGrid.angle = 90.0; } else {*/ currPrintGrid.orig.x = -0.5*printScale; currPrintGrid.orig.y = -0.5*printScale; currPrintGrid.angle = 0.0; /* }*/ currPrintGrid.size = maxPageSize; newPrintGrid = currPrintGrid; iPrintScale = (long)printScale; ParamLoadControls( &printPG ); ParamGroupRecord( &printPG ); ChangeDim(); pageCount = 1; BITMAP(bm,0,0) = TRUE; DrawPrintGrid(); ParamLoadMessage( &printPG, I_PAGECNT, _("1 page") ); ParamDialogOkActive( &printPG, TRUE ); PrintEnableControls(); wShow( printWin ); }
void WinEDA_PcbFrame::ReCreateHToolbar(void) /******************************************/ // Create the main horizontal toolbar { int ii; if ( m_HToolBar != NULL ) { // simple mise a jour de la liste des fichiers anciens wxMenuItem * item; for ( ii = 9; ii >=0 ; ii-- ) { if( m_FilesMenu->FindItem(ID_LOAD_FILE_1 + ii) ) { item = m_FilesMenu->Remove(ID_LOAD_FILE_1 + ii); if ( item ) delete item; } } for ( ii = 0; ii < 10; ii++ ) { if ( GetLastProject(ii).IsEmpty() ) break; m_FilesMenu->Append(ID_LOAD_FILE_1 + ii, GetLastProject(ii) ); } SetToolbars(); return; } m_HToolBar = new WinEDA_Toolbar(TOOLBAR_MAIN, this, ID_H_TOOLBAR, TRUE); m_HToolBar->SetRows(1); SetToolBar(m_HToolBar); // Set up toolbar m_HToolBar->AddTool(ID_NEW_BOARD, wxEmptyString, BITMAP(new_xpm), _("New Board")); m_HToolBar->AddTool(ID_LOAD_FILE, wxEmptyString, BITMAP(open_xpm), _("Open existing Board")); m_HToolBar->AddTool(ID_SAVE_BOARD, wxEmptyString, BITMAP(save_xpm), _("Save Board")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_SHEET_SET, wxEmptyString, BITMAP(sheetset_xpm), _("page settings (size, texts)") ); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_OPEN_MODULE_EDITOR, wxEmptyString, BITMAP(modedit_xpm), _("Open Module Editor")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(wxID_CUT, wxEmptyString, BITMAP(cut_button), _("Cut selected item")); #if 0 m_HToolBar->AddTool(wxID_COPY, wxEmptyString, BITMAP(copy_button), _("Copy selected item")); m_HToolBar->AddTool(wxID_PASTE, wxEmptyString, BITMAP(paste_xpm), _("Paste")); #endif m_HToolBar->AddTool(ID_UNDO_BUTT, wxEmptyString, BITMAP(undelete_xpm), _("Undelete")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_GEN_PRINT, wxEmptyString, BITMAP(print_button), _("Print Board")); m_HToolBar->AddTool(ID_GEN_PLOT, wxEmptyString, BITMAP(plot_xpm), _("Plot (Hplg, Postscript, or Gerber format)")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_ZOOM_PLUS_BUTT, wxEmptyString, BITMAP(zoom_in_xpm), _("zoom + (F1)")); m_HToolBar->AddTool(ID_ZOOM_MOINS_BUTT, wxEmptyString, BITMAP(zoom_out_xpm), _("zoom - (F2)")); m_HToolBar->AddTool(ID_ZOOM_REDRAW_BUTT, wxEmptyString, BITMAP(repaint_xpm), _("redraw (F3)")); m_HToolBar->AddTool(ID_ZOOM_PAGE_BUTT, wxEmptyString, BITMAP(zoom_optimal_xpm), _("auto zoom")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_FIND_ITEMS, wxEmptyString, BITMAP(find_xpm), _("Find components and texts")); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_GET_NETLIST, wxEmptyString, BITMAP(netlist_xpm), _("Read Netlist")); m_HToolBar->AddTool(ID_DRC_CONTROL, wxEmptyString, BITMAP(erc_xpm), _("Pcb Design Rules Check")); m_HToolBar->AddSeparator(); ReCreateLayerBox(m_HToolBar); m_HToolBar->AddSeparator(); m_HToolBar->AddTool(ID_TOOLBARH_PCB_AUTOPLACE, wxEmptyString, BITMAP(mode_module_xpm), _("Mode Module: Manual and Automatic Move or Place for modules"), wxITEM_CHECK ); m_HToolBar->AddTool(ID_TOOLBARH_PCB_AUTOROUTE, wxEmptyString, BITMAP(mode_track_xpm), _("Mode Track and Autorouting"), wxITEM_CHECK); // after adding the buttons to the toolbar, must call Realize() to reflect // the changes m_HToolBar->Realize(); SetToolbars(); }
static BOOL_T PrintPage( int x, int y ) { coOrd orig, p[4], minP, maxP; int i; coOrd clipOrig, clipSize; wFont_p fp; coOrd roomSize; if (BITMAP(bm,x,y)) { orig.x = currPrintGrid.orig.x + x*currPrintGrid.size.x; orig.y = currPrintGrid.orig.y + y*currPrintGrid.size.y; Rotate( &orig, currPrintGrid.orig, currPrintGrid.angle ); p[0] = p[1] = p[2] = p[3] = orig; p[1].x = p[2].x = orig.x + currPrintGrid.size.x; p[2].y = p[3].y = orig.y + currPrintGrid.size.y + ( printGaudy ? printScale : 0.0 ); Rotate( &p[0], orig, currPrintGrid.angle ); Rotate( &p[1], orig, currPrintGrid.angle ); Rotate( &p[2], orig, currPrintGrid.angle ); Rotate( &p[3], orig, currPrintGrid.angle ); minP = maxP = p[0]; for (i=1; i<4; i++) { if (maxP.x < p[i].x) maxP.x = p[i].x; if (maxP.y < p[i].y) maxP.y = p[i].y; if (minP.x > p[i].x) minP.x = p[i].x; if (minP.y > p[i].y) minP.y = p[i].y; } maxP.x -= minP.x; maxP.y -= minP.y; print_d.d = page_d.d = wPrintPageStart(); if (page_d.d == NULL) return FALSE; print_d.dpi = page_d.dpi = wDrawGetDPI( print_d.d ); print_d.angle = currPrintGrid.angle; print_d.orig = orig; print_d.size = /*maxP*/ currPrintGrid.size; page_d.orig = zero; page_d.angle = 0.0; if ( printGaudy ) { Translate( &print_d.orig, orig, currPrintGrid.angle+180.0, printScale ); print_d.size.y += printScale; } if (printRotate) { rotateCW = (printFormat != PORTRAIT); if (rotateCW) { page_d.orig.x = realPageSize.y; page_d.orig.y = 0.0; page_d.angle = -90.0; print_d.angle += -90.0; Translate( &print_d.orig, print_d.orig, currPrintGrid.angle+90, maxPageSize.x ); } else { page_d.orig.x = 0.0; page_d.orig.y = realPageSize.x; page_d.angle = 90.0; print_d.angle += 90.0; Translate( &print_d.orig, print_d.orig, currPrintGrid.angle, maxPageSize.y+(printGaudy?printScale:0) ); } page_d.size.x = print_d.size.y/printScale; page_d.size.y = print_d.size.x/printScale; print_d.size.x = currPrintGrid.size.y; print_d.size.y = currPrintGrid.size.x; } else { page_d.size.x = print_d.size.x/printScale; page_d.size.y = print_d.size.y/printScale; } wSetCursor( wCursorWait ); print_d.scale = printScale; if (print_d.d == NULL) AbortProg( "wPrintPageStart" ); clipOrig.x = clipOrig.y = 0; clipSize.x = maxPageSize.x/printScale; clipSize.y = maxPageSize.y/printScale; GetRoomSize( &roomSize ); if (printGaudy) { PrintGaudyBox( roomSize ); if ((!printRotate) || rotateCW) { clipOrig.y = 1.0; } if (printRotate && rotateCW) { print_d.size.x += printScale; } } else if (printRegistrationMarks) PrintPlainBox( x, y, p ); if (printRotate) { wPrintClip( (wPos_t)(clipOrig.y*print_d.dpi), (wPos_t)(clipOrig.x*print_d.dpi), (wPos_t)(clipSize.y*print_d.dpi), (wPos_t)(clipSize.x*print_d.dpi) ); } else { wPrintClip( (wPos_t)(clipOrig.x*print_d.dpi), (wPos_t)(clipOrig.y*print_d.dpi), (wPos_t)(clipSize.x*print_d.dpi), (wPos_t)(clipSize.y*print_d.dpi) ); } p[0].x = p[3].x = 0.0; p[1].x = p[2].x = roomSize.x; p[0].y = p[1].y = 0.0; p[2].y = p[3].y = roomSize.y; fp = wStandardFont( F_TIMES, FALSE, FALSE ); DrawRuler( &print_d, p[0], p[1], 0.0, TRUE, FALSE, wDrawColorBlack ); DrawRuler( &print_d, p[0], p[3], 0.0, TRUE, TRUE, wDrawColorBlack ); DrawRuler( &print_d, p[1], p[2], 0.0, FALSE, FALSE, wDrawColorBlack ); DrawRuler( &print_d, p[3], p[2], 0.0, FALSE, TRUE, wDrawColorBlack ); if ( printRuler && currPrintGrid.angle == 0 ) { if ( !printRotate ) { p[2] = p[3] = print_d.orig; p[3].x += print_d.size.x; p[3].y += print_d.size.y; } else if ( rotateCW ) { p[2].x = print_d.orig.x - print_d.size.y; p[2].y = print_d.orig.y; p[3].x = print_d.orig.x; p[3].y = print_d.orig.y + print_d.size.x; } else { p[2].x = print_d.orig.x; p[2].y = print_d.orig.y - print_d.size.x; p[3].x = print_d.orig.x + print_d.size.y; p[3].y = print_d.orig.y; } if ( p[2].x > 0 ) minP.x = p[2].x + 0.4 * print_d.scale; else minP.x = 0.0; if ( p[3].x < roomSize.x ) maxP.x = p[3].x - 0.2 * print_d.scale; else maxP.x = roomSize.x; if ( p[2].y > 0 ) minP.y = p[2].y + 0.4 * print_d.scale; else minP.y = 0.0; if ( p[3].y < roomSize.y ) maxP.y = p[3].y - 0.2 * print_d.scale; else maxP.y = roomSize.y; p[0].y = 0.0; p[1].y = maxP.y - minP.y; if ( p[2].x > 0 ) { p[0].x = p[1].x = p[2].x + 0.4 * print_d.scale; DrawRuler( &print_d, p[0], p[1], minP.y, TRUE, TRUE, wDrawColorBlack ); } if ( p[3].x < roomSize.x ) { p[0].x = p[1].x = p[3].x - 0.2 * print_d.scale; DrawRuler( &print_d, p[0], p[1], minP.y, FALSE, FALSE, wDrawColorBlack ); } p[0].x = 0; p[1].x = maxP.x - minP.x; if ( p[2].y > 0 ) { p[0].y = p[1].y = p[2].y + 0.4 * print_d.scale; DrawRuler( &print_d, p[0], p[1], minP.x, TRUE, FALSE, wDrawColorBlack ); } if ( p[3].y < roomSize.y ) { p[0].y = p[1].y = p[3].y - 0.2 * print_d.scale; DrawRuler( &print_d, p[0], p[1], minP.x, FALSE, TRUE, wDrawColorBlack ); } } if (printGrid) DrawSnapGrid( &print_d, mapD.size, FALSE ); roadbedWidth = printRoadbed?printRoadbedWidth:0.0; DrawTracks( &print_d, print_d.scale, minP, maxP ); if (printRegistrationMarks && printScale == 1) DrawRegistrationMarks( &print_d ); if ( !wPrintPageEnd( print_d.d ) ) return FALSE; /*BITMAP(bm,x,y) = 0;*/ MarkPage( x, y ); } return TRUE; }
static void calc_contours( double *z, int nrz, int nx, int ny, double *cv, int ncv, double zmax, int *bitmap, double xmin, double ymin, double dx, double dy) { /* This subroutine draws a contour through equal values of an array. ***** Formal arguments *********************************** Z is the array for which contours are to be drawn. The elements of Z are assumed to lie upon the nodes of a topologically rectangular coordinate system - e.g. cartesian, polar (except the origin), etc. NRZ is the number of rows declared for z in the calling program. NX is the limit for the first subscript of Z. NY is the limit for the second subscript of Z. CV are the values of the contours to be drawn. NCV is the number of contour values in CV. ZMAX is the maximum value of Z for consideration. A value of Z[I,J] greater than ZMAX is a signal that that point and the grid line segments radiating from that point to it's neighbors are to be excluded from contouring. BITMAP is a work area large enough to hold NX*NY*NCV*2 bits. ****************************************************************** DRAW is a subroutine used to draw contours. The calling sequence for draw is: draw (x, y, z, iflag) Let NX = integer part of X, FX = fractional part of X. Then X should be interpreted such that increases in NX correspond to increases in the first subscript of Z, and FX is the fractional distance from the abscissa corresponding to NX to the abscissa corresponding to NX+1, and Y should be interpreted similarly for the second subscript of Z. The low-order digit of IFLAG will have one of the values: 1 - continue a contour, 2 - start a contour at a boundary, 3 - start a contour not at a boundary, 4 - finish a contour at a boundary, 5 - finish a closed contour (not at a boundary). note that requests 1, 4 and 5 are for pen-down moves, and that requests 2 and 3 are for pen-up moves. 6 - set X and Y to the approximate 'pen' position, using the notation discussed above. this call may be ignored, the result being that the 'pen' position is taken to correspond to Z[1]. IFLAG/10 is the contour number. L1 and L2 contain limits used during the spiral search for the beginning of a contour. IJ stores subcripts used during the spiral search. int i1[2], i2[2], i3[6] I1, I2 and I3 are used for subscript computations during the examination of lines from Z[I,J] to it's neighbors. double xint[4] XINT is used to mark intersections of the contour under consideration with the edges of the cell being examined. double xy[2] XY is used to compute coordinates for the draw subroutine. */ static int l1[4] = { 0, 0, -1, -1 }; static int i1[2] = { 1, 0 }; static int i2[2] = { 1, -1 }; static int i3[6] = { 1, 0, 0, 1, 1, 0 }; double cval = 0, xint[4], z1, z2, zz; int idir, icur, jcur, jump, k, l, iedge, iflag = 0, ibkey; double xy[2]; int ij[2], l2[4]; int ii, jj, ni, ks = 0, ix, nxidir, icv = 0; #define Z(i, j) z[(i) - 1 + ((j) - 1) * nrz] #define BITMAP(i, j, k, l) \ bitmap[(i) - 1 + ((j) - 1 + ((k) - 1 + ((l) - 1) * ncv) * ny) * nx] l1[0] = nx; l1[1] = ny; /* Set the current pen position. The default position corresponds to Z[1]. */ xy[0] = 1.0; xy[1] = 1.0; icur = max(1, min((int) xy[0], nx)); jcur = max(1, min((int) xy[1], ny)); /* Clear the bitmap. */ memset(bitmap, 0, nx * ny * ncv * 2 * sizeof(int)); /* Search along a rectangular spiral path for a line segment having the following properties: 1. the end points are not excluded, 2. no mark has been recorded for the segment, 3. the values of z at the ends of the segment are such that One Z is less than the current contour value, and the other is greater than or equal to the current contour value. Search all boundaries first, then search interior line segments. Note that the interior line segments near excluded points may be boundaries. */ ibkey = 0; L10: ij[0] = icur; ij[1] = jcur; L20: l2[0] = ij[0]; l2[1] = ij[1]; l2[2] = -ij[0]; l2[3] = -ij[1]; idir = 0; /* Direction 0 is +I, 1 is +J, 2 is -I, 3 is -J. */ L30: nxidir = idir + 1; k = nxidir; if (nxidir > 3) { nxidir = 0; } L40: ij[0] = abs(ij[0]); ij[1] = abs(ij[1]); if (Z(ij[0], ij[1]) > zmax) { goto L140; } l = 1; /* L=1 means horizontal line, L=2 means vertical line. */ L50: if (ij[l - 1] >= l1[l - 1]) { goto L130; } ii = ij[0] + i1[l - 1]; jj = ij[1] + i1[3 - l - 1]; if (Z(ii, jj) > zmax) { goto L130; } jump = 100; /* The next 15 statements (or so) detect boundaries. */ L60: ix = 1; if (ij[3 - l - 1] == 1) { goto L80; } ii = ij[0] - i1[3 - l - 1]; jj = ij[1] - i1[l - 1]; if (Z(ii, jj) > zmax) { goto L70; } ii = ij[0] + i2[l - 1]; jj = ij[1] + i2[3 - l - 1]; if (Z(ii, jj) < zmax) { ix = 0; } L70: if (ij[3 - l - 1] >= l1[3 - l - 1]) { goto L90; } L80: ii = ij[0] + i1[3 - l - 1]; jj = ij[1] + i1[l - 1]; if (Z(ii, jj) > zmax) { goto L90; } if (Z(ij[0] + 1, ij[1] + 1) < zmax) { goto L100; } L90: ix += 2; L100: if (jump == 280) { goto L280; } if (ix == 3) { goto L130; } if (ix + ibkey == 0) { goto L130; } /* Now determine whether the line segment is crossed by the contour. */ ii = ij[0] + i1[l - 1]; jj = ij[1] + i1[3 - l - 1]; z1 = Z(ij[0], ij[1]); z2 = Z(ii, jj); for (icv = 1; icv <= ncv; ++icv) { if (BITMAP(ij[0], ij[1], icv, l) != 0) { goto L120; } if (cv[icv - 1] <= min(z1, z2)) { goto L110; } if (cv[icv - 1] <= max(z1, z2)) { goto L190; } L110: BITMAP(ij[0], ij[1], icv, l) = 1; L120: ; } L130: ++l; if (l <= 2) { goto L50; } L140: l = idir % 2 + 1; ij[l - 1] = abs(ij[l - 1]) * (abs(l1[k - 1]) / l1[k - 1]); /* Lines from Z[I,J] to Z[I+1,J] and Z[I,J+1] are not satisfactory continue the spiral. */ L150: if (ij[l - 1] >= l1[k - 1]) { goto L170; } ++ij[l - 1]; if (ij[l - 1] > l2[k - 1]) { goto L160; } goto L40; L160: l2[k - 1] = ij[l - 1]; idir = nxidir; goto L30; L170: if (idir == nxidir) { goto L180; } ++nxidir; ij[l - 1] = l1[k - 1]; k = nxidir; l = 3 - l; ij[l - 1] = l2[k - 1]; if (nxidir > 3) { nxidir = 0; } goto L150; L180: if (ibkey != 0) { return; } ibkey = 1; goto L10; /* An acceptable line segment has been found. Follow the contour until it either hits a boundary or closes. */ L190: iedge = l; cval = cv[icv - 1]; if (ix != 1) { iedge += 2; } iflag = ibkey + 2; xint[iedge - 1] = (cval - z1) / (z2 - z1); L200: xy[l - 1] = ij[l - 1] + xint[iedge - 1]; xy[3 - l - 1] = ij[3 - l - 1]; BITMAP(ij[0], ij[1], icv, l) = 1; draw(xmin + (xy[0] - 1.0) * dx, ymin + (xy[1] - 1.0) * dy, cval, iflag + 10 * icv); if (iflag < 4) { goto L210; } icur = ij[0]; jcur = ij[1]; goto L20; /* Continue a contour. The edges are numbered clockwise with the bottom edge being edge number one. */ L210: ni = 1; if (iedge < 3) { goto L220; } ij[0] -= i3[iedge - 1]; ij[1] -= i3[iedge + 1]; L220: for (k = 1; k <= 4; ++k) { if (k == iedge) { goto L250; } ii = ij[0] + i3[k - 1]; jj = ij[1] + i3[k]; z1 = Z(ii, jj); ii = ij[0] + i3[k]; jj = ij[1] + i3[k + 1]; z2 = Z(ii, jj); if (cval <= min(z1, z2)) { goto L250; } if (cval > max(z1, z2)) { goto L250; } if (k == 1) { goto L230; } if (k != 4) { goto L240; } L230: zz = z1; z1 = z2; z2 = zz; L240: xint[k - 1] = (cval - z1) / (z2 - z1); ++ni; ks = k; L250: ; } if (ni == 2) { goto L260; } /* The contour crosses all four edges of the cell being examined. choose the lines top-to-left and bottom-to-right if the interpolation point on the top edge is less than the interpolation point on the bottom edge. Otherwise, choose the other pair. This method produces the same results if the axes are reversed. The contour may close at any edge, but must not cross itself inside any cell. */ ks = 5 - iedge; if (xint[2] < xint[0]) { goto L260; } ks = 3 - iedge; if (ks <= 0) { ks += 4; } /* Determine whether the contour will close or run into a boundary at edge KS of the current cell. */ L260: l = ks; iflag = 1; jump = 280; if (ks < 3) { goto L270; } ij[0] += i3[ks - 1]; ij[1] += i3[ks + 1]; l = ks - 2; L270: if (BITMAP(ij[0], ij[1], icv, l) == 0) { goto L60; } iflag = 5; goto L290; L280: if (ix != 0) { iflag = 4; } L290: iedge = ks + 2; if (iedge > 4) { iedge += -4; } xint[iedge - 1] = xint[ks - 1]; goto L200; }
/* The main function */ int main(int argc, char const *argv[0]) { int hdev; char const *dev; unsigned char kbits[BITMAP(MEMBS_OF(Symbols))]; /* Parse the "-d" command line argument. * dev := path to the evdev device */ #ifdef __ARMEL__ dev = "/dev/input/event2"; #else dev = "/dev/input/event0"; #endif if (argv[1] && !strcmp(argv[1], "-d")) { if (!argv[2]) { fputs("getkey: Required argument missing.\n", stderr); exit(255); } dev = argv[2]; argv += 2; argc -= 2; } /* Open the evdev interface. * hdev := file descriptor of the evdev device */ if ((hdev = open(dev, O_RDONLY)) < 0) { fprintf(stderr, "getkey: %s: %s\n", dev, strerror(errno)); exit(255); } /* kbits := bitmask of all keys pressed at the moment */ memset(kbits, 0, sizeof(kbits)); if (ioctl(hdev, EVIOCGKEY(sizeof(kbits)), kbits) < 0) { fprintf(stderr, "getkey: %s: EVIOCGKEY: %s\n", dev, strerror(errno)); exit(255); } /* Process the rest of the command line. */ if (!argv[1]) { unsigned i; /* Get mode: print the symbolic names of * all keys currently pressed. */ for (i = 0; i < MEMBS_OF(Symbols); i++) if (BIT_OF(kbits, i)) printf("%s 0x%.4X %u\n", Symbols[i] ? Symbols[i] : "<unknown>", i, i); exit(0); } else { int allok, checkany; unsigned i, exitcode; /* Test mode: test whether all key specified * on the command line block are pressed and * exit with the appropriate code. */ allok = 1; checkany = 0; exitcode = 0; for (i = 1; ; i++) { if (!argv[i] || !strcmp(argv[i], "-o")) { /* End of command line block */ if (checkany && allok) /* All of the keys in the block * are being pushed. */ break; exitcode++; if (!argv[i]) /* Out of blocks */ break; /* Process the next block. */ allok = 1; checkany = 0; } else { /* Test wheter argv[i] is pressed * and reset `allok' if it isn't. * There's no point in testing if * the block has already failed. */ checkany = 1; if (allok && !match(kbits, argv[i])) allok = 0; } /* if */ } /* for */ exit(exitcode); } /* if */ /* Not reached */ } /* main */