void console::ted_cmd::OnGUInput(wxCommandEvent& evt) { switch (evt.GetInt()) { case -4: _translation.FlipY();break; case -3: _translation.Rotate(90.0);break; case -2: cancelLastPoint();break; case -1: // abort current mouse input Disconnect(-1, wxEVT_COMMAND_ENTER); delete puc; puc = NULL; _mouseIN_OK = false; tell_log(MT_WARNING, "input aborted"); tell_log(MT_EOL); // wake-up the thread expecting this data threadWaits4->Signal(); break; case 0: {// left mouse button telldata::ttpnt* p = static_cast<telldata::ttpnt*>(evt.GetClientData()); mouseLB(*p); break; } case 2: mouseRB(); break; default: assert(false); } }
void console::ted_cmd::getCommandA() { if (puc) getGUInput(); // run the local GUInput parser else { wxString command = GetValue(); tell_log(MT_COMMAND, command.c_str()); _cmd_history.push_back(command.c_str()); _history_position = _cmd_history.end(); Clear(); parse_thread *pthrd = new parse_thread(command, _wait?wxTHREAD_JOINABLE:wxTHREAD_DETACHED ); pthrd->Create(); pthrd->Run(); if (_wait) pthrd->Wait(); } }
laydata::TEDfile::TEDfile(tdtdesign* design, std::string& filename) { //writing _design = design;_revision=0;_subrevision=6; if (NULL == (_file = fopen(filename.c_str(), "wb"))) { std::string news = "File \""; news += filename.c_str(); news += "\" can not be created"; tell_log(console::MT_ERROR,news.c_str()); return; } putString(TED_LEADSTRING); putRevision(); putTime(); _design->write(this); fclose(_file); }
int tellstdfunc::stdUSINGLAYER_S::execute() { std::string layname = getStringValue(); word layno = DATC->getLayerNo(layname); if (layno > 0) { OPstack.push(DEBUG_NEW telldata::ttint(layno)); return stdUSINGLAYER::execute(); } else {// no layer with this name std::string news = "layer \""; news += layname; news += "\" is not defined"; tell_log(console::MT_ERROR,news); return EXEC_NEXT; } }
//----------------------------------------------------------------------------- Calbr::CalbrFile::CalbrFile(const std::string &fileName) :_ok(true) { std::ostringstream ost; _fileName = fileName; std::string fname(convertString(_fileName)); if (!(_calbrFile = fopen(fname.c_str(),"rt"))) // open the input file { _ok = false; ost << "Can't open file " << fname; tell_log(console::MT_ERROR,ost.str()); return; } //read header char str[512]; if (fgets(str, 512, _calbrFile)==NULL) { _ok = false; ost << "Problem of reading file " << fname; tell_log(console::MT_ERROR,ost.str()); return; } char cellName[512]; sscanf( str, "%s %ud", cellName, &_precision); //initialisation of static member drcPolygon class drcPolygon::_precision = _precision; drcEdge::_precision = _precision; _cellName = cellName; while(parse()) { } }
int tellstdfunc::stdCHANGESTRING::execute() { std::string newstring = getStringValue(); laydata::tdtdesign* ATDB = DATC->lockDB(); // first save the list of all currently selected components ... laydata::selectList* savelist = ATDB->copy_selist(); // get a list of selected texts only laydata::selectList* texts4u = filter_selist(savelist, laydata::_lmtext); if (texts4u->empty()) { for (laydata::selectList::const_iterator CL = savelist->begin(); CL != savelist->end(); CL++) delete CL->second; delete savelist; for (laydata::selectList::const_iterator CL = texts4u->begin(); CL != texts4u->end(); CL++) delete CL->second; delete texts4u; tell_log(console::MT_ERROR,"No text objects selected"); } else {// just if we have selected texts UNDOcmdQ.push_front(this); // now unselect all ... ATDB->unselect_all(); // ... and select back only text shapes ATDB->select_fromList(texts4u); // delete them from the DB - get back the list of deleted shapes. laydata::atticList* fha = DEBUG_NEW laydata::atticList(); ATDB->delete_selected(fha, DATC->TEDLIB()); // save the deleted shapes in the UNDO data stack UNDOPstack.push_front(make_ttlaylist(fha)); // replace the strings laydata::atticList* fhba = replace_str(fha, newstring); telldata::ttlist* fhb = make_ttlaylist(fhba); // save the new texts in the UNDO data stack UNDOPstack.push_front(fhb); // add the new objects back to the DB ATDB->addlist(get_shlaylist(fhb)); // now restore selection ATDB->select_fromList(savelist); ATDB->select_fromList(get_ttlaylist(fhb)); // that's it! clean_atticlist(fha); delete fha; clean_atticlist(fhba);delete fhba; LogFile << LogFile.getFN() << "(\"" << newstring << "\");"; LogFile.flush(); RefreshGL(); } DATC->unlockDB(); return EXEC_NEXT; }
laydata::tdtdata* laydata::tdtdesign::addwire(word la, const pointlist* pl, word w) { laydata::valid_wire check(*pl,w); if (!check.valid()) { std::ostringstream ost; ost << "Wire check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); return NULL; } tdtlayer *actlay = static_cast<tdtlayer*>(targetlayer(la)); modified = true; pointlist vpl = check.get_validated(); for(pointlist::iterator PL = vpl.begin(); PL != vpl.end(); PL++) (*PL) *= _target.rARTM(); return actlay->addwire(vpl,w); }
int tellstdfunc::stdUSINGLAYER_S::execute() { std::string layname = getStringValue(); unsigned layno = DATC->getLayerNo(layname); if (layno > 0) { //@FIXMEEE! 0 here means that the layer with this name is not found! // which means that layer 0 will be pronounced undefined! OPstack.push(DEBUG_NEW telldata::ttint(layno)); return stdUSINGLAYER::execute(); } else {// no layer with this name std::string news = "layer \""; news += layname; news += "\" is not defined"; tell_log(console::MT_ERROR,news); return EXEC_NEXT; } }
void console::ted_cmd::getCommandA() { if (puc) getGUInput(); // run the local GUInput parser else { wxString command = GetValue(); tell_log(MT_COMMAND, command); _cmd_history.push_back(std::string(command.mb_str())); _history_position = _cmd_history.end(); Clear(); if (!_thread) { // executing the parser without thread // essentially the same code as in parse_thread::Entry, but // without the mutexes telllloc.first_column = telllloc.first_line = 1; telllloc.last_column = telllloc.last_line = 1; telllloc.filename = NULL; void* b = tell_scan_string( command.mb_str() ); tellparse(); my_delete_yy_buffer( b ); } else { // executing the parser in a separate thread //wxTHREAD_JOINABLE, wxTHREAD_DETACHED parse_thread *pthrd = DEBUG_NEW parse_thread(command,_parent,_canvas); wxThreadError result = pthrd->Create(); if (wxTHREAD_NO_ERROR == result) pthrd->Run(); else { tell_log( MT_ERROR, "Can't execute the command in a separate thread"); delete(pthrd); } // if (_wait) pthrd->Wait(); } } }
void GDSin::Gds2Ted::poly(GDSin::GdsPolygon* wd, laydata::tdtlayer* wl, int2b layno) { pointlist &pl = wd->plist(); laydata::valid_poly check(pl); if (!check.valid()) { std::ostringstream ost; ost << "Layer " << layno; ost << ": Polygon check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); } else pl = check.get_validated() ; if (check.box()) wl->addbox(pl[0], pl[2], false); else wl->addpoly(pl,false); }
int tellstdfunc::stdROTATESEL_D::execute() { real angle = getOpValue(); if (DATC->numselected() == 0) { tell_log(console::MT_ERROR,"No objects selected. Nothing to rotate"); return EXEC_NEXT; } CTM rct; rct.Rotate(angle); OPstack.push(DEBUG_NEW telldata::ttreal(angle)); // stop the thread and wait for input from the GUI if (!tellstdfunc::waitGUInput(console::op_rotate, &OPstack, "", rct)) return EXEC_ABORT; return stdROTATESEL::execute(); }
void DataCenter::importGDScell(const nameList& top_names, bool recur, bool over) { if (NULL == lockGDS()) { std::string news = "No GDS data in memory. Parse GDS file first"; tell_log(console::MT_ERROR,news); } { // Lock the DB here manually. Otherwise the cell browser is going mad GDSin::gds2ted converter(_GDSDB, _TEDLIB()); for (nameList::const_iterator CN = top_names.begin(); CN != top_names.end(); CN++) converter.structure(CN->c_str(), recur, over); _TEDLIB()->modified = true; unlockGDS(); } }
void GDSin::gds2ted::path(GDSin::GDSpath* wd, laydata::tdtcell* dst) { laydata::tdtlayer* wl = static_cast<laydata::tdtlayer*> (dst->securelayer(wd->GetLayer())); pointlist &pl = wd->GetPlist(); laydata::valid_wire check(pl, wd->Get_width()); if (!check.valid()) { std::ostringstream ost; ost << "Layer " << wd->GetLayer(); ost << ": Wire check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); return; } else pl = check.get_validated() ; /* @TODO !!! GDS path type here!!!! */ wl->addwire(pl, wd->Get_width(),false); }
int tellstdfunc::stdCOPYSEL_D::execute() { if (DATC->numselected() == 0) { tell_log(console::MT_ERROR,"No objects selected. Nothing to copy"); return EXEC_NEXT; } // stop the thread and wait for input from the GUI if (!tellstdfunc::waitGUInput(console::op_copy, &OPstack)) return EXEC_ABORT; // get the data from the stack telldata::ttwnd *w = static_cast<telldata::ttwnd*>(OPstack.top());OPstack.pop(); OPstack.push(DEBUG_NEW telldata::ttpnt(w->p1().x(), w->p1().y())); OPstack.push(DEBUG_NEW telldata::ttpnt(w->p2().x(), w->p2().y())); delete w; return stdCOPYSEL::execute(); }
int tellstdfunc::TDTunloadlib::execute() { std::string libname = getStringValue(); if (DATC->TDTunloadlib(libname)) { browsers::addTDTtab(true); LogFile << LogFile.getFN() << "(\""<< libname << "\");"; LogFile.flush(); } else { std::string info = "Library \"" + libname + "\" is not loaded"; tell_log(console::MT_ERROR,info); } return EXEC_NEXT; }
void GDSin::Gds2Ted::wire(GDSin::GDSpath* wd, laydata::tdtlayer* wl, int2b layno) { pointlist &pl = wd->plist(); laydata::valid_wire check(pl, wd->width()); if (!check.valid()) { std::ostringstream ost; ost << "Layer " << layno; ost << ": Wire check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); return; } else pl = check.get_validated() ; /* @TODO !!! GDS path type here!!!! */ wl->addwire(pl, wd->width(),false); }
void CIFin::Cif2Ted::box ( CIFin::CifBox* wd, laydata::tdtlayer* wl, std::string layname) { pointlist pl; pl.reserve(4); real cX, cY; cX = rint(((real)wd->center()->x() - (real)wd->length()/ 2.0f) * _crosscoeff ); cY = rint(((real)wd->center()->y() - (real)wd->width() / 2.0f) * _crosscoeff ); TP cpnt1( (int4b)cX, (int4b)cY ); pl.push_back(cpnt1); cX = rint(((real)wd->center()->x() + (real)wd->length()/ 2.0f) * _crosscoeff ); cY = rint(((real)wd->center()->y() - (real)wd->width() / 2.0f) * _crosscoeff ); TP cpnt2( (int4b)cX, (int4b)cY ); pl.push_back(cpnt2); cX = rint(((real)wd->center()->x() + (real)wd->length()/ 2.0f) * _crosscoeff ); cY = rint(((real)wd->center()->y() + (real)wd->width() / 2.0f) * _crosscoeff ); TP cpnt3( (int4b)cX, (int4b)cY ); pl.push_back(cpnt3); cX = rint(((real)wd->center()->x() - (real)wd->length()/ 2.0f) * _crosscoeff ); cY = rint(((real)wd->center()->y() + (real)wd->width() / 2.0f) * _crosscoeff ); TP cpnt4( (int4b)cX, (int4b)cY ); pl.push_back(cpnt4); if (NULL != wd->direction()) { CTM tmx; cX = (real)wd->center()->x() * _crosscoeff; cY = (real)wd->center()->y() * _crosscoeff; tmx.Translate(-cX,-cY); tmx.Rotate(*(wd->direction())); tmx.Translate(cX,cY); pl[0] *= tmx; pl[1] *= tmx; pl[2] *= tmx; pl[3] *= tmx; } laydata::valid_poly check(pl); if (!check.valid()) { std::ostringstream ost; ost << "Layer " << layname; ost << ": Box check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); } else pl = check.get_validated() ; if (check.box()) wl->addbox(pl[0], pl[2],false); else wl->addpoly(pl,false); }
void tui::MenuItemHandler::recreate(wxMenuBar *menuBar) { wxMenu* menu; wxMenuItem *menuItem; std::vector<std::string> menuNames; menuNames = split(_menuItem, '/'); if (menuNames.size()==0) return; if (menuNames.size()==1) { //Create new item in main menu menu = new wxMenu(); menuBar->Insert(menuBar->GetMenuCount()-1, menu, wxString(menuNames[0].c_str(), wxConvUTF8)); _inserted = true; return; } menu = buildPath(menuBar, menuNames); //last item std::string insertedString = *(menuNames.end()-1); if (_hotKey !="") insertedString=insertedString+"\t"+_hotKey; int index = menu->FindItem(wxString(insertedString.c_str(), wxConvUTF8)); menuItem = menu->FindItem(index); if ((index==wxNOT_FOUND)||(menuItem==NULL)) { std::ostringstream ost; ost<<"Error redefining menu"; tell_log(console::MT_ERROR,ost.str()); return; } menuItem->SetText(wxString(insertedString.c_str(), wxConvUTF8)); menuItem->SetHelp(wxString(_helpString.c_str(), wxConvUTF8)); //menuItem = new wxMenuItem(menu, _ID, insertedString.c_str(), _helpString.c_str()); //menu->Append(menuItem); _inserted = true; _changed = false; };
laydata::tdtdata* laydata::tdtdesign::addcellref(laydata::refnamepair striter, CTM& ori) { modified = true; ori *= _target.rARTM(); DBbox old_overlap = _target.edit()->overlap(); tdtdata* ncrf = _target.edit()->addcellref(this, striter, ori); if (NULL == ncrf) { tell_log(console::MT_ERROR, "Circular reference is forbidden"); } else { if (_target.edit()->overlapChanged(old_overlap, this)) do {} while(validate_cells()); } return ncrf; }
int tellstdfunc::GDSexportLIB::execute() { std::string filename = getStringValue(); if (expandFileName(filename)) { DATC->lockDB(false); DATC->GDSexport(filename); DATC->unlockDB(); LogFile << LogFile.getFN() << "(\""<< filename << ");"; LogFile.flush(); } else { std::string info = "Filename \"" + filename + "\" can't be expanded properly"; tell_log(console::MT_ERROR,info); } return EXEC_NEXT; }
void CIFin::Cif2Ted::ref ( CIFin::CifRef* wd, laydata::tdtcell* dst) { CifStructure* refd = _src_lib->getStructure(wd->cell()); std::string cell_name = refd->name(); if (NULL != _dst_lib->checkcell(cell_name)) { laydata::refnamepair striter = _dst_lib->getcellnamepair(cell_name); // Absolute magnification, absolute angle should be reflected somehow!!! dst->addcellref(_dst_lib, striter, (*wd->location())*_crosscoeff, false); } else { std::string news = "Referenced structure \""; news += cell_name; news += "\" not found. Reference ignored"; tell_log(console::MT_ERROR,news); } }
int tellstdfunc::stdGRID::execute() { bool visu = getBoolValue(); byte no = getByteValue(); if (NULL != DATC->grid(no)) { UNDOcmdQ.push_front(this); UNDOPstack.push_front(new telldata::ttint(no)); UNDOPstack.push_front(new telldata::ttbool(DATC->grid_visual(no))); gridON(no,visu); LogFile << LogFile.getFN() << "(" << no << "," << LogFile._2bool(visu) << ");"; LogFile.flush(); RefreshGL(); } else tell_log(console::MT_ERROR,"Grid is not defined. Use definegrid(...) first"); return EXEC_NEXT; }
void GDSin::gds2ted::polygon(GDSin::GDSpolygon* wd, laydata::tdtcell* dst) { laydata::tdtlayer* wl = static_cast<laydata::tdtlayer*> (dst->securelayer(wd->GetLayer())); pointlist &pl = wd->GetPlist(); laydata::valid_poly check(pl); if (!check.valid()) { std::ostringstream ost; ost << "Layer " << wd->GetLayer(); ost << ": Polygon check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); } else pl = check.get_validated() ; if (check.box()) { wl->addbox(new TP(pl[0]), new TP(pl[2]),false); } else wl->addpoly(pl,false); }
void GDSin::Gds2Ted::top_structure(std::string top_str, bool recursive, bool overwrite) { assert(_src_lib->hierTree()); GDSin::GdsStructure *src_structure = _src_lib->getStructure(top_str.c_str()); if (NULL != src_structure) { GDSin::GDSHierTree* root = _src_lib->hierTree()->GetMember(src_structure); if (recursive) child_structure(root, overwrite); convert_prep(root, overwrite); root = root->GetNextRoot(TARGETDB_LIB); } else { std::ostringstream ost; ost << "GDS import: "; ost << "Structure \""<< top_str << "\" not found in the GDS DB in memory."; tell_log(console::MT_WARNING,ost.str()); } }
bool laydata::tdtdesign::collect_usedlays(std::string cellname, bool recursive, usedlayList& laylist) const { tdtcell* targetcell; if ("" == cellname) targetcell = _target.edit(); else targetcell = getcellnamepair(cellname)->second; if (NULL != targetcell) { targetcell->collect_usedlays(this, recursive, laylist); laylist.sort(); laylist.unique(); std::ostringstream ost; ost << "used layers: {"; for(usedlayList::const_iterator CL = laylist.begin() ; CL != laylist.end();CL++ ) ost << " " << *CL << " "; ost << "}"; tell_log(console::MT_INFO, ost.str()); return true; } else return false; }
//============================================================================= clbr::ClbrFile::ClbrFile(wxString wxfname, DrcLibrary*& drcDB) : InputDBFile (wxfname, false) { std::ostringstream info; if (!status()) { throw EXPTNdrc_reader("Failed to open the input file"); } info << "Parsing \"" << fileName() << "\" using ASCII DRC grammar)"; tell_log(console::MT_INFO,info.str()); _textStream = DEBUG_NEW wxTextInputStream(*_inStream); real precision; std::string cellName = getTextWord(); if (moreData()) precision = _textStream->ReadDouble(); _drcDB = drcDB = DEBUG_NEW DrcLibrary(cellName, precision); CTM defCtm; DrcCell* topCell = _drcDB->registerCellRead(cellName, defCtm); // Now parse the rules do // i.e. at least one rule is expected { // Get the rule name and create a drcRuleCheck object with it // It is considered that at this point is legal to finish the file // That's why getTextWord() is not used, it might throw an exception if (moreData(false)) { wxString wxRuleName = _textStream->ReadWord(); _cRuleName = std::string(wxRuleName.mb_str(wxConvUTF8)); if (_cRuleName.empty()) break; else _cRule = DEBUG_NEW DrcRule(); } else break; // For every new rule reset the value of the current cell _cCell = topCell; ruleMetaData(); ruleDrcResults(); _cCell->registerRuleRead( _cRuleName, _cRule); } while (true); }
laydata::tdtdata* laydata::tdtdesign::addwire(word la, const pointlist* pl, word w) { laydata::valid_wire check(*pl,w); if (!check.valid()) { std::ostringstream ost; ost << "Wire check fails - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); return NULL; } DBbox old_overlap = _target.edit()->overlap(); tdtlayer *actlay = static_cast<tdtlayer*>(targetlayer(la)); modified = true; pointlist vpl = check.get_validated(); for(pointlist::iterator PL = vpl.begin(); PL != vpl.end(); PL++) (*PL) *= _target.rARTM(); laydata::tdtdata* newshape = actlay->addwire(vpl,w); if (_target.edit()->overlapChanged(old_overlap, this)) do {} while(validate_cells()); return newshape; }
int tellstdfunc::stdEDITTOP::execute() { laydata::tdtdesign* ATDB = DATC->lockDB(); telldata::ttlist* selected = make_ttlaylist(ATDB->shapesel()); if (ATDB->edittop()) { UNDOcmdQ.push_front(this); UNDOPstack.push_front(selected); std::string name = ATDB->activecellname(); /*-!-*/ DATC->unlockDB(); browsers::celltree_highlight(name); RefreshGL(); LogFile << LogFile.getFN() << "();"; LogFile.flush(); } else { /*-!-*/ DATC->unlockDB(); tell_log(console::MT_ERROR,"Already on the top level of the curent hierarchy"); delete selected; } return EXEC_NEXT; }
int tellstdfunc::stdEDITPREV::execute() { laydata::tdtdesign* ATDB = DATC->lockDB(); telldata::ttlist* selected = make_ttlaylist(ATDB->shapesel()); if (ATDB->editprev(false)) { UNDOcmdQ.push_front(this); UNDOPstack.push_front(selected); std::string name = ATDB->activecellname(); /*-!-*/ DATC->unlockDB(); browsers::celltree_highlight(name); RefreshGL(); LogFile << LogFile.getFN() << "();"; LogFile.flush(); } else { /*-!-*/ DATC->unlockDB(); tell_log(console::MT_ERROR,"This is the first cell open during this session"); delete selected; } return EXEC_NEXT; }
int tellstdfunc::stdCELLAREF_D::execute() { real stepY = getOpValue(); real stepX = getOpValue(); word row = getWordValue(); word col = getWordValue(); std::string name = getStringValue(); // check that target cell exists - otherwise tmp_draw can't obviously work. // there is another more extensive check when the cell is added, there the circular // references are checked as well laydata::tdtdesign* ATDB = DATC->lockDB(false); laydata::tdtcell *excell = static_cast<laydata::tdtcell*>(ATDB->checkcell(name)); DATC->unlockDB(); if (NULL == excell) { std::string news = "Can't find cell \""; news += name; news += "\" "; tell_log(console::MT_ERROR,news); return EXEC_ABORT; } real DBscale = DATC->DBscale(); int4b istepX = (int4b)rint(stepX * DBscale); int4b istepY = (int4b)rint(stepY * DBscale); // stop the thread and wait for input from the GUI if (!tellstdfunc::waitGUInput(console::op_abind, &OPstack, name, CTM(), istepX, istepY,col,row)) return EXEC_ABORT; // get the data from the stack telldata::ttbnd *bnd = static_cast<telldata::ttbnd*>(OPstack.top());OPstack.pop(); OPstack.push(DEBUG_NEW telldata::ttstring(name)); OPstack.push(DEBUG_NEW telldata::ttpnt(bnd->p())); OPstack.push(DEBUG_NEW telldata::ttreal(bnd->rot())); OPstack.push(DEBUG_NEW telldata::ttbool(bnd->flx())); OPstack.push(DEBUG_NEW telldata::ttreal(bnd->sc())); OPstack.push(DEBUG_NEW telldata::ttint(col)); OPstack.push(DEBUG_NEW telldata::ttint(row)); OPstack.push(DEBUG_NEW telldata::ttreal(stepX)); OPstack.push(DEBUG_NEW telldata::ttreal(stepY)); delete bnd; return stdCELLAREF::execute(); }