Exemplo n.º 1
0
void QGraphicsGuideView::pathEndEvent(QMouseEvent *event) {
    cout << "Drawing Path (Before Simplification): " << _drawingPath.elementCount() << endl;
//    simplifyPainterPath();
    if (_pathMode == FillMode) {
        QPainter painter(&_userDrawingCanvas);
        painter.setRenderHints(0);
        painter.setBrush(QBrush(Qt::yellow,Qt::SolidPattern));
        painter.setPen(Qt::NoPen);
        painter.drawPath(_drawingPath);
        painter.end();

        this->scene()->removeItem(_drawingPathItem);
        _drawingPathItem = NULL;
        _updateRect = _drawingPath.boundingRect();
        userDrawingToSlice();
        sliceToLabelImage(true);
        updateLabelItem();
        sliceToVolume(true);
    } else {
        simplifyPainterPath();
        cout << "Drawing Path (After Simplification): " << _drawingPath.elementCount() << endl;
        for (int i = 0; i < _drawingPath.elementCount(); i++) {
            QPainterPath::Element e = _drawingPath.elementAt(i);
            QGraphicsEllipseItem* el = new QGraphicsEllipseItem(e.x-2,e.y-2,5,5,_drawingPathItem);
            el->setBrush(QBrush(0xFFFFBBDD, Qt::SolidPattern));
            el->setOpacity(1);
            el->setZValue(2);
        }
    }
}
Exemplo n.º 2
0
void GalaGV::showESysteme(const QString &ally, bool show)
{
    if(!ally.isEmpty()){
        mData->showESysteme.first = ally;
        mData->showESysteme.second = show;
        int gala =mData->gala;
        QString key = ally+";"+QString::number(gala);

        if(!mData->eSysteme.contains(key)){
            QList<ESystem> l =mDB->eSysteme(ally,gala);
            QString cords;
            QHash<QString,QGraphicsEllipseItem*> hash;
            for (int var = 0; var < l.size(); ++var) {
                const ESystem & s = l.at(var);
                cords = s.cords;
                if(cords== "")
                    cords = mData->systeme.value(mData->gala).value(s.id)->data(Cords).toString();

                QGraphicsEllipseItem *item = makeMarkerItem(cords,s.id,Ally,s.isWerft?Qt::yellow:QColor("#E87A1A"),Mark);
                if(s.isChecked){
                    item->setOpacity(0.5);
                }
                item->setData(Esystem,QVariant::fromValue(s));
                item->setFlag(QGraphicsItem::ItemIsSelectable,true);
                item->setToolTip(s.namen.join(",")+" : "+(s.isWerft?"Werft":""));
                hash.insert(s.id,item);
                scene()->addItem(item);
            }
            mData->eSysteme.insert(key,hash);
            qDebug() << Q_FUNC_INFO << mData->eSysteme.keys()<< mData->eSysteme.value(key).count();
        }
        if(show)
            showItems(mData->eSysteme.value(key));
        else
            hideItems(mData->eSysteme.value(key));
    }
}