/*! Insert Parameters in AST of given scad file form of annotations */ void CommentParser::collectParameters(const char *fulltext, FileModule *root_module) { // Get all groups of parameters GroupList groupList = collectGroups(std::string(fulltext)); int parseTill=getLineToStop(fulltext); // Extract parameters for all literal assignments for (auto &assignment : root_module->scope.assignments) { if (!assignment.expr.get()->isLiteral()) continue; // Only consider literals // get location of assignment node int firstLine = assignment.location().firstLine(); if(firstLine>=parseTill ) continue; // making list to add annotations AnnotationList *annotationList = new AnnotationList(); // Extracting the parameter comment std::string comment = getComment(std::string(fulltext), firstLine); // getting the node for parameter annnotataion shared_ptr<Expression> params = CommentParser::parser(comment.c_str()); if (!params) { params = shared_ptr<Expression>(new Literal(ValuePtr(std::string("")))); } // adding parameter to the list annotationList->push_back(Annotation("Parameter", params)); //extracting the description std::string descr = getDescription(std::string(fulltext), firstLine - 1); if (descr != "") { //creating node for description shared_ptr<Expression> expr(new Literal(ValuePtr(std::string(descr.c_str())))); annotationList->push_back(Annotation("Description", expr)); } // Look for the group to which the given assignment belong int i=0; for (;i<groupList.size() && groupList[i].lineNo<firstLine;i++); i--; if (i >= 0) { //creating node for description shared_ptr<Expression> expr(new Literal(ValuePtr(groupList[i].commentString))); annotationList->push_back(Annotation("Group", expr)); } assignment.addAnnotations(annotationList); } }
void mouseCallback(int event, int x, int y, int flags, void* userdata) { GUI* gui = static_cast<GUI*>(userdata); double px = (double)x / gui->image.image->getRGBImage().cols; double py = (double)y / gui->image.image->getRGBImage().rows; if (event == cv::EVENT_LBUTTONDOWN && gui->selected_type == "exclude") { gui->image.excluded = true; std::cout << "Excluding image" << std::endl; gui->image_changed = true; gui->redraw(); } else if (event == cv::EVENT_LBUTTONDOWN && gui->selected_type.size() > 5 && gui->selected_type.substr(0, 5) == "area:") { gui->image.area_name = gui->selected_type.substr(5); std::cout << "Setting area to '" << gui->image.area_name << "'" << std::endl; gui->image_changed = true; gui->redraw(); } else if (event == cv::EVENT_LBUTTONDOWN || event == cv::EVENT_RBUTTONDOWN) { // std::cout << px << ", " << py << std::endl; std::vector<Annotation>::iterator it_clicked = gui->image.annotations.end(); // Loop over all annotations and check whether we have clicked one for (std::vector<Annotation>::iterator it = gui->image.annotations.begin(); it != gui->image.annotations.end(); ++it) { Annotation& a = *it; int a_x = a.px * gui->image.image->getRGBImage().cols; int a_y = a.py * gui->image.image->getRGBImage().rows; if (x > a_x - gui->CIRCLE_RADIUS && x < a_x + gui->CIRCLE_RADIUS && y > a_y - gui->CIRCLE_RADIUS && y < a_y + gui->CIRCLE_RADIUS) { it_clicked = it; break; } } if (it_clicked != gui->image.annotations.end() && event == cv::EVENT_RBUTTONDOWN) { gui->image.annotations.erase(it_clicked); gui->image_changed = true; } if (it_clicked == gui->image.annotations.end() && event == cv::EVENT_LBUTTONDOWN && !gui->selected_type.empty()) { gui->image.annotations.push_back(Annotation(gui->selected_type, px, py)); gui->types.insert(gui->selected_type); gui->image_changed = true; } gui->redraw(); } }
Annotation::List Parser::parseAnnotation( ParserContext *context, const QDomElement &element ) { Annotation::List result; QDomElement child; for( child = element.firstChildElement(); !child.isNull(); child = child.nextSiblingElement() ) { NSManager namespaceManager( context, child ); const QName name( child.tagName() ); if ( name.localName() == QLatin1String("documentation") ) { result.append( Annotation( child ) ); } else if ( name.localName() == QLatin1String("appinfo") ) { result.append( Annotation( child ) ); } } return result; }
Annotation::List Parser::parseAnnotation( ParserContext *, const QDomElement &element ) { Annotation::List result; QDomElement e; for( e = element.firstChildElement(); !e.isNull(); e = e.nextSiblingElement() ) { QName name = e.tagName(); if ( name.localName() == "documentation" ) { result.append( Annotation( e ) ); } else if ( name.localName() == "appinfo" ) { result.append( Annotation( e ) ); } } return result; }
void Cluster::addAnnotation(const Annotation &ann) { if (ann.getTone() != getLabel()) Annotation(ann).setTone(ui->lineEdit->text()); QListWidgetItem *item = new QListWidgetItem(_item_label(ann)); item->setData(Qt::UserRole, QVariant::fromValue<Annotation>(ann)); ui->listWidget->addItem(item); ui->f0Display->addAnnotation(ann); }
void PageSettings::Load(const XMLNode& node) { if (MakeCString(node.tagName) != pszTagPageSettings) return; list<XMLNode>::const_iterator it; for (it = node.childElements.begin(); it != node.childElements.end(); ++it) { const XMLNode& child = *it; if (MakeCString(child.tagName) == pszTagAnnotation) { anno.push_back(Annotation()); Annotation& annotation = anno.back(); annotation.Load(child); if (annotation.rects.empty()) anno.pop_back(); } } }
boolean TextFileScript::Definition (ostream& out) { TextFileComp* comp = (TextFileComp*) GetSubject(); TextGraphic* g = comp->GetText(); int h = g->GetLineHeight(); out << "textfile("; out << h << ",\"" << comp->GetPathname() << "\""; if (comp->GetBegstr()) { out << " :begstr "; ParamList::output_text(out, comp->GetBegstr(), 0); } if (comp->GetEndstr()) { out << " :endstr "; ParamList::output_text(out, comp->GetEndstr(), 0); } if (comp->GetLineWidth() > -1) out << " :linewidth " << comp->GetLineWidth(); float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } Annotation(out); Attributes(out); out << ")"; return out.good(); }
void PageInfo::DecodeAnno(GP<ByteStream> pAnnoStream) { if (pAnnoStream == NULL) return; pAnnoStream->seek(0); GP<DjVuAnno> pDjVuAnno = DjVuAnno::create(); pDjVuAnno->decode(pAnnoStream); pAnt = pDjVuAnno->ant; if (pAnt != NULL) { for (GPosition pos = pAnt->map_areas; pos; ++pos) { GP<GMapArea> pArea = pAnt->map_areas[pos]; anno.push_back(Annotation()); anno.back().Init(pArea, szPage, nInitialRotate); } } bAnnoDecoded = true; }
boolean TextScript::Definition (ostream& out) { TextOvComp* comp = (TextOvComp*) GetSubject(); TextGraphic* g = comp->GetText(); const char* text = g->GetOriginal(); int h = g->GetLineHeight(); out << "text("; out << h << ","; int indent_level = 0; Component* parent = comp; do { parent = parent->GetParent(); indent_level++; } while (parent != nil); ParamList::output_text(out, text, indent_level); float sep = g->GetLineHeight() - 1; // correct for vert shift Transformer corrected, *t = g->GetTransformer(); corrected.Translate(0., sep); if (t == nil) { g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); } else { t->Reference(); corrected.Postmultiply(t); g->SetTransformer(&corrected); TextGS(out); g->SetTransformer(t); Unref(t); } Annotation(out); Attributes(out); out << ")"; return out.good(); }