Ejemplo n.º 1
0
/*!
 * \brief TextAnnotation::duplicate
 * Creates a duplicate of this object.
 */
void TextAnnotation::duplicate()
{
  TextAnnotation *pTextAnnotation = new TextAnnotation("", false, mpGraphicsView);
  QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
                   mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
  pTextAnnotation->setOrigin(mOrigin + gridStep);
  pTextAnnotation->setRotationAngle(mRotation);
  pTextAnnotation->initializeTransformation();
  pTextAnnotation->setLineColor(getLineColor());
  pTextAnnotation->setFillColor(getFillColor());
  pTextAnnotation->setLinePattern(getLinePattern());
  pTextAnnotation->setFillPattern(getFillPattern());
  pTextAnnotation->setLineThickness(getLineThickness());
  pTextAnnotation->setExtents(getExtents());
  pTextAnnotation->setTextString(getTextString());
  pTextAnnotation->setFontSize(getFontSize());
  pTextAnnotation->setFontName(getFontName());
  pTextAnnotation->setTextStyles(getTextStyles());
  pTextAnnotation->setTextHorizontalAlignment(getTextHorizontalAlignment());
  pTextAnnotation->drawCornerItems();
  pTextAnnotation->setCornerItemsPassive();
  pTextAnnotation->update();
  mpGraphicsView->addClassAnnotation();
  mpGraphicsView->setCanAddClassAnnotation(true);
}
Ejemplo n.º 2
0
void LineLayer::setLineColor(DataDrivenPropertyValue<Color> value) {
    if (value == getLineColor())
        return;
    auto impl_ = mutableImpl();
    impl_->paint.template get<LineColor>().value = value;
    baseImpl = std::move(impl_);
    observer->onLayerChanged(*this);
}
Ejemplo n.º 3
0
void LinePath::createHeadLines() {
    m_HeadList.clear();
    QCanvas * canvas = getCanvas();
    switch( getAssocType() ) {
    case Uml::at_Activity:
    case Uml::at_State:
    case Uml::at_Dependency:
    case Uml::at_UniAssociation:
    case Uml::at_Relationship:
        growList(m_HeadList, 2);
        break;

    case Uml::at_Generalization:
    case Uml::at_Realization:
        growList(m_HeadList, 3);
        m_pClearPoly = new QCanvasPolygon( canvas );
        m_pClearPoly -> setVisible( true );
        m_pClearPoly -> setBrush( QBrush( Qt::white ) );
        m_pClearPoly -> setZ( -1 );
        break;

    case Uml::at_Composition:
    case Uml::at_Aggregation:
        growList(m_HeadList, 4);
        m_pClearPoly = new QCanvasPolygon( canvas );
        m_pClearPoly -> setVisible( true );
        if( getAssocType() == Uml::at_Aggregation )
            m_pClearPoly -> setBrush( QBrush( Qt::white ) );
        else
            m_pClearPoly -> setBrush( QBrush( getLineColor() ) );
        m_pClearPoly -> setZ( -1 );
        break;

    case Uml::at_Containment:
        growList(m_HeadList, 1);
        if (!m_pCircle) {
            m_pCircle = new Circle( canvas, 6 );
            m_pCircle->show();
            m_pCircle->setPen( QPen( getLineColor(), getLineWidth() ) );
        }
        break;
    default:
        break;
    }
    m_bHeadCreated = true;
}
Ejemplo n.º 4
0
void rectangle::paintEvent( QPaintEvent *event )
{
    Q_UNUSED(event);
    QPainter p( this );
    p.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
    p.setBrush(readFG());
    p.drawRect(0, 0, width()-1, height()-1 );
}
Ejemplo n.º 5
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// ---- paint
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void Ellipse::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
	painter->setPen  ( QPen(getLineColor())   );
	painter->setBrush( QBrush(getFillColor()) );

	painter->drawEllipse( getGeometry() );

	Shape::paint( painter, option, widget );
}
Ejemplo n.º 6
0
void LinePath::growList(LineList &list, int by) {
    QPen pen( getLineColor(), getLineWidth() );
    for (int i = 0; i < by; i++) {
        QCanvasLine * line = new QCanvasLine( getCanvas() );
        line -> setZ( 0 );
        line -> setPen( pen );
        line -> setVisible( true );
        list.append( line );
    }
}
Ejemplo n.º 7
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// ---- duplication
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void Shape::copyPropertiesIntoObject( Shape* intoShape )
{
	intoShape->setText			( getText()			);
	intoShape->setTextColor	( getTextColor()		);

	intoShape->setLineColor	( getLineColor()		);
	intoShape->setFillColor	( getFillColor()		);

	intoShape->setScenePosition	( getScenePosition()	);
	intoShape->setGeometry		( getGeometry()		);

}
QWidget * DataRecorderChannelBoolean::getPropertyWidget(QWidget * parent, const char * name)
{
	if (!m_propertyWidget)
	{
		// Setup widget
		QVBox * widget = new QVBox(parent,name);
		Q_CHECK_PTR(widget);
		widget->setMargin(KDialog::marginHint());
		widget->setSpacing(KDialog::spacingHint());
		
		QLabel * lab;
		lab = new QLabel(i18n("DataRecorder", "Channel:"), widget);
		Q_CHECK_PTR(lab);
		
		KSimLineEdit * conName;
		conName = new KSimLineEdit(widget);
		Q_CHECK_PTR(conName);
		conName->setText(getConnector()->getName());
		connect(getConnector(), SIGNAL(signalSetName(const QString &)), conName, SLOT(setText(const QString &)));
		connect(conName, SIGNAL(changed(const QString &)), SLOT(setChannelName(const QString &)));
		lab->setBuddy(conName);
		// TODO add ToolTip

		
		ChannelPositionWidget * pos;
		pos = new ChannelPositionWidget(this, widget);
		Q_CHECK_PTR(pos);
		pos->setGainValue(getVerticalGain());
		pos->setOffsetValue(getVerticalOffset());
		connect(pos, SIGNAL(gainChanged(double)), SLOT(setVerticalGain(double)));
		connect(pos, SIGNAL(offsetChanged(double)), SLOT(setVerticalOffset(double)));
		
		
		KColorButton * color = new KColorButton(widget);
		Q_CHECK_PTR(color);
		color->setColor(getLineColor());
		connect(color, SIGNAL(changed(const QColor &)), SLOT(setLineColor(const QColor &)));
		
		
		m_propertyWidget = widget;
	}
	else
	{
		if (parent)
		{
			KSIMDEBUG("Only one widget allowed");
		}
	}
		
	return m_propertyWidget;	
}
Ejemplo n.º 9
0
void CGridIcon::ShowName(Point _point)
{
    if(!m_pName && m_pItem)
    {
        m_pName = Text::create();
        m_pName->setFontSize(24);
        m_pName->setColor(getNameColor(part_name));
        m_pName->enableOutline(getLineColor(part_name));
        m_pName->setPosition(Point(_customSize.width * _point.x, _customSize.height * _point.y));
        addChild(m_pName);
    }
    if(m_pLevel && m_pItem)
        m_pLevel->setText(m_pItem->getItemData()->name);
}
Ejemplo n.º 10
0
void CGridIcon::ShowPrecent(Point _point)
{
    if(!m_pPercent && m_pItem)
    {
        m_pPercent = Text::create();
        m_pPercent->setFontSize(16);
        m_pPercent->setColor(getNameColor(part_precent));
        m_pPercent->enableOutline(getLineColor(part_precent));
        m_pPercent->setPosition(Point(_customSize.width * _point.x, _customSize.height * _point.y));
        addChild(m_pPercent);
    }
    if(m_pPercent && m_pItem)
        m_pPercent->setText(INT_TO_STRING(m_pItem->getBookPercent()));
}
Ejemplo n.º 11
0
void Circle::draw(QPainter *painter)
{
    QBrush brush(getFillColor());
    QPen pen(getLineColor());

    if (getLineThickness() == 0) pen.setStyle(Qt::NoPen);

    pen.setWidth(getLineThickness());

    painter->setBrush(brush);
    painter->setPen(pen);

    painter->drawEllipse(getPosition(), m_radius, m_radius);
}
int DataRecorderChannelFloat::drawData(QPaintDevice * paintDev,
                                       int startSample, int stopSample,
                                       int horizontalOffset, int height,
                                       double samplePerPixel, int verticalDivs)
{
#define LIMIT 32767
#define LIMITER(a) (QMIN(QMAX(a,-LIMIT),LIMIT))
    int index = startSample;
    int counter = 0;
    int horiPos = horizontalOffset;
    int lastHoriPos = horizontalOffset;
    int lastVertPos, vertPos;
    QPainter painter(paintDev);
    painter.setPen(getLineColor());

    double verticalOffset = (getVerticalOffset() * height) / verticalDivs;
    double verticalGain = (getVerticalGain() * height) / verticalDivs;

    if (index >= m_data->count())
        return m_data->count();	// Nothing to draw

    if (stopSample >= m_data->count())
        stopSample = m_data->count()-1; // Limit samples

    vertPos = lastVertPos = LIMITER(height - qRound(verticalGain * getData(index) + verticalOffset));

    while(index < stopSample)
    {
        index++;
        counter++;
        vertPos = LIMITER(height - qRound(verticalGain * getData(index) + verticalOffset));
        horiPos = horizontalOffset + qRound(counter / samplePerPixel);
//		if(lastVertPos != vertPos)		// Speed up static signals
        {
            painter.drawLine(lastHoriPos, lastVertPos, horiPos, vertPos);
            lastVertPos = vertPos;
            lastHoriPos = horiPos;
        }
    }
    // Draw final line
//	painter.drawLine(lastHoriPos, lastVertPos, horiPos, vertPos);
    return index-1;
}
int DataRecorderChannelBoolean::drawData(QPaintDevice * paintDev,
											 int startSample, int stopSample,
											 int horizontalOffset, int height,
											 double samplePerPixel, int verticalDivs)
{
	int index = startSample;
	int counter = 0;
	int horiPos = horizontalOffset;
	int lastHoriPos = horizontalOffset;
	int lastVertPos, vertPos;
	QPainter painter(paintDev);
	painter.setPen(getLineColor());
	
	int verticalOffset = qRound((getVerticalOffset() * height) / verticalDivs);
	int verticalGain = qRound((getVerticalGain() * height) / verticalDivs);

	if (index >= m_data->count())
		return m_data->count();	// Nothing to draw
		
	if (stopSample >= m_data->count())
		stopSample = m_data->count()-1; // Limit samples
		
	lastVertPos = height - (verticalGain * getData(index) + verticalOffset);
	
	while(index <= stopSample)
	{
		vertPos = height - (verticalGain * getData(index) + verticalOffset);
		if(lastVertPos != vertPos)
		{
			painter.drawLine(lastHoriPos, lastVertPos, horiPos, lastVertPos);
			painter.drawLine(horiPos, lastVertPos, horiPos, vertPos);
			lastVertPos = vertPos;
			lastHoriPos = horiPos;
		}
		horiPos = horizontalOffset + qRound(counter / samplePerPixel);
		index++;
		counter++;
	}
	// Draw final line
	painter.drawLine(lastHoriPos, lastVertPos, horiPos, lastVertPos);
	return index-1;
}
Ejemplo n.º 14
0
void RectangleAnnotation::duplicate()
{
  RectangleAnnotation *pRectangleAnnotation = new RectangleAnnotation("", false, mpGraphicsView);
  QPointF gridStep(mpGraphicsView->getCoOrdinateSystem()->getHorizontalGridStep(),
                   mpGraphicsView->getCoOrdinateSystem()->getVerticalGridStep());
  pRectangleAnnotation->setOrigin(mOrigin + gridStep);
  pRectangleAnnotation->setRotationAngle(mRotation);
  pRectangleAnnotation->initializeTransformation();
  pRectangleAnnotation->setLineColor(getLineColor());
  pRectangleAnnotation->setFillColor(getFillColor());
  pRectangleAnnotation->setLinePattern(getLinePattern());
  pRectangleAnnotation->setFillPattern(getFillPattern());
  pRectangleAnnotation->setLineThickness(getLineThickness());
  pRectangleAnnotation->setBorderPattern(getBorderPattern());
  pRectangleAnnotation->setExtents(getExtents());
  pRectangleAnnotation->setRadius(getRadius());
  pRectangleAnnotation->drawCornerItems();
  pRectangleAnnotation->setCornerItemsPassive();
  pRectangleAnnotation->update();
  mpGraphicsView->addClassAnnotation();
  mpGraphicsView->setCanAddClassAnnotation(true);
}
Ejemplo n.º 15
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// ---- paint
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void Line::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget )
{
	QPen	linePen( getLineColor() );
		linePen.setWidthF( 1.5 );

	switch( _lineType )
	{
		case eTopLeftBottomRight:
			_startPoint = getGeometry().topLeft();
			_endPoint   = getGeometry().bottomRight();
			break;

		case eBottomRightTopLeft:
			_startPoint = getGeometry().bottomRight();
			_endPoint   = getGeometry().topLeft();
			break;

		case eBottomLeftTopRight:
			_startPoint = getGeometry().bottomLeft();
			_endPoint   = getGeometry().topRight();
			break;

		case eTopRightBottomLeft:
			_startPoint = getGeometry().topRight();
			_endPoint   = getGeometry().bottomLeft();
			break;

		default:
			_startPoint = getGeometry().topLeft();
			_endPoint   = getGeometry().bottomRight();
			break;			
	}

	painter->setPen( linePen );
	painter->drawLine( _startPoint, _endPoint );

	Shape::paint( painter, option, widget );
}
Ejemplo n.º 16
0
void EArrow::paintEvent( QPaintEvent * ) {
    QPointF p1,p2;
    QLineF polyLine;
    QPainter painter( this );

    painter.setRenderHint( QPainter::Antialiasing );
    painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ) );
    painter.setBrush( getBrushColor() );

    int m_margin = 3;

    if (VERTICAL == getArrowDirection()) {
        p1 = QPointF( width()/2, m_margin );
        p2 = QPointF( width()/2, height()-m_margin );
    } else if (RIGTHBOTTOM == getArrowDirection()) {
        p1 = QPointF( m_margin, m_margin );
        p2 = QPointF( width()-m_margin, height()-m_margin );
    } else if (RIGTHTOP == getArrowDirection()) {
        p1 = QPointF( m_margin, height()-m_margin );
        p2 = QPointF( width()-m_margin, m_margin );
    } else { // HORIZONTAL
        p1 = QPointF( m_margin, height()/2 );
        p2 = QPointF( width()-m_margin, height()/2 );
    }

    polyLine = QLineF( p1, p2 );
    painter.drawLine(polyLine);

    if (LEFT == getArrowMode()) {
        painter.drawPolygon( getHead(p1,p2) );
    } else if (RIGTH == getArrowMode()) {
        painter.drawPolygon(getHead(p2,p1));
    } else if (DOUBLE == getArrowMode()) {
        painter.drawPolygon(getHead(p1,p2));
        painter.drawPolygon(getHead(p2,p1));
    }
}
Ejemplo n.º 17
0
void QLineItem::compile(QSqlDatabase &db, int nSceneId,int &count,int index)
{
    count++;

    //QBasicGraphicsItem::compile(db, nSceneId, count, index);

    QSqlQuery sqlquery(db);
    sqlquery.prepare("INSERT INTO line(nItemNumber ,nSceneId ,eLineClass ,eLineType ,nLineWidth ,"
                     "nLineColor ,eLineArrow ,nAlpha , eLinePointType ,nZvalue,nCollidindId,"
                     "nStartX ,nStartY ,nWidth ,nHeight )"
                     "VALUES (:nItemNumber ,:nSceneId ,:eLineClass ,:eLineType ,:nLineWidth ,"
                     ":nLineColor ,:eLineArrow ,:nAlpha , :eLinePointType,:nZvalue,:nCollidindId,"
                     ":nStartX ,:nStartY ,:nWidth ,:nHeight)");
    sqlquery.bindValue(":nItemNumber",QVariant(count));// 表 id
    sqlquery.bindValue(":nSceneId",QVariant(nSceneId));// 所在场景 id
    sqlquery.bindValue(":eLineClass",QVariant(1)); //1 代表类型为直线
    sqlquery.bindValue(":eLineType",QVariant(nLineType+1));// 线形
    sqlquery.bindValue(":nLineWidth",QVariant(getLineWidth()));// 线宽
    sqlquery.bindValue(":nLineColor",QVariant(ColorToInt(getLineColor()))); //颜色
    sqlquery.bindValue(":eLineArrow",QVariant(m_eLineEndArrowType+1));// 箭头
    sqlquery.bindValue(":nAlpha",QVariant(getAlpha()));// 透明度
    sqlquery.bindValue(":eLinePointType",QVariant(m_eLineEndArrowType+1)); //端点类型

    sqlquery.bindValue(":nZvalue",QVariant(zValue()));//层次

    sqlquery.bindValue(":nCollidindId",QVariant(index));//碰撞ID

    QRectF rect = sceneBoundingRect();
    if(getLineWidth() == 1)
    {
        sqlquery.bindValue(":nStartX",QVariant(rect.x()-1));//x
        sqlquery.bindValue(":nStartY",QVariant(rect.y()-1));//y
        sqlquery.bindValue(":nWidth",QVariant(rect.width()+2));//w
        sqlquery.bindValue(":nHeight",QVariant(rect.height()+2));//h
    }
    else
    {
        sqlquery.bindValue(":nStartX",QVariant(rect.x()));//x
        sqlquery.bindValue(":nStartY",QVariant(rect.y()));//y
        sqlquery.bindValue(":nWidth",QVariant(rect.width()));//w
        sqlquery.bindValue(":nHeight",QVariant(rect.height()));//h
    }

    bool result = false;
    result = sqlquery.exec();
    qDebug() << "insert line table :"<<result;

    sqlquery.prepare("INSERT INTO point(nItemId,nPosX,nPosY,nOrder,ePointType)"
                     "VALUES (:nItemId ,:nPosX ,:nPosY ,:nOrder ,:ePointType )");
    for(int i=0; i<2; i++)
    {
        QPointF pt = this->path().pointAtPercent(i);
        pt = mapToScene(pt);
        sqlquery.bindValue(":nItemId",QVariant(count));// item表 id
        sqlquery.bindValue(":nPosX",QVariant((int)pt.x()));// X
        sqlquery.bindValue(":nPosY",QVariant((int)pt.y())); //Y
        sqlquery.bindValue(":nOrder",QVariant(i));// 顺序
        sqlquery.bindValue(":ePointType",QVariant(1));// 显示点
        result = sqlquery.exec();
        qDebug() << "insert point table :"<<result;
    }

    SamDrawScene *pScene = dynamic_cast<SamDrawScene *>(scene());
    if(pScene && pScene->nIsSceneOrWindow == 2)
    {
        //是自定义键盘的item
        //先新建键盘——item关联表 item表在派生类中创建

        //QSqlQuery sqlquery(db);

        sqlquery.prepare("INSERT INTO kbAndItem(nKeyBoardId , nItemId ,nId,nItemTableType ) "
                         "VALUES (:nKeyBoardId ,:nItemId ,:nId,:nItemTableType)");
        sqlquery.bindValue(":nKeyBoardId",QVariant(nSceneId));
        sqlquery.bindValue(":nItemId",QVariant(count));
        sqlquery.bindValue(":nId",QVariant(id()));
        sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_LINE));

        bool result = false;
        result = sqlquery.exec();
        qDebug() << "insert kbAndItem table :"<<result;

    }
    if(pScene && pScene->nIsSceneOrWindow != 2)
    {
        //窗口或者场景item
        //先新建键盘——item关联表
        //item表在派生类中创建

        //QSqlQuery sqlquery(db);

        sqlquery.prepare("INSERT INTO sceneAndItem(nSceneId,nItemId,nId,nItemTableType)"
                         "VALUES(:nSceneId,:nItemId,:nId,:nItemTableType)");
        sqlquery.bindValue(":nSceneId",QVariant(nSceneId));
        sqlquery.bindValue(":nItemId",QVariant(count));
        sqlquery.bindValue(":nId",QVariant(id()));
        //int t = this->GroupType();
        sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_LINE));

        bool result = false;
        result = sqlquery.exec();
        qDebug() << "insert sceneAndItem table :"<<result;
    }
}
Ejemplo n.º 18
0
QPen LinePath::getPen() {
    Uml::Association_Type type = getAssocType();
    if( type == Uml::at_Dependency || type == Uml::at_Realization || type == Uml::at_Anchor )
        return QPen( getLineColor(), getLineWidth(), Qt::DashLine );
    return QPen( getLineColor(), getLineWidth() );
}
Ejemplo n.º 19
0
void caGraphics::paintEvent( QPaintEvent *event )
{
    Q_UNUSED(event);

    if(thisHide) return;

    int m_margin = 3;
    QPointF p1,p2;
    QPainter painter( this );
    painter.setRenderHint( QPainter::Antialiasing );

    int margin = thisLineSize/2;
    int w = width() - 2 * margin;
    int h = height() - 2 * margin;

// do not increase linesize beyond the canvas size
    if(w <= 0 || h <= 0) {
        setLineSize(thisLineSize-1);
    }
    margin = thisLineSize/2;
    w = width() - 2 * margin;
    h = height() - 2 * margin;
    int x = margin;
    int y = margin;

    if(thisLineStyle == Dash) {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DotLine, Qt::SquareCap) );
    } else if (thisLineStyle == BigDash) {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DashLine, Qt::SquareCap) );
    } else {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::SquareCap) );
    }

    if(thisFillStyle == Filled) {
        painter.setBrush(getForeground());
    }

    if(getForm() == Rectangle) {
        QPolygonF rectangle;
        rectangle.append(QPointF(x,y));
        rectangle.append(QPointF(x+w,y));
        rectangle.append(QPointF(x+w,y+h));
        rectangle.append(QPointF(x,y+h));
        rectangle.append(QPointF(x,y));
        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, rectangle);
        painter.drawPolygon(rotated);

    } else if(getForm() == Circle) {
        // rotate my calculated ellipse
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, drawCircle(x, x+w, y, y+h));
        painter.drawPolygon(rotated);

    } else if(getForm() == Triangle) {
        QPolygonF triangle;
        triangle.append(QPointF(x+w/2,0));
        triangle.append(QPointF(x,y+h));
        triangle.append(QPointF(x+w,y+h));
        triangle.append(QPointF(x+w/2,0));

        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, triangle);
        painter.drawPolygon(rotated);

    } else if(getForm() == Arc) {
        if(thisFillStyle == Filled) {
            painter.drawPie (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16);
        } else {
            painter.drawArc (x, y, w, h, thisStartAngle * 16, thisSpanAngle * 16);
        }

    } else if(getForm() == Line) {
        QPolygonF line;
        line.append(QPointF(x,y+h/2));
        line.append(QPointF(x+w,y+h/2));

        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, line);
        painter.drawPolygon(rotated);

    } else if(getForm() == Arrow) {
        QPolygonF lines;
        QPolygonF head1;
        QPolygonF head2;

        p1 = QPointF( m_margin, height()/2 );
        p2 = QPointF( width()-m_margin, height()/2 );
        lines.append(p1);
        lines.append(p2);

        head1 = getHead(p1,p2);
        if (getArrowMode() == Double) {
            head2 = getHead(p2,p1);
        }

        for(int i=0; i<head1.count(); i++) lines.append(head1.at(i));
        for(int i=0; i<head2.count(); i++) lines.append(head2.at(i));

        // rotate
        QPolygonF rotated = rotateObject(thisTiltAngle, w, h, thisLineSize, lines);
        painter.drawPolygon(rotated);
    }

}
Ejemplo n.º 20
0
void LineLayer::setLineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
    if (value == getLineColor(klass))
        return;
    impl->paint.lineColor.set(value, klass);
    impl->observer->onLayerPaintPropertyChanged(*this);
}
Ejemplo n.º 21
0
void caPolyLine::paintEvent(QPaintEvent * /* event */)
{
    QStringList pairs;
    if(thisHide) return;

    QPainter painter(this);

    painter.setRenderHint( QPainter::Antialiasing );
    int nbPoints = 0;

    if(inEditor) {
      painter.setBrush(QColor(Qt::white));
      painter.drawRect(editSize);
    }

    if(thisLineStyle == Dash) {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DotLine,  Qt::FlatCap));
    } else if (thisLineStyle == BigDash) {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::DashLine, Qt::FlatCap ));
    } else {
        painter.setPen( QPen( getLineColor(), getLineSize(), Qt::SolidLine, Qt::FlatCap));
    }

    if(inDesigner) {
        pairs = thisXYpairs.split(";", QString::SkipEmptyParts);
    } else {
        pairs = XYpairs.split(";", QString::SkipEmptyParts);
    }
    QPolygon polygon(pairs.count());

    for(int i=0; i< pairs.count(); i++) {
        QStringList xy = pairs.at(i).split(",", QString::SkipEmptyParts);
        if(xy.count() == 2) {
            polygon.putPoints(i, 1, atoi(qasc(xy.at(0))), atoi(qasc(xy.at(1))));
            lastPosition =  QPointF(atoi(qasc(xy.at(0))), atoi(qasc(xy.at(1))));
            nbPoints++;
        }
    }

    // when polygon, close the line
    if((thisPolyStyle == Polygon) && (nbPoints > 2)) {
        QStringList xy = pairs.at(0).split(",", QString::SkipEmptyParts);
        if(xy.count() == 2) {
            polygon.putPoints(nbPoints, 1, atoi(qasc(xy.at(0))), atoi(qasc(xy.at(1))));
            nbPoints++;
        }
    }

    if(thisFillStyle == Filled) {
        painter.setBrush(getForeground());
    }

    if(nbPoints > 0) {
        if(thisPolyStyle == Polygon) {
            painter.drawPolygon(polygon);
        } else {
            painter.drawPolyline(polygon);
        }
    }

    if(inEditor && mouseMove) {
      painter.setPen( QPen(QColor(Qt::red), getLineSize(), Qt::SolidLine, Qt::FlatCap ) );
      if(actualPosition != lastPosition)
         painter.drawLine(actualPosition, lastPosition);
    }
}