void GraphicsLinesForCurve::updateGraphicsLinesToMatchGraphicsPoints (const LineStyle &lineStyle)
{
  // LOG4CPP_INFO_S is below

  bool needRenumbering = needOrdinalRenumbering ();
  if (needRenumbering) {

    renumberOrdinals();

  }

  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::updateGraphicsLinesToMatchGraphicsPoints"
                              << " numberPoints=" << m_graphicsPoints.count()
                              << " ordinalRenumbering=" << (needRenumbering ? "true" : "false");

  if (lineStyle.curveConnectAs() != CONNECT_SKIP_FOR_AXIS_CURVE) {

    // Draw as either straight or smoothed. The function/relation differences were handled already with ordinals. The
    // Spline algorithm will crash with fewer than three points so it is only called when there are enough points
    QPainterPath path;
    if (lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_STRAIGHT ||
        lineStyle.curveConnectAs() == CONNECT_AS_RELATION_STRAIGHT ||
        m_graphicsPoints.count () < 3) {

      path = drawLinesStraight ();
    } else {
      path = drawLinesSmooth ();
    }

   setPath (path);
  }
}
Ejemplo n.º 2
0
void LineStyle::setStyle(const LineStyle& other) 
{
	other.validate();
	setParent(other.parent());
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
	inh_##attr_NAME = other.inh_##attr_NAME; \
	m_##attr_NAME = other.m_##attr_NAME;
#include "linestyle.attrdefs.cxx"
#undef ATTRDEF
}
Ejemplo n.º 3
0
void GraphicsLinesForCurve::updateFinish (const LineStyle &lineStyle)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::updateFinish";

  // Apply line style
  QPen pen = QPen (QBrush (ColorPaletteToQColor (lineStyle.paletteColor())),
                   lineStyle.width());
  setPen (pen);

  updateGraphicsLinesToMatchGraphicsPoints (lineStyle);
}
Ejemplo n.º 4
0
void DlgSettingsCurveProperties::drawLine (bool isRelation,
                                           const LineStyle &lineStyle)
{
  const double Z_LINE = -1.0; // Looks nicer if line goes under the points, so points are unobscured

  // Line between points. Start with function connection
  QPainterPath path;
  QPointF p0 (POS_LEFT), p1 (POS_CENTER), p2 (POS_RIGHT);
  if (isRelation) {

    // Relation connection
    p1 = POS_RIGHT;
    p2 = POS_CENTER;
  }

  // Draw straight or smooth
  if (lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_SMOOTH ||
      lineStyle.curveConnectAs() == CONNECT_AS_RELATION_SMOOTH) {

    vector<double> t;
    vector<SplinePair> xy;
    t.push_back(0);
    t.push_back(1);
    t.push_back(2);
    xy.push_back (SplinePair (p0.x(), p0.y()));
    xy.push_back (SplinePair (p1.x(), p1.y()));
    xy.push_back (SplinePair (p2.x(), p2.y()));
    Spline spline (t, xy);
    path.moveTo (p0);
    path.cubicTo (QPointF (spline.p1(0).x(),
                           spline.p1(0).y()),
                  QPointF (spline.p2(0).x(),
                           spline.p2(0).y()),
                  p1);
    path.cubicTo (QPointF (spline.p1(1).x(),
                           spline.p1(1).y()),
                  QPointF (spline.p2(1).x(),
                           spline.p2(1).y()),
                  p2);
  } else {
    path.moveTo (p0);
    path.lineTo (p1);
    path.lineTo (p2);
  }

  QGraphicsPathItem *line = new QGraphicsPathItem (path);
  line->setPen (QPen (QBrush (ColorPaletteToQColor (lineStyle.paletteColor())),
                      lineStyle.width()));
  line->setZValue (Z_LINE);
  m_scenePreview->addItem (line);
}
Ejemplo n.º 5
0
void GraphicsLinesForCurve::updateGraphicsLinesToMatchGraphicsPoints (const LineStyle &lineStyle)
{
  OrdinalToPointIdentifier ordinalToPointIdentifier;

  // Order by ordinals locally
  PointIdentifierToPoint::const_iterator itr;
  for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr++) {

    const Point &point = *itr;
    ordinalToPointIdentifier [point.ordinal ()] = point.identifier ();

  }

  // Draw as either straight or smoothed. The function/relation differences were handled already with ordinals. The
  // Spline algorithm will crash with fewer than three points so it is only called when there are enough points
  QPainterPath path;
  if (lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_STRAIGHT ||
      lineStyle.curveConnectAs() == CONNECT_AS_RELATION_STRAIGHT ||
      m_graphicsPoints.count () < 3) {

    path = drawLinesStraight (ordinalToPointIdentifier);
  } else {
    path = drawLinesSmooth (ordinalToPointIdentifier);
  }

  setPath (path);
}
Ejemplo n.º 6
0
// Write AxisBlock keywords
bool UChromaSession::writeAxisBlock(LineParser& parser, Axes& axes, int axis)
{
	parser.writeLineF("    %s %i\n", UChromaSession::viewPaneKeyword(UChromaSession::AxisBlockKeyword), axis);
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::AutoScaleKeyword), Axes::autoScaleMethod(axes.autoScale(axis)));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::AutoTicksKeyword), stringBool(axes.autoTicks(axis)));
	parser.writeLineF("      %s %f\n", UChromaSession::axisKeyword(UChromaSession::FirstTickKeyword), axes.tickFirst(axis));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::FractionalPositioningKeyword), stringBool(axes.positionIsFractional(axis)));
	parser.writeLineF("      %s %s %s %s\n", UChromaSession::axisKeyword(UChromaSession::GridLinesKeyword), stringBool(axes.gridLinesMajor(axis)), stringBool(axes.gridLinesMinor(axis)), stringBool(axes.gridLinesFull(axis)));
	LineStyle style = axes.gridLineMajorStyle(axis);
	parser.writeLineF("      %s %f '%s' %f %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::GridLineMajorStyleKeyword), style.width(), LineStipple::stipple[style.stipple()].name, style.colour().redF(), style.colour().greenF(), style.colour().blueF(), style.colour().alphaF());
	style = axes.gridLineMinorStyle(axis);
	parser.writeLineF("      %s %f '%s' %f %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::GridLineMinorStyleKeyword), style.width(), LineStipple::stipple[style.stipple()].name, style.colour().redF(), style.colour().greenF(), style.colour().blueF(), style.colour().alphaF());
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::InvertKeyword), stringBool(axes.inverted(axis)));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::LabelAnchorKeyword), TextPrimitive::textAnchor(axes.labelAnchor(axis)));
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::LabelOrientationKeyword), axes.labelOrientation(axis).x, axes.labelOrientation(axis).y, axes.labelOrientation(axis).z);
	parser.writeLineF("      %s %f %f\n", UChromaSession::axisKeyword(UChromaSession::LimitsKeyword), axes.min(axis), axes.max(axis));
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::LogarithmicKeyword), stringBool(axes.logarithmic(axis)));
	parser.writeLineF("      %s %i\n", UChromaSession::axisKeyword(UChromaSession::MinorTicksKeyword), axes.minorTicks(axis));
	NumberFormat fmt = axes.numberFormat(axis);
	parser.writeLineF("      %s '%s' %i %s %s\n", UChromaSession::axisKeyword(UChromaSession::NumberFormatKeyword), NumberFormat::formatType(fmt.type()), fmt.nDecimals(), stringBool(fmt.useUpperCaseExponent()), stringBool(fmt.forcePrecedingPlus()));
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::PositionFractionalKeyword), axes.positionFractional(axis).x, axes.positionFractional(axis).y, axes.positionFractional(axis).z);
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::PositionRealKeyword), axes.positionReal(axis).x, axes.positionReal(axis).y, axes.positionReal(axis).z);
	parser.writeLineF("      %s %f\n", UChromaSession::axisKeyword(UChromaSession::StretchKeyword), axes.stretch(axis));
	parser.writeLineF("      %s %f\n", UChromaSession::axisKeyword(UChromaSession::TickDeltaKeyword), axes.tickDelta(axis));
	parser.writeLineF("      %s %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::TickDirectionKeyword), axes.tickDirection(axis).x, axes.tickDirection(axis).y, axes.tickDirection(axis).z);
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::TitleAnchorKeyword), TextPrimitive::textAnchor(axes.titleAnchor(axis)));
	parser.writeLine(QString("      ")+UChromaSession::axisKeyword(UChromaSession::TitleKeyword)+" '"+axes.title(axis)+"'\n");
	parser.writeLineF("      %s %f %f %f %f\n", UChromaSession::axisKeyword(UChromaSession::TitleOrientationKeyword), axes.titleOrientation(axis).x, axes.titleOrientation(axis).y, axes.titleOrientation(axis).z, axes.titleOrientation(axis).w);
	parser.writeLineF("      %s %s\n", UChromaSession::axisKeyword(UChromaSession::VisibleAxisKeyword), stringBool(axes.visible(axis)));
	parser.writeLineF("    %s\n", UChromaSession::axisKeyword(UChromaSession::EndAxisKeyword));

	return true;
}
Ejemplo n.º 7
0
void DlgSettingsCurveProperties::updatePreview()
{
  m_scenePreview->clear();

  QString currentCurve = m_cmbCurveName->currentText();

  const PointStyle pointStyle = m_modelCurveStylesAfter->curveStyle (currentCurve).pointStyle();
  const LineStyle lineStyle = m_modelCurveStylesAfter->curveStyle (currentCurve).lineStyle();

  // Function or relation?
  bool isRelation = (lineStyle.curveConnectAs() == CONNECT_AS_RELATION_SMOOTH ||
                     lineStyle.curveConnectAs() == CONNECT_AS_RELATION_STRAIGHT);

  drawPoints (pointStyle);
  drawLine (isRelation,
            lineStyle);

  resetSceneRectangle();
}
Ejemplo n.º 8
0
void LineStyle::eraseLineStyle(const LineStyle & other)
{
	other.validate();
	Style::eraseStyle(other);
#define ATTRDEF(attr_TYPE, attr_GETTER, attr_NAME, attr_DEFAULT) \
	if (!inh_##attr_NAME && m_##attr_NAME == other.m_##attr_NAME) \
		reset##attr_NAME();
#include "linestyle.attrdefs.cxx"
#undef ATTRDEF
}
void GraphicsLinesForCurve::updatePointOrdinalsAfterDrag (const LineStyle &lineStyle,
                                                          const Transformation &transformation)
{
  CurveConnectAs curveConnectAs = lineStyle.curveConnectAs();

  LOG4CPP_DEBUG_S ((*mainCat)) << "GraphicsLinesForCurve::updateGraphicsLinesToMatchGraphicsPoints"
                               << " curve=" << m_curveName.toLatin1().data()
                               << " curveConnectAs=" << curveConnectAsToString(curveConnectAs).toLatin1().data();

  if (curveConnectAs == CONNECT_AS_FUNCTION_SMOOTH ||
      curveConnectAs == CONNECT_AS_FUNCTION_STRAIGHT) {

    // Make sure ordinals are properly ordered

    // Get a map of x/theta values as keys with point identifiers as the values
    XOrThetaToOrdinal xOrThetaToOrdinal;
    OrdinalToGraphicsPoint::iterator itrP;
    for (itrP = m_graphicsPoints.begin(); itrP != m_graphicsPoints.end(); itrP++) {

       double ordinal = itrP.key();
       const GraphicsPoint *point = itrP.value();

       // Convert screen coordinate to graph coordinates, which gives us x/theta
       QPointF pointGraph;
       transformation.transformScreenToRawGraph(point->pos (),
                                                pointGraph);

       xOrThetaToOrdinal [pointGraph.x()] = ordinal;
    }

    // Loop through the sorted x/theta values. Since QMap is used, the x/theta keys are sorted
    OrdinalToGraphicsPoint temporaryList;
    int ordinalNew = 0;
    XOrThetaToOrdinal::const_iterator itrX;
    for (itrX = xOrThetaToOrdinal.begin(); itrX != xOrThetaToOrdinal.end(); itrX++) {

      double ordinalOld = *itrX;
      GraphicsPoint *point = m_graphicsPoints [ordinalOld];

      temporaryList [ordinalNew++] = point;
    }

    // Copy from temporary back to original map
    m_graphicsPoints.clear();
    for (itrP = temporaryList.begin(); itrP != temporaryList.end(); itrP++) {

      double ordinal = itrP.key();
      GraphicsPoint *point = itrP.value();

      m_graphicsPoints [ordinal] = point;
    }
  }
}
Ejemplo n.º 10
0
void ShapeCharacterDefinition::readLineStyles(Stream* in, int tagType, MovieDefinition* m)
{
	// Get the count.
	int	line_style_count = in->readUI8();

	// @@ does the 0xFF flag apply to all tag types?
	// if (tag_type > 2)
	// {
	if (line_style_count == 0xFF)
	{
		line_style_count = in->readUI16();
	}
	// }

	// Read the styles.
	for (int i = 0; i < line_style_count; i++)
	{
		LineStyle ls;
		ls.read(in, tagType, m);
		_lineStyles.push_back(ls);
	}
}
void GraphicsLinesForCurve::lineMembershipPurge (const LineStyle &lineStyle)
{
  LOG4CPP_INFO_S ((*mainCat)) << "GraphicsLinesForCurve::lineMembershipPurge"
                              << " curve=" << m_curveName.toLatin1().data();

  OrdinalToGraphicsPoint::iterator itr, itrNext;
  for (itr = m_graphicsPoints.begin(); itr != m_graphicsPoints.end(); itr = itrNext) {

    itrNext = itr;
    ++itrNext;

    GraphicsPoint *point = *itr;

    if (!point->wanted ()) {

      double ordinal = itr.key ();

      delete point;
      m_graphicsPoints.remove (ordinal);
    }
  }

  // Apply line style
  QPen pen;
  if (lineStyle.paletteColor() == COLOR_PALETTE_TRANSPARENT) {

    pen = QPen (Qt::NoPen);

  } else {

    pen = QPen (QBrush (ColorPaletteToQColor (lineStyle.paletteColor())),
                lineStyle.width());

  }

  setPen (pen);

  updateGraphicsLinesToMatchGraphicsPoints (lineStyle);
}
Ejemplo n.º 12
0
void GraphicsLinesForCurve::updatePointOrdinalsAfterDrag (const LineStyle &lineStyle,
                                                          const Transformation &transformation)
{
  if (lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_SMOOTH ||
      lineStyle.curveConnectAs() == CONNECT_AS_FUNCTION_STRAIGHT) {

    // Make sure ordinals are properly ordered

    // Get a map of x/theta values as keys with point identifiers as the values
    XOrThetaToPointIdentifier xOrThetaToPointIdentifier;
    PointIdentifierToPoint::iterator itrP;
    for (itrP = m_graphicsPoints.begin(); itrP != m_graphicsPoints.end(); itrP++) {

       QString pointIdentifier = itrP.key();
       const Point &pointScreen = itrP.value();

       // Convert screen coordinate to graph coordinates, which gives us x/theta
       QPointF pointGraph;
       transformation.transformScreenToRawGraph(pointScreen.posScreen(),
                                                pointGraph);

       xOrThetaToPointIdentifier [pointGraph.x()] = pointIdentifier;
    }

    // Loop through the sorted x/theta values. Since QMap is used, the x/theta keys are sorted
    int ordinal = 0;
    XOrThetaToPointIdentifier::const_iterator itrX;
    for (itrX = xOrThetaToPointIdentifier.begin(); itrX != xOrThetaToPointIdentifier.end(); itrX++) {

      QString pointIdentifier = itrX.value();
      Point &point = m_graphicsPoints [pointIdentifier];

      point.setOrdinal (ordinal++); // Override the old ordinal
    }
  }
}
Ejemplo n.º 13
0
void LinearRing::draw(cairo_t* cr, double a_x, double b_x, double a_y, double b_y, double *color)
{
  PolyStyle *ps;
  double width = 1.0;
  node *tmp = parent;
  bool fill = true;
  bool outline = false;

  while (!(dynamic_cast<Placemark*> (tmp)))
  {
    tmp = tmp->GetParent();
  }
  ps = dynamic_cast<Placemark*> (tmp)->getPolystyle();

  double *col = 0;
  if (ps)
  {
    col = ps->getColor();
    fill = ps->getFill();
    outline = ps->getOutline();
  }

  if (outline)
  {
    LineStyle *ls = dynamic_cast<Placemark*> (tmp)->getLinestyle();
    if (ls)
    {
      col = ls->getColor();
      if (ls->getWidth()) width = ls->getWidth();
    }
    if (color) //domyślnie czarny
    {
      cairo_set_source_rgba(cr, color[0], color[1], color[2], color[3]);
    }
    else if (col)
    {
      cairo_set_source_rgba(cr, col[0], col[1], col[2], col[3]);
    }
    else
    {
      cairo_set_source_rgb(cr, 0, 0, 0);
    }
  }
  else //rysujemy na czarno
  {
    if (ps)
    {
      col = ps->getColor();
    }
    if (color) // najpierw biały oznaczający puste miejsce
    {
      cairo_set_source_rgba(cr, color[0], color[1], color[2], color[3]);
    }
    else if (col)
    {
      cairo_set_source_rgba(cr, col[0], col[1], col[2], col[3]);
    }
    else //domyślny czarny
    {
      cairo_set_source_rgb(cr, 0, 0, 0);
    }
  }

  double *cor;
  int n = (dynamic_cast<Coordinates*> (children.front()))->getSize();
  cairo_set_line_width(cr, width);
  cor = (dynamic_cast<Coordinates*> (children.front()))->getCoordinates(0);
  cairo_move_to(cr, a_x * (cor[0] - b_x), a_y * (cor[1] - b_y));
  for (int i = 1; i < n; i++)
  {
    cor = (dynamic_cast<Coordinates*> (children.front()))->getCoordinates(i);
    cairo_line_to(cr, a_x * (cor[0] - b_x), a_y * (cor[1] - b_y));
  }
  cairo_close_path(cr);
  if (outline)
  {
    cairo_stroke_preserve(cr);
  }
  if (fill) //kolory fill
  {
    if (ps)
    {
      col = ps->getColor();
    }
    if (color) // najpierw biały oznaczający puste miejsce
    {
      cairo_set_source_rgba(cr, color[0], color[1], color[2], color[3]);
    }
    else if (col)
    {
      cairo_set_source_rgba(cr, col[0], col[1], col[2], col[3]);
    }
    else //domyślny czarny
    {
      cairo_set_source_rgb(cr, 0, 0, 0);
    }
    cairo_fill(cr);
  }
  else
  {
    if (color)
    {
      cairo_set_source_rgba(cr, color[0], color[1], color[2], color[3]);
      cairo_fill(cr);
    }
  }
  cairo_stroke(cr);
}
Ejemplo n.º 14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    /*Label l;
    l.setGeometry(Geometry(10, 10));
    l.setOrientation(horizontal);
    l.setText("test comic sansa gghjghjg jhfjj ngb 76p ' '''][].gfd");
    l.setFont(QFont("comic sans ms", 10));
    l.setIcon(Icon(Geometry(0,0,20,20), Qt::green));

    Label l2;
    l2.setGeometry(Geometry(10, 10));
    l2.setOrientation(horizontal);
    l2.setText("test Tajmsa");
    l2.setFont(QFont("times new roman", 20));
    l2.setIcon(Icon(Geometry(0,0,5,5), Qt::red));*/

    /*leg.addLabel(Label("Etykieta 1", Geometry(0, 0, 0, 20), Icon(Qt::red)));
    leg.addLabel(Label("Etykieta 2", Geometry(0, 0, 0, 20), Icon(Qt::yellow)));
    leg.addLabel(Label("Etykieta 3", Geometry(0, 0, 0, 20), Icon(Qt::darkYellow)));
    leg.addLabel(Label("Etykieta 4", Geometry(0, 0, 0, 20), Icon(Qt::darkRed)));
    leg.addLabel(Label("Etykieta 5", Geometry(0, 0, 0, 20), Icon(Qt::cyan)));
    leg.addLabel(Label("Etykieta 6", Geometry(0, 0, 0, 20), Icon(Qt::magenta)));*/
    Axis x;
    x.setFont(QFont("arial", 8));
    x.setTick(20);
    x.setTickDirection(inside);
    x.setTickSize(4);
    x.setMax(100);
    x.setMin(0);
    x.setPosition(bottom);
    x.setUnitVisibility(false);
    x.setGeometry(Geometry(0, 0, 400, 30));

    //Legend leg;
    /*leg.addLabel(Label("Etykieta 1", Geometry(0, 0, 0, 20), Icon(Geometry(0, 0, 20, 20), Qt::red)));
    leg.addLabel(Label("Etykieta 2", Geometry(0, 0, 0, 20), Icon(QColor(255, 150, 0))));
    leg.addLabel(Label("Etykieta 3", Geometry(0, 0, 0, 20), Icon(Qt::darkBlue)));
    leg.addLabel(Label("Etykieta 4", Geometry(0, 0, 0, 20), Icon(Qt::cyan)));*/

    ch.setAxisX(x);
    x.setPosition(bottom);
    x.setGeometry(Geometry(0, 0, 40, 400));
    ch.addAxisY(x);
    ch.setGeometry(Geometry(0, 0, 500, 500));
    //ch.setLegend(leg);

    LineStyle ls;
    ls.setWidth(2);
    ls.setColor(QColor(255, 127, 40));
    ls.setType(Qt::SolidLine);

    s = new Serie;
    s->setLength(20);
    s->setLineStyle(ls);
    s->setAxisId(0);
//    s->setTick(20);
//    s->addPoint(0);
//    s->addPoint(50);
//    s->addPoint(20);
//    s->addPoint(100);
//    s->addPoint(50);
    ch.addSerie(s);

    srand(time(NULL));
}
Ejemplo n.º 15
0
LineStyle::LineStyle (const LineStyle &other) :
  m_width (other.width ()),
  m_paletteColor (other.paletteColor()),
  m_curveConnectAs (other.curveConnectAs())
{
}