void Lien::ajouteElementsAuGroupe() { calculeCoordonnees(); addToGroup(laLigne); addToGroup(texte1); addToGroup(texte2); addToGroup(condition); }
GraphicsObject::GraphicsObject(Perso *obj) : QObject(), _perso(obj) { // Get images depending on the name QStringList direction_list; direction_list << "haut" << "bas" << "gauche" << "droite"; for(int i = 0 ; i < direction_list.size() ; ++ i) { // For each direction, we create a list of images QSharedPointer<ImageAnimation> img(new ImageAnimation()); img.data()->_current_img = 0; int tile_id = 0; bool file_exists = true; // Load image for this direction while files exist for this direction while(file_exists) { // Check for next file const QString filename = Constants::IMAGES_PERSOS_PATH + QString::fromStdString(obj->get_name()) + "_" + direction_list.at(i) + QString("_%1.png").arg(tile_id); if(QFile::exists(filename)) { // File exists, we load the pixmap img.data()->_items.append(new QGraphicsPixmapItem(QPixmap(filename).scaled(TILE_SIZE, TILE_SIZE), this)); img.data()->_items.last()->setVisible(false); } else { file_exists = false; } std::cout << "Looking for " << filename.toStdString() << " : " << file_exists<< std::endl; tile_id ++; } _pixmaps[(Direction)i] = img; } // Store default pixmap _current_pixmap = _pixmaps[BOTTOM]->_items[0]; _current_pixmap->setVisible(true); addToGroup(_current_pixmap); // Draw ellipsis on the bottom right of the perso _status = new QGraphicsEllipseItem(this); const int w = _current_pixmap->pixmap().size().width(); const int size_ellipse = w/4; _status->setRect(w-size_ellipse, w-size_ellipse, size_ellipse, size_ellipse); _status->setBrush(QBrush(Qt::green)); addToGroup(_status); // Box drawn when we select the perso _selected_item_box = new QGraphicsRectItem(QRectF(0., 0., boundingRect().width(), boundingRect().height()), this); _selected_item_box->setPen(QPen(QBrush(QColor(Qt::yellow)), 1)); _selected_item_box->setVisible(false); // Connect animation timer connect(&_move_timer, SIGNAL(timeout()), this, SLOT(updateAnimation())); // Connection between the graphical object and the data connect(_perso, SIGNAL(signal_set_has_moved(bool)), this, SLOT(slot_perso_has_move(bool))); // Connection between the graphical object and the data connect(_perso, SIGNAL(signal_perso_is_dead(Perso *)), this, SLOT(slot_perso_dead(Perso *))); }
void LegendGroup::updateModel() { QList<QGraphicsItem*> pool; for (auto l : legends) { removeFromGroup(l); pool.append(l); } for (auto t : texts) { removeFromGroup(t); pool.append(t); } for (auto l : pool) delete l; legends.clear(); texts.clear(); for (int i=0; i<model->rowCount(); i++) { auto marker = model->at(i); QString l = marker->label() + "\t: " + QString::number(marker->count()); QColor color1 = marker->color1(); QColor color2 = marker->color2(); int type = marker->activeType(); if (0 == type) { QRectF r = MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize); QLineF l(r.topLeft(), r.bottomRight()); auto marker = new ArrowItem(l); marker->setArrowhead(ArrowHead::Start); marker->setColor1(color1); marker->setColor2(color2); marker->setPenWidth(myPenWidth); legends.append(marker); addToGroup(marker); } else if (1 == type) { auto marker = new RectItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize)); marker->setColor1(color1); marker->setColor2(color2); marker->setPenWidth(myPenWidth); legends.append(marker); addToGroup(marker); } else { auto marker = new EllipseItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize)); marker->setColor1(color1); marker->setColor2(color2); marker->setPenWidth(myPenWidth); legends.append(marker); addToGroup(marker); } auto label = new RichTextItem(l); label->setFont(myFont); label->setFontSize(myFontSize); label->setKeyPressFunc([this](QKeyEvent* event) { updateRect(); }); label->setTextInteractionFlags(Qt::TextEditorInteraction); label->setFlag(QGraphicsItem::ItemIsFocusable); QPointF textPos = legends.at(i)->boundingRect().center() + QPointF(legends.at(i)->boundingRect().width()/2+20, -label->boundingRect().height()*0.5); label->setPos(textPos); label->setZValue(1000); texts.append(label); addToGroup(label); } calculatePos(); }
AnchorHandleItem::AnchorHandleItem(QGraphicsItem *parent, const AnchorController &anchorController) : QGraphicsItemGroup(parent), m_anchorControllerData(anchorController.weakPointer()), m_sourceAnchorLinePathItem(new QGraphicsPathItem(this)), m_arrowPathItem(new QGraphicsPathItem(this)), m_targetAnchorLinePathItem(new QGraphicsPathItem(this)), m_targetNamePathItem(new QGraphicsPathItem(this)) { addToGroup(m_sourceAnchorLinePathItem); addToGroup(m_arrowPathItem); addToGroup(m_targetAnchorLinePathItem); addToGroup(m_targetNamePathItem); setFlag(QGraphicsItem::ItemIsMovable, true); }
void PropertyList::removeProperty(const QString &name) { if (m_list.contains(name)) { QString group = m_groupOfProperty[m_list[name]]; removeFromGroup(m_list[name]); Property *property; for (property = m_list[name]->list.first(); property; property = m_list[name]->list.next()) { if (m_propertyOwner) emit aboutToDeleteProperty(property); m_list[property->name()]->removeProperty(property); if (m_propertyOwner) delete property; } if (m_list[name]->list.count() == 0) { // qWarning("rp2: removing mp for %s itself", name.ascii()); delete m_list[name]; m_list.remove(name); } else { addToGroup(group, m_list[name]); } } }
//----------------------------------------------------------------------------- // Function: StickyNote::createGluedEdge() //----------------------------------------------------------------------------- void StickyNote::createGluedEdge() { QColor topColor = QColor("lemonChiffon").darker(103); QGraphicsRectItem* glueEdge = new QGraphicsRectItem(0, 0, DEFAULT_WIDTH, TOP_OFFSET); QPen outlinePen(Qt::black, 0, Qt::NoPen); glueEdge->setPen(outlinePen); glueEdge->setBrush(topColor); addToGroup(glueEdge); timeLabel_ = new QGraphicsSimpleTextItem(); timeLabel_->setBrush(Qt::gray); timeLabel_->setPos(5, TOP_OFFSET/2 - QFontMetrics(timeLabel_->font()).height()/2); addToGroup(timeLabel_); }
void DynCircleAttr::resetCircle(short alpha, bool fill, bool frame, QColor cFill, QColor cFrame) { if(pCircle) { delete pCircle; pCircle = NULL; } QRectF rect = QRectF(0,0,100,100); pCircle = new QElipseItem(rect); pCircle->SetBackColor(cFill); if(fill) { pCircle->SetPattern(1); pCircle->SetBackColor(cFill); } else { pCircle->SetPattern(0); } pCircle->SetAlpha(alpha); if(frame) { pCircle->SetLineType(1); pCircle->SetLineWidth(1); pCircle->SetLineColor(cFrame); } else { pCircle->SetLineType(0); } addToGroup(pCircle); }
//----------------------------------------------------------------------------- // Function: StickyNote::createWritableArea() //----------------------------------------------------------------------------- void StickyNote::createWritableArea() { textArea_ = new ColorFillTextItem(); textArea_->setFill(QColor("lemonChiffon")); textArea_->setTextWidth(DEFAULT_WIDTH); textArea_->setPos(0, TOP_OFFSET); addToGroup(textArea_); }
void ClientMapTagItem::setupItems() { QString clientName = ""; if(m_Client.get() != NULL) clientName = m_Client->getName(); m_ClientNameItem = new QGraphicsTextItem(clientName, this); m_ClientTagItem = new QGraphicsPixmapItem(m_NormalIcon, this); m_RectItem = new ClientMapRectItem(QRectF(m_ClientNameItem->pos(),QSizeF(25,25)), this); m_ClientNameItem->setDefaultTextColor(QColor("Green")); m_RectItem->setPen(QPen(QColor("blue"))); m_RectItem->hide(); addToGroup(m_ClientNameItem); addToGroup(m_ClientTagItem); addToGroup(m_RectItem); }
/** * If it is a group it is unrolled and each member added * @param workspace A pointer to the workspace to add */ void GroupWorkspaces::addToGroup(const API::Workspace_sptr &workspace) { auto localGroup = boost::dynamic_pointer_cast<WorkspaceGroup>(workspace); if (localGroup) { addToGroup(localGroup->getNames()); // Remove the group from the ADS AnalysisDataService::Instance().remove(workspace->name()); } else { m_group->addWorkspace(workspace); } }
int MulticastProvider::callServer() { if (createSocket()) { if (tryToBind()) { if (setSocketOptions()) { if (addToGroup()) { return socketDescriptor; } } } } return -1; }
void Shape::setLabel(const char * text, double relX, double relY) { if(!m_label) { m_label = new QGraphicsTextItem(this, scene()); m_label->setFont(QFont( m_label->font().family(), m_fontSize)); m_label->setDefaultTextColor( m_fontColor ); m_label->translate(relX,relY); addToGroup(m_label); } m_label->setPlainText(text); }
MarkerItem::MarkerItem(const QRectF& Rect, int type, QGraphicsItem* parent): QGraphicsItemGroup(parent), rect(Rect.normalized()), myType(type) { mode = Rectangle; _isSinglePoint = false; arrow = new ArrowItem(QLineF(rect.center(), rect.bottomRight())); arrow->setArrowhead(ArrowHead::Start); box = new RectItem(rect); circle = new EllipseItem(rect); arrow->setIsMarker(true); box->setIsMarker(true); circle->setIsMarker(true); text = new SimpleTextItem(""); setFlag(QGraphicsItem::ItemIsSelectable); addToGroup(arrow); addToGroup(box); addToGroup(circle); addToGroup(text); setType(type); HasContainer = false; }
QGraphicsRectItem* ScreenGrabberChooserRectItem::createHandleItem(QGraphicsScene* scene) { QGraphicsRectItem* handle = new QGraphicsRectItem(0, 0, HandleSize, HandleSize); handle->setPen(QPen(Qt::blue)); handle->setBrush(Qt::NoBrush); scene->addItem(handle); addToGroup(handle); handle->installSceneEventFilter(this); return handle; }
//LegendItem LegendItem::LegendItem(const QPointF& Clicked, int type, QGraphicsItem* parent): QGraphicsItemGroup(parent), clicked(Clicked), myType(type) { mode = SinglePoint; _isSinglePoint = true; mySize = 20; arrow = new ArrowItem(QLineF(clicked, clicked+QPointF(mySize, mySize))); arrow->setArrowhead(ArrowHead::Start); box = new RectItem(QRectF(clicked-QPointF(mySize, mySize), clicked+QPointF(mySize, mySize))); circle = new EllipseItem(QRectF(clicked-QPointF(mySize, mySize), clicked+QPointF(mySize, mySize))); arrow->setIsMarker(true); box->setIsMarker(true); circle->setIsMarker(true); text = new RichTextItem(""); text->setTextInteractionFlags(Qt::TextEditable); //setFlag(QGraphicsItem::ItemIsSelectable); addToGroup(arrow); addToGroup(box); addToGroup(circle); addToGroup(text); setType(type); }
//MarkerItem MarkerItem::MarkerItem(const QPointF& Clicked, int type, QGraphicsItem* parent): QGraphicsItemGroup(parent), clicked(Clicked), myType(type) { mode = SinglePoint; _isSinglePoint = true; mySize = 20; arrow = new ArrowItem(QLineF(clicked, clicked+QPointF(mySize, mySize))); arrow->setArrowhead(ArrowHead::Start); box = new RectItem(QRectF(clicked-QPointF(mySize, mySize), clicked+QPointF(mySize, mySize))); circle = new EllipseItem(QRectF(clicked-QPointF(mySize, mySize), clicked+QPointF(mySize, mySize))); arrow->setIsMarker(true); box->setIsMarker(true); circle->setIsMarker(true); text = new SimpleTextItem(""); setFlag(QGraphicsItem::ItemIsSelectable); addToGroup(arrow); addToGroup(box); addToGroup(circle); addToGroup(text); setType(type); HasContainer = false; }
MarkerItem::MarkerItem(const QLineF& Line, int type, QGraphicsItem* parent): QGraphicsItemGroup(parent), line(Line), myType(type) { mode = MarkerItem::Line; _isSinglePoint = false; arrow = new ArrowItem(line); arrow->setArrowhead(ArrowHead::Start); QRectF tmp(line.p1()-(line.p2()-line.p1()), line.p2()); box = new RectItem(tmp.normalized()); circle = new EllipseItem(tmp.normalized()); arrow->setIsMarker(true); box->setIsMarker(true); circle->setIsMarker(true); text = new SimpleTextItem(""); setFlag(QGraphicsItem::ItemIsSelectable); addToGroup(arrow); addToGroup(box); addToGroup(circle); addToGroup(text); setType(type); HasContainer = false; }
AngleItem::AngleItem(QGraphicsItem* parent) : QGraphicsItemGroup(parent), _center(new QGraphicsRectItem(this)), _edge1(new QGraphicsRectItem(this)), _edge2(new QGraphicsRectItem(this)), _line1(new QGraphicsLineItem(this)), _line2(new QGraphicsLineItem(this)) { addToGroup(_line1); addToGroup(_line2); addToGroup(_center); addToGroup(_edge1); addToGroup(_edge2); _edge1->setPen(Qt::NoPen); _edge1->setBrush(Qt::red); _edge2->setPen(Qt::NoPen); _edge2->setBrush(Qt::red); _center->setPen(Qt::NoPen); _center->setBrush(Qt::red); }
PropertyBuffer::PropertyBuffer(PropertyList *list) :PropertyList(false) { //deep copy of m_list for (QMap<QString, MultiProperty*>::const_iterator it = list->m_list.begin(); it != list->m_list.end(); ++it) { MultiProperty *mp = new MultiProperty(*it.data()); mp->m_propertyList = this; addToGroup(list->m_groupOfProperty[it.data()], mp); m_list[it.key()] = mp; } connect(list, SIGNAL(propertyValueChanged(Property*)), this, SLOT(intersectedValueChanged(Property*))); }
void CmdAdd::ExecuteIntern() { if (checkSizeGreater(3)) { // Try casting of second argument to Path try { const Path path(getArgument(1)); // Number in path are one-based addToGroup(path); } catch (const PathNotValidException & ex){ const Path path(Helpers::convertToString(specification->size() + 1)); // Number in path are one-based addMain(path); } } }
rce::gui::RGraphicsFlagItem:: RGraphicsFlagItem(const QPointF &position, const QString &flagText, const QColor &textColour, const QFont &font, const QColor &flagColour, QGraphicsItem *parent): QGraphicsItemGroup(parent) { setFlag(QGraphicsItem::ItemIgnoresTransformations); setPos(position); labelItem_ = new rce::gui::RGraphicsTextShapeItem(flagText, font, Qt::AlignLeft | Qt::AlignBottom, QPointF(), NULL); labelItem_->setOriginShift(QPointF(RCE_FLAG_DSPLCMNT_X, -RCE_FLAG_DSPLCMNT_Y)); addToGroup(labelItem_); labelItem_->setPen(Qt::NoPen); labelItem_->setBrush(QBrush(textColour)); labelItem_->setPos(0,0); flagItem_ = new QGraphicsPathItem(NULL); addToGroup(flagItem_); flagItem_->setBrush(QBrush(flagColour)); flagItem_->setPen(QPen(QBrush(flagColour), RCE_DEFAULT_FLAG_POLE_WIDTH)); flagItem_->setPos(0,0); flagItem_->setZValue(3); labelItem_->setZValue(4); //regenerate(); }
vector<pair<unsigned, unsigned> > Sparse6Writer::constructGroups(const IntegerMatrix& integerMatrix) { vector<pair<unsigned, unsigned> > group; vector< vector< unsigned> > matrix = integerMatrix.getMatrix(); pair<unsigned, unsigned> lastEdge; unsigned multiEdgecounter; for (unsigned col = 0; col < matrix.size(); ++col) for (unsigned row = 0; row <= col; ++row) { // if there is at least one edge if (matrix[col][row]) { // if we are dealing with the first edge if (group.empty()) { // if the first edge is from the first node to the first node if (row == 0 && col == 0) { addToGroup(0, 0, group); } else { addToGroup(0, col, group); addToGroup(0, row, group); } } // 2 choices, we stay in the same col else if (lastEdge.second == col) { addToGroup(0, row, group); // printing happens implicitly because row is always smaller than col } // we change from colom else { addToGroup(0, col, group); addToGroup(0, row, group); } multiEdgecounter = matrix[col][row]; // save all the edges while (multiEdgecounter > 1) { multiEdgecounter--; addToGroup(0, row, group); } lastEdge.first = row; lastEdge.second = col; } } return group; }
LegendGroup::LegendGroup(const QPointF& Clicked, MarkerModel* model, QGraphicsItem* parent): QGraphicsItemGroup(parent), origin(Clicked), model(model) { mySize = 20; frame = new RectItem(QRectF()); frame->setBrush(QColor(255, 255, 255, 192)); setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsGeometryChanges); addToGroup(frame); auto s = Settings("LegendL"); myPenWidth = s.penWidth(); mySize = s.size(); myFont = s.font(); myFontSize = s.fontSize(); updateModel(); }
QStarItem::QStarItem(qreal x, qreal y, const Star &star, QGraphicsItem *parent) { this->starRadius = 0.025; nameItem = new QGraphicsTextItem(star.Name); // addToGroup(nameItem); ellipseItem = new QGraphicsEllipseItem(); ellipseItem->setPen(QPen(QBrush(Qt::yellow),0)); ellipseItem->setBrush(QBrush(Qt::yellow)); addToGroup(ellipseItem); setPos(x, y); setStar(star); }
CGroupListView::CGroupListView(QWidget *parent, CGroupList *model) : QTreeView(parent) { setModel(model); setItemDelegate(new CGroupListViewDelegate(this)); sortByColumn(COL_GROUP_NAME, Qt::AscendingOrder); setSelectionMode(QAbstractItemView::SingleSelection); setSortingEnabled(true); setAllColumnsShowFocus(true); setAlternatingRowColors(true); setAcceptDrops(true); setDragDropMode(QAbstractItemView::DropOnly); setDropIndicatorShown(true); setDragEnabled(false); header()->setSortIndicatorShown(true); setRootIsDecorated(false); itsMenu=new QMenu(this); itsDeleteAct=itsMenu->addAction(QIcon::fromTheme("list-remove"), i18n("Remove"), this, SIGNAL(del())); itsMenu->addSeparator(); itsEnableAct=itsMenu->addAction(QIcon::fromTheme("enablefont"), i18n("Enable"), this, SIGNAL(enable())); itsDisableAct=itsMenu->addAction(QIcon::fromTheme("disablefont"), i18n("Disable"), this, SIGNAL(disable())); itsMenu->addSeparator(); itsRenameAct=itsMenu->addAction(QIcon::fromTheme("edit-rename"), i18n("Rename..."), this, SLOT(rename())); if(!Misc::app(KFI_PRINTER).isEmpty()) { itsMenu->addSeparator(); itsPrintAct=itsMenu->addAction(QIcon::fromTheme("document-print"), i18n("Print..."), this, SIGNAL(print())); } else itsPrintAct=0L; itsMenu->addSeparator(); itsExportAct=itsMenu->addAction(QIcon::fromTheme("document-export"), i18n("Export..."), this, SIGNAL(zip())); setWhatsThis(model->whatsThis()); header()->setWhatsThis(whatsThis()); connect(this, SIGNAL(addFamilies(QModelIndex,QSet<QString>)), model, SLOT(addToGroup(QModelIndex,QSet<QString>))); connect(this, SIGNAL(removeFamilies(QModelIndex,QSet<QString>)), model, SLOT(removeFromGroup(QModelIndex,QSet<QString>))); }
foreach(const Property property, component()->propertyMap()) { if(property.isVisible()) { bool newlyCreated = false; //Create new property item if it doesn't exist. if(!m_propertyItemsMap.contains(property.name())) { PropertyItem *item = new PropertyItem(property.name(), schematicScene()); QFont font = item->font(); if(font.pointSize() != m_pointSize) { font.setPointSize(m_pointSize); item->setFont(font); } m_propertyItemsMap.insert(property.name(), item); newlyCreated = true; } PropertyItem *item = m_propertyItemsMap[property.name()]; visibleItemsCount++; QList<QGraphicsItem*> _children = QGraphicsItemGroup::children(); if(!_children.isEmpty()) { //Place the new item at bottom, properly aligned with group. QPointF itemPos = mapToScene(boundingRect().bottomLeft()); itemPos.rx() -= item->boundingRect().left(); item->setPos(itemPos); } else { savePos.rx() -= item->boundingRect().left(); item->setPos(savePos); } addToGroup(item); if(newlyCreated) { item->updateValue(); } } else { // Delete item if it existed before as it is being hidden now. if(m_propertyItemsMap.contains(property.name())) { PropertyItem *item = m_propertyItemsMap[property.name()]; m_propertyItemsMap.remove(property.name()); delete item; } } }
void Map::toggleFlag(){ Person* person; if(role==1) // police person=polices[role-1]; else person=robber; for(unsigned int i=0;i<flags.size();i++){ if(person->collidesWithItem(flags[i])){ removeFromGroup(flags[i]); flags[i]->scene()->removeItem(flags[i]); flags.erase(flags.begin()+i); return; } } flags.push_back(new Flag()); addToGroup(flags[flags.size()-1]); }
void PropertyList::addProperty(Property *property) { if (property == 0) return; MultiProperty *mp = 0; if ( m_list.contains(property->name()) ) { mp = m_list[property->name()]; mp->addProperty(property); } else { mp = new MultiProperty(this, property); m_list[property->name()] = mp; addToGroup("", mp); } }
void CadControlPointsGroup::setPoints(QPolygonF *newPoints) { points = newPoints; QGraphicsRectItem * rectItem; for(int i = 0; i<points->size();i++) { QPointF p = points->value(i); QPointF p1 = p - QPointF(3,3); QPointF p2 = p + QPointF(3,3); QRectF r = QRectF(p1,p2); rectItem = new QGraphicsRectItem(r,this); rectItem->setFlag(QGraphicsItem::ItemIsMovable, true); rectItem->setFlag(QGraphicsItem::ItemIsSelectable, true); addToGroup(rectItem); } }
void PropertyList::removeProperty(Property *property) { if (property == 0) return; if (m_propertyOwner) emit aboutToDeleteProperty(property); MultiProperty *mp = m_list[property->name()]; QString group = m_groupOfProperty[mp]; removeFromGroup(mp); QString pname = property->name(); mp->removeProperty(property); if (m_propertyOwner) delete property; if (mp->list.count() == 0) { // qWarning("rp: removing mp for %s itself", pname.ascii()); m_list.remove(pname); delete mp; } else addToGroup(group, mp); }