int main(int argc,char **argv) { /*set<SmartPtr<Gene> > geneSet; geneSet.insert(new Gene("chr1",0,100,"geneB")); geneSet.insert(new Gene("chr1",0,100,"geneA")); geneSet.insert(new Gene("chr1",0,100,"geneC")); geneSet.insert(new Gene("chr1",50,100,"geneZ")); geneSet.insert(new Gene("chr1",50,60,"geneY")); for(set<SmartPtr<Gene> >::iterator i=geneSet.begin();i!=geneSet.end();i++){ cerr<<(*i)->chrom()<<"\t"<<(*i)->start0()<<"\t"<<(*i)->end1()<<"\t"<<(*i)->name()<<endl; delete *i; }*/ if(argc<2){ cerr<<argv[0]<<"bedfile"<<endl; return 1; } Annotation annot; annot.readBedFile(argv[1]); annot.print(cerr); annot.name_genes["ENAH"]->constructBlockInfo(); annot.name_genes["ENAH"]->printBlockInfo(cerr); //annot.writeBed(cout); return 0; }
QImage visualize_parts(const PartConfig &conf, const PartWindowParam &window_param, const Annotation &annotation) { assert(annotation.size() > 0); double scale = (annotation[0].bottom() - annotation[0].top())/window_param.train_object_height(); cout << "visualize_parts, scale: " << scale << endl; QImage _img; cout << "loading image" << endl; assert(_img.load(annotation.imageName().c_str())); QImage img = _img.convertToFormat(QImage::Format_RGB32); QPainter painter(&img); for (int pidx = 0; pidx < conf.part_size(); ++pidx) { PartBBox part_bbox; get_part_bbox(annotation[0], conf.part(pidx), part_bbox, scale); int coloridx = 1; int pen_width = 2; if (conf.part(pidx).is_detect()) { if (conf.part(pidx).is_root()) draw_bbox(painter, part_bbox, 2, pen_width); else draw_bbox(painter, part_bbox, coloridx, pen_width); } else draw_bbox(painter, part_bbox, -1); // only draw center point and axis (skip bounding box) } cout << "done" << endl; return img; }
Annotation * Task::AddAnnotation(const char *annotation) { Annotation *a = new Annotation; a->SetAnnotation(annotation); Add(a); Fire(Notification::TASK_CHILD_ADDED); return a; }
Annotable::~Annotable() { // Virtual because it's designed to be subclassed... Annotation *A = AnnotationList; while (A) { Annotation *Next = A->getNext(); delete A; A = Next; } }
QString Cluster::_item_label(const Annotation &ann) { QString label = ann.getTargetLabel(); if (_config.show_frame_label) label += "-" + ann.getFrameLabel(); if (_config.show_speaker_label) label += "-" + ann.getSpeaker(); return label; }
void Cluster::setLabel(const QString& label) { ui->lineEdit->setText(label); for (int i=0; i < ui->listWidget->count(); ++i) { QListWidgetItem *item = ui->listWidget->item(i); QVariant data = item->data(Qt::UserRole); Annotation ann = data.value<Annotation>(); ann.setTone(label); } }
void AnnotationSet::insert(const Annotation& p_Annotation) { if(p_Annotation.isEmpty()) return; qint32 hemi = p_Annotation.hemi(); m_qMapAnnots.remove(hemi); m_qMapAnnots.insert(hemi, p_Annotation); }
AnnotationSet::AnnotationSet(const Annotation& p_LHAnnotation, const Annotation& p_RHAnnotation) { if(p_LHAnnotation.hemi() == 0) m_qMapAnnots.insert(0, p_LHAnnotation); else qWarning("Left hemisphere id is not 0. LH annotation not assigned!"); if(p_RHAnnotation.hemi() == 1) m_qMapAnnots.insert(1, p_RHAnnotation); else qWarning("Right hemisphere id is not 1. RH annotation not assigned!"); }
void setObjProperties(std::vector<std::vector<std::string> > &list, IObjContainer &ioc) { std::string name; int id; for( size_t i=0 ; i < ioc.vIObj.size() ; ++i ) { name = ioc.vIObj[i]->getObjName(); id = ioc.vIObj[i]->getObjID(); IObj *ip = ioc.vIObj[i] ; if( name == "X" ) { Annotation *p = dynamic_cast<Annotation*>(ip); p->setTablePath(::TABLE_PATH); if( id == 0 ) notes = &ioc.an[i] ; } else if( name == "CS" ) ; else if( name == "CF" ) { CF *p = dynamic_cast<CF*>(ip); p->setTablePath(::TABLE_PATH); p->enableCheck(); } else if( name == "FD" ) ; else if( name == "IN" ) { InFile *p = dynamic_cast<InFile*>(ip); p->setFilename(::NC_PATH + "/" + ::NC_FILENAME); } else if( name == "OP" ) ; else if( name == "OUT" ) ; else if( name == "QA" ) { QA *p = dynamic_cast<QA*>(ip); p->setTablePath(::TABLE_PATH); } else if( name == "TC" ) ; } return; }
QList<U2Region> GTUtilsAnnotationsTreeView::getAnnotatedRegions(HI::GUITestOpStatus &os) { QList<U2Region> res; QTreeWidget *treeWidget = getTreeWidget(os); GT_CHECK_RESULT(treeWidget != NULL, "Tree widget is NULL", res); QList<QTreeWidgetItem*> treeItems = GTTreeWidget::getItems(treeWidget->invisibleRootItem()); foreach (QTreeWidgetItem* item, treeItems) { AVAnnotationItem* annotationItem = dynamic_cast<AVAnnotationItem*>(item); CHECK_OPERATION(annotationItem != NULL, continue); Annotation *ann = annotationItem->annotation; res.append(ann->getRegions().toList()); }
bool AnnotationNode::setValue (const String& strMemberName, const String* pstrValue) { bool bValueSet = false; Annotation* pObject = dynamic_cast<Annotation*>(m_pObject); if (strMemberName == L"Type") { if (!pstrValue) { pObject->resetValue_Type(); } else { pObject->setType(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Name") { if (!pstrValue) { pObject->resetValue_Name(); } else { pObject->setName(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"Desc") { if (!pstrValue) { pObject->resetValue_Desc(); } else { pObject->setDesc(StringObjectImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } if (strMemberName == L"PclRef") { if (!pstrValue) { pObject->setPclRef(NULL); } else { pObject->setPclRef(StringCollectionImpl::parseString(pstrValue->c_str(), pstrValue->length())); bValueSet = true; } } return bValueSet; }
bool BrainHemisphereTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation, Qt3DCore::QEntity* p3DEntityParent) { //Set name of this item based on the hemispehre information switch (tSurface.hemi()) { case 0: this->setText("Left"); break; case 1: this->setText("Right"); break; default: this->setText("Unknown"); break; } //Add childs bool state = false; //Add surface child m_pSurfaceItem = new BrainSurfaceTreeItem(BrainTreeModelItemTypes::SurfaceItem); *this<<m_pSurfaceItem; state = m_pSurfaceItem->addData(tSurface, p3DEntityParent); //Add annotation child if(!tAnnotation.isEmpty()) { m_pAnnotItem = new BrainAnnotationTreeItem(BrainTreeModelItemTypes::AnnotationItem); *this<<m_pAnnotItem; state = m_pAnnotItem->addData(tSurface, tAnnotation); } return state; }
bool AnnotWriter::UpdateAnnotArray(int pageNo, Annotations* annots, Ref annotArray) { ASSERT(annots->HasChanged()); Object array; array.initArray(mXRef); for (int i = 0; i < annots->Length(); i++) { Annotation* a = annots->At(i); if (!a->IsDeleted()) { AddToAnnots(&array, a); if (a->GetPopup()) AddToAnnots(&array, a->GetPopup()); } } // write to file WriteObject(annotArray, &array); array.free(); return true; }
void save_screenshot(const char *dir, const char* name, const Annotation& ann = Annotation()) { char filename[PATH_MAX]; int ret = snprintf(filename, sizeof(filename), "%s/%s.png", dir, name); assert(ret >= 0 && (size_t)ret < sizeof(filename)); auto screenshot = u8x8_bitmap_to_cimg<uint8_t>(&u8g2, 3, black, white); screenshot.resize(screenshot.width() * SCREENSHOT_SCALE, screenshot.height() * SCREENSHOT_SCALE); // Create a bigger output image size_t width = screenshot.width() + 2*SCREENSHOT_BORDER + (ann.margin[LEFT] + ann.margin[RIGHT]) * SCREENSHOT_SCALE; size_t height = screenshot.height() + 2*SCREENSHOT_BORDER + (ann.margin[TOP] + ann.margin[BOTTOM]) * SCREENSHOT_SCALE; auto output = CImg<uint8_t>(width, height, 1, 3, /* value for all channels */ 255); // Draw the screenshot in the center output.draw_image(translate_x(0, ann), translate_y(0, ann), 0, 0, screenshot); // Draw a 1px border around the screenshot, just inside the // SCREENSHOT_BORDER area (leaving a bit of white space between // the border and the screenshot). draw_outline(output, ann.margin[LEFT] * SCREENSHOT_SCALE, ann.margin[TOP] * SCREENSHOT_SCALE, screenshot.width() + 2 * SCREENSHOT_BORDER, screenshot.height() + 2 * SCREENSHOT_BORDER, grey); ann.annotate(output); output.save_png(filename); printf("Generated %s\n", filename); }
BrainObject::BrainObject(const Surface &tSurface, const Annotation &tAnnotation, Qt3DCore::QEntity *parent) : Renderable3DEntity(tSurface.rr(), tSurface.nn(), tSurface.tris(), -tSurface.offset(), parent) , m_sFilePath(tSurface.filePath()) , m_sSurfFileName(tSurface.fileName()) , m_iHemi(tSurface.hemi()) , m_sSurf(tSurface.surf()) , m_vecCurv(tSurface.curv()) , m_vecOffset(tSurface.offset()) , m_ColorGyri(QColor(125,125,125)) , m_ColorSulci(QColor(50,50,50)) , m_matVert(tSurface.rr()) , m_matTris(tSurface.tris()) , m_matNorm(tSurface.nn()) , m_sAnnotFilePath(tAnnotation.fileName()) { //Create color from curvature information m_matColorsOrig.resize(m_matVert.rows(), m_matVert.cols()); for(int i = 0; i<m_matVert.rows() ; i++) { if(m_vecCurv[i] >= 0) { m_matColorsOrig(i, 0) = m_ColorSulci.redF(); m_matColorsOrig(i, 1) = m_ColorSulci.greenF(); m_matColorsOrig(i, 2) = m_ColorSulci.blueF(); } else { m_matColorsOrig(i, 0) = m_ColorGyri.redF(); m_matColorsOrig(i, 1) = m_ColorGyri.greenF(); m_matColorsOrig(i, 2) = m_ColorGyri.blueF(); } } //Create color from annotation data if annotation is not empty if(tAnnotation.getVertices().rows() != 0) { tAnnotation.toLabels(tSurface, m_qListLabels, m_qListLabelRGBAs); m_matColorsAnnot.resize(m_matVert.rows(), m_matVert.cols()); for(int i = 0; i<m_qListLabels.size(); i++) { FSLIB::Label label = m_qListLabels.at(i); for(int j = 0; j<label.vertices.rows(); j++) { m_matColorsAnnot(label.vertices(j), 0) = m_qListLabelRGBAs.at(i)(0)/255.0; m_matColorsAnnot(label.vertices(j), 1) = m_qListLabelRGBAs.at(i)(1)/255.0; m_matColorsAnnot(label.vertices(j), 2) = m_qListLabelRGBAs.at(i)(2)/255.0; } } } }
bool MeasurementTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation, Qt3DCore::QEntity* p3DEntityParent) { //Generate child items based on surface set input parameters bool state = false; QList<QStandardItem*> itemList = this->findChildren(Data3DTreeModelItemTypes::HemisphereItem); bool hemiItemFound = false; //Search for already created hemi items and add source space data respectivley for(int j = 0; j < itemList.size(); ++j) { if(BrainHemisphereTreeItem* pHemiItem = dynamic_cast<BrainHemisphereTreeItem*>(itemList.at(j))) { if(pHemiItem->data(Data3DTreeModelItemRoles::SurfaceHemi).toInt() == tSurface.hemi()) { hemiItemFound = true; if(tAnnotation.hemi() == tSurface.hemi()) { state = pHemiItem->addData(tSurface, tAnnotation, p3DEntityParent); } else { state = pHemiItem->addData(tSurface, Annotation(), p3DEntityParent); } } } } if(!hemiItemFound) { //Item does not exist yet, create it here. BrainHemisphereTreeItem* pHemiItem = new BrainHemisphereTreeItem(Data3DTreeModelItemTypes::HemisphereItem); if(tAnnotation.hemi() == tSurface.hemi()) { state = pHemiItem->addData(tSurface, tAnnotation, p3DEntityParent); } else { state = pHemiItem->addData(tSurface, Annotation(), p3DEntityParent); } QList<QStandardItem*> list; list << pHemiItem; list << new QStandardItem(pHemiItem->toolTip()); this->appendRow(list); connect(pHemiItem->getSurfaceItem(), &BrainSurfaceTreeItem::colorInfoOriginChanged, this, &MeasurementTreeItem::onColorInfoOriginChanged); } return state; }
bool AnnotationNode::getValue (const String& strMemberName, String& strValue) { bool bValueSet = false; Annotation* pObject = dynamic_cast<Annotation*>(m_pObject); if (strMemberName == L"value") { ValueObject* pValueObj = dynamic_cast<ValueObject*>(m_pObject); if (pValueObj) { if (!pValueObj->isNothing()) { strValue = pValueObj->toString(); bValueSet = true; } } } else if (strMemberName == L"Type") { if (pObject->hasValue_Type()) { strValue = (StringObjectImpl(pObject->getType())).toString(); bValueSet = true; } } else if (strMemberName == L"Name") { if (pObject->hasValue_Name()) { strValue = (StringObjectImpl(pObject->getName())).toString(); bValueSet = true; } } else if (strMemberName == L"Desc") { if (pObject->hasValue_Desc()) { strValue = (StringObjectImpl(pObject->getDesc())).toString(); bValueSet = true; } } else if (strMemberName == L"PclRef") { if (pObject->getPclRef()) { strValue = pObject->getPclRef()->toString(); bValueSet = true; } } return bValueSet; }
// Create new PDF file and append changed or new annotations bool AnnotWriter::WriteTo(const char* name) { if (!CopyFile(name)) return false; if (!mAnnots.HasChanged()) return true; AssignShortFontNames(); mFile = fopen(name, "a+b"); bool ok = mFile != NULL; int numPages = mDoc->getNumPages(); for (int i = 0; ok && i < numPages; i ++) { mPageRef = *mDoc->getCatalog()->getPageRef(i+1); Annotations* a = mAnnots.Get(i); if (a && a->HasChanged()) { Ref annotArray; ok = ok && UpdatePage(i, a, annotArray); ok = ok && UpdateAnnotArray(i, a, annotArray); for (int j = 0; ok && j < a->Length(); j ++) { Annotation* an = a->At(j); if (!an->IsDeleted()) { if (CanWrite(an)) { ok = UpdateAnnot(an); } } else { if (!is_empty_ref(an->GetRef())) { mXRefTable.DeleteRef(an->GetRef()); } } } } } if (ok) { UpdateInfoDict(); UpdateBePDFAcroForm(); UpdateCatalog(); ok = WriteXRefTable(); ok = ok && WriteFileTrailer(); } if (mFile) { fclose(mFile); mFile = NULL; } if (!ok) { // delete file on error unlink(name); } UnassignShortFontNames(); return ok; }
void AnnotationGroup::deleteFromFrame(int frame) { for(unsigned int j = 0; j < vannotations_.size(); j++) { Annotation* annotation = vannotations_[j]; if(annotation->getMaxFrame() >= frame) annotation->setMaxFrame(annotation->getMaxFrame() - 1); if(annotation->getMinFrame() >= frame) annotation->setMinFrame(annotation->getMinFrame() - 1); } }
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 Consumer::writeComment( Comment const& preComment, Comment const& comment, Annotation const& annotation, MarkSet const& marks) { if (!annotation.isEmpty()) { for (unsigned i = 0; i < annotation.count(); ++i) { m_strm.put(token::Nag); m_strm.put(annotation[i]); } m_endOfRun = true; } if (!marks.isEmpty()) { for (unsigned i = 0; i < marks.count(); ++i) { m_strm.put(token::Mark); marks[i].encode(m_data); } m_endOfRun = true; } Byte flag = writeComment(comm::Ante, preComment) | writeComment(comm::Post, comment); if (flag) { m_strm.put(token::Comment); m_data.put(flag); m_endOfRun = true; if (isMainline()) m_lastCommentPos = plyCount() + 1; } }
void AnnotationDataVisitor::visit(MongoDocument &document, void *data) { Annotation *anno = (Annotation *) data; if (anno->getScheme()) { if (anno->getScheme()->type == IAnnotation::TYPE::DISCRETE) { ssi_size_t id = (ssi_size_t)document.int32(Annotation::KEY_NAMES[Annotation::KEY::ANNOTATION_SEGMENT_ID]); ssi_time_t from = (ssi_time_t)document.real(Annotation::KEY_NAMES[Annotation::KEY::ANNOTATION_SEGMENT_FROM]); ssi_time_t to = (ssi_time_t)document.real(Annotation::KEY_NAMES[Annotation::KEY::ANNOTATION_SEGMENT_TO]); ssi_real_t conf = (ssi_real_t)document.real(Annotation::KEY_NAMES[Annotation::KEY::ANNOTATION_SEGMENT_CONF]); anno->add(from, to, id, conf); } else { ssi_real_t score = (ssi_real_t)document.real(Annotation::KEY_NAMES[Annotation::KEY::ANNOTATION_FRAME_SCORE]); ssi_real_t conf = (ssi_real_t)document.real(Annotation::KEY_NAMES[Annotation::KEY::ANNOTATION_FRAME_CONF]); anno->add(score, conf); } } }
bool BrainSurfaceSetTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation, Qt3DCore::QEntity* p3DEntityParent) { //Generate child items based on surface set input parameters bool state = false; QList<QStandardItem*> itemList = this->findChildren(BrainTreeModelItemTypes::HemisphereItem); bool hemiItemFound = false; //Search for already created hemi items and add source space data respectivley for(int j = 0; j<itemList.size(); j++) { BrainHemisphereTreeItem* pHemiItem = dynamic_cast<BrainHemisphereTreeItem*>(itemList.at(j)); if(pHemiItem->data(BrainHemisphereTreeItemRoles::SurfaceHemi).toInt() == tSurface.hemi()) { hemiItemFound = true; if(tAnnotation.hemi() == tSurface.hemi()) { state = pHemiItem->addData(tSurface, tAnnotation, p3DEntityParent); } else { state = pHemiItem->addData(tSurface, Annotation(), p3DEntityParent); } } } if(!hemiItemFound) { //Item does not exist yet, create it here. BrainHemisphereTreeItem* pHemiItem = new BrainHemisphereTreeItem(BrainTreeModelItemTypes::HemisphereItem); if(tAnnotation.hemi() == tSurface.hemi()) { state = pHemiItem->addData(tSurface, tAnnotation, p3DEntityParent); } else { state = pHemiItem->addData(tSurface, Annotation(), p3DEntityParent); } *this<<pHemiItem; //same as this->appendRow(pSurfaceItem) } return state; }
QString GTUtilsAnnotationsTreeView::getAVItemName(HI::GUITestOpStatus &os, AVItem* avItem) { GT_CHECK_RESULT(avItem != NULL, "avItem is NULL", ""); switch (avItem->type) { case AVItemType_Annotation: { AVAnnotationItem* avAnnotationItem = (AVAnnotationItem*)avItem; GT_CHECK_RESULT(avAnnotationItem != NULL, "avAnnotationItem is NULL", ""); Annotation *annotation = avAnnotationItem->annotation; return annotation->getName(); } break; case AVItemType_Group: { AVGroupItem* avGroupItem = (AVGroupItem*)avItem; GT_CHECK_RESULT(avGroupItem!= NULL, "avAnnotationItem is NULL", ""); AnnotationGroup *group= avGroupItem->group; return group->getName(); } break; case AVItemType_Qualifier: { AVQualifierItem* avQualifierItem = (AVQualifierItem*)avItem; GT_CHECK_RESULT(avQualifierItem != NULL, "avQualifierItem is NULL", ""); return avQualifierItem->qName; } break; default: break; } return ""; }
void EnzymesADVContext::buildMenu(GObjectView *v, QMenu *m) { AnnotatedDNAView *av = qobject_cast<AnnotatedDNAView *>(v); SAFE_POINT(NULL != av, "Invalid sequence view",); CHECK(av->getSequenceInFocus()->getAlphabet()->isNucleic(),); QMenu *cloningMenu = new QMenu(tr("Cloning"), m); cloningMenu->menuAction()->setObjectName("Cloning"); cloningMenu->addActions(cloningActions); QAction *exportMenuAction = GUIUtils::findAction(m->actions(), ADV_MENU_EXPORT); m->insertMenu(exportMenuAction, cloningMenu); if (!av->getAnnotationsSelection()->getSelection().isEmpty()) { Annotation *a = av->getAnnotationsSelection()->getSelection().first().annotation; const QString annName = a->getName(); const QString groupName = a->getGroup()->getName(); const int annCount = a->getGroup()->getAnnotations().size(); if (annName == PRIMER_ANNOTATION_NAME && groupName.startsWith(PRIMER_ANNOTATION_GROUP_NAME) && 2 == annCount) { QAction *a = findViewAction(v, CREATE_PCR_PRODUCT_ACTION_NAME); SAFE_POINT(NULL != a, "Invalid menu action",); cloningMenu->addAction(a); }
//@Override void Method::build_c_member_id_load(std::ostream &os) { os << std::endl; Annotation *annotation = get_annotation_at("MinApi"); if (annotation) { os << build_indent() << "if (J4A_GetSystemAndroidApiLevel(env) >= " << annotation->get_value() << ") {" << std::endl; increase_build_indent(4); } os << build_indent() << "class_id = " << get_this_class()->get_c_jni_id() << ";\n"; os << build_indent() << "name = \"" << get_c_jni_method_name() << "\";\n"; os << build_indent() << "sign = \"" << get_c_jni_sign() << "\";\n"; os << build_indent() << get_c_jni_id() << " = " << (is_static() ? "J4A_GetStaticMethodID__catchAll" : "J4A_GetMethodID__catchAll") << "(env, class_id, name, sign);\n"; os << build_indent() << "if (" << get_c_jni_id() << " == NULL)\n"; os << build_indent() << " goto fail;\n"; if (annotation) { increase_build_indent(-4); os << build_indent() << "}" << std::endl; } }
void AnnotationDeserializer::readAnnotation(Annotation & annotation) { uint32_t type_id = readValue<uint32_t>(_stream); uint8_t features = readValue<uint8_t>(_stream); uint32_t size = getInt1_2_4Bytes(_stream); const AnnotationType *type = _repo.getAnnotationType(type_id); if (!type) { // LOG(warning, "Skipping unknown annotation of type %u", type_id); _stream.adjustReadPos(size); return; } annotation.setType(type); SpanNode *span_node = 0; if (features & 1) { // has span node uint32_t span_node_id = getInt1_2_4Bytes(_stream); span_node = _nodes[span_node_id]; } if (features & 2) { // has value uint32_t data_type_id = readValue<uint32_t>(_stream); const DataType *data_type = _repo.getDataType(data_type_id); if (!data_type) { LOG(warning, "Unknown data type %d", data_type_id); _stream.adjustReadPos(size - sizeof(uint32_t)); } else { FieldValue::UP value(data_type->createFieldValue()); VespaDocumentDeserializer deserializer(_repo, _stream, _version); deserializer.read(*value); annotation.setFieldValue(std::move(value)); } } if (span_node) { annotation.setSpanNode(*span_node); } }
bool Nepomuk::AnnotationDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index ) { if ( event->type() == QEvent::MouseButtonPress ) { QMouseEvent* me = static_cast<QMouseEvent*>( event ); if ( me->button() == Qt::LeftButton ) { if ( plusRect( option ).contains( me->pos() ) ) { kDebug() << "Clicked plus"; Annotation* anno = index.data( AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>(); anno->create( d->resource ); delete anno; return true; } else if ( minusRect( option ).contains( me->pos() ) ) { kDebug() << "Clicked minus"; Annotation* anno = index.data( AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>(); anno->setUserRelevance( 0.0 ); delete anno; return true; } } } return false; }
bool RowData::push_annotation(const Annotation &a) { try { _annotations.push_back(a); _max_annotation = max(_max_annotation, a.end_sample() - a.start_sample()); if (a.end_sample() != a.start_sample()) _min_annotation = min(_min_annotation, a.end_sample() - a.start_sample()); return true; } catch (const std::bad_alloc&) { return false; } }
bool BrainAnnotationTreeItem::addData(const Surface& tSurface, const Annotation& tAnnotation) { //Create color from annotation data if annotation is not empty if(!tAnnotation.isEmpty()) { QByteArray arrayColorsAnnot; arrayColorsAnnot.resize(tAnnotation.getVertices().rows() * 3 * (int)sizeof(float)); float *rawArrayColors = reinterpret_cast<float *>(arrayColorsAnnot.data()); QList<FSLIB::Label> qListLabels; QList<RowVector4i> qListLabelRGBAs; tAnnotation.toLabels(tSurface, qListLabels, qListLabelRGBAs); for(int i = 0; i<qListLabels.size(); i++) { FSLIB::Label label = qListLabels.at(i); for(int j = 0; j<label.vertices.rows(); j++) { rawArrayColors[label.vertices(j)*3+0] = qListLabelRGBAs.at(i)(0)/255.0; rawArrayColors[label.vertices(j)*3+1] = qListLabelRGBAs.at(i)(1)/255.0; rawArrayColors[label.vertices(j)*3+2] = qListLabelRGBAs.at(i)(2)/255.0; } } //Add data which is held by this BrainAnnotationTreeItem QVariant data; data.setValue(arrayColorsAnnot); this->setData(data, BrainAnnotationTreeItemRoles::AnnotColors); data.setValue(qListLabels); this->setData(data, BrainAnnotationTreeItemRoles::LabeList); data.setValue(tAnnotation.getLabelIds()); this->setData(data, BrainAnnotationTreeItemRoles::LabeIds); //Add annotation meta information as item children BrainTreeMetaItem *itemAnnotFileName = new BrainTreeMetaItem(BrainTreeMetaItemTypes::AnnotFileName, tAnnotation.fileName()); itemAnnotFileName->setEditable(false); *this<<itemAnnotFileName; data.setValue(tAnnotation.fileName()); itemAnnotFileName->setData(data, BrainAnnotationTreeItemRoles::AnnotFileName); BrainTreeMetaItem *itemAnnotPath = new BrainTreeMetaItem(BrainTreeMetaItemTypes::AnnotFilePath, tAnnotation.filePath()); itemAnnotPath->setEditable(false); *this<<itemAnnotPath; data.setValue(tAnnotation.filePath()); itemAnnotFileName->setData(data, BrainAnnotationTreeItemRoles::AnnotFilePath); } return true; }