GraphicsPoint *GraphicsPointFactory::createPoint (QGraphicsScene &scene,
                                                  const QString &identifier,
                                                  const QPointF &posScreen,
                                                  const PointStyle &pointStyle)
{
  GraphicsPoint *item = 0;

  switch (pointStyle.shape ())
  {
    case POINT_SHAPE_CIRCLE:
      {
        item = new GraphicsPoint (scene,
                                  identifier,
                                  posScreen,
                                  ColorPaletteToQColor (pointStyle.paletteColor ()),
                                  pointStyle.radius (),
                                  pointStyle.lineWidth());
      }
      break;

    default:
      {
        item = new GraphicsPoint (scene,
                                  identifier,
                                  posScreen,
                                  ColorPaletteToQColor (pointStyle.paletteColor ()),
                                  pointStyle.polygon (),
                                  pointStyle.lineWidth());
      }
      break;
  }
  
  return item;
}
示例#2
0
void Checker::updateModelAxesChecker (const DocumentModelAxesChecker &modelAxesChecker)
{
    QColor color = ColorPaletteToQColor (modelAxesChecker.lineColor());
    QPen pen (QBrush (color), CHECKER_POINTS_WIDTH);

    m_gridLines.setPen (pen);
}
示例#3
0
void Checker::updateModelAxesChecker (const DocumentModelAxesChecker &modelAxesChecker)
{
  QColor color = ColorPaletteToQColor (modelAxesChecker.lineColor());
  QPen pen (QBrush (color), CHECKER_POINTS_WIDTH);

  setLineColor (m_sideLeft, pen);
  setLineColor (m_sideTop, pen);
  setLineColor (m_sideRight, pen);
  setLineColor (m_sideBottom, pen);
}
QPixmap ViewPointStyle::pixmapForCurrentSettings () const
{
  LOG4CPP_INFO_S ((*mainCat)) << "ViewPointStyle::pixmapForCurrentSettings";

  // Polygon that is sized for the main drawing window.
  QPolygonF polygonUnscaled = m_pointStyle.polygon();

  // Resize polygon to fit icon, by builiding a new scaled polygon from the unscaled polygon
  double xMinGot = polygonUnscaled.boundingRect().left();
  double xMaxGot = polygonUnscaled.boundingRect().right();
  double yMinGot = polygonUnscaled.boundingRect().top();
  double yMaxGot = polygonUnscaled.boundingRect().bottom();

  QPolygonF polygonScaled;
  for (int i = 0; i < polygonUnscaled.length(); i++) {
    QPointF pOld = polygonUnscaled.at(i);
    polygonScaled.append (QPointF ((width () - 1) * (pOld.x() - xMinGot) / (xMaxGot - xMinGot),
                                   (height () - 1) * (pOld.y() - yMinGot) / (yMaxGot - yMinGot)));
  }

  // Color
  QColor color = ColorPaletteToQColor(m_pointStyle.paletteColor());
  if (!m_enabled) {
    color = QColor (Qt::black);
  }

  // Image for drawing
  QImage img (width (),
              height (),
              QImage::Format_RGB32);
  QPainter painter (&img);

  painter.fillRect (0,
                    0,
                    width (),
                    height (),
                    QBrush (m_enabled ? COLOR_FOR_BRUSH_ENABLED : COLOR_FOR_BRUSH_DISABLED));

  if (m_enabled) {
    painter.setPen (QPen (color, m_pointStyle.lineWidth()));
    painter.drawPolygon (polygonScaled);
  }

  // Create pixmap from image
  QPixmap pixmap = QPixmap::fromImage (img);

  return pixmap;
}
void GridLineFactory::createGridLinesForEvenlySpacedGrid (const DocumentModelGridDisplay &modelGridDisplay,
                                                          const Document &document,
                                                          const MainWindowModel &modelMainWindow,
                                                          const Transformation &transformation,
                                                          GridLines &gridLines)
{
  // At a minimum the transformation must be defined. Also, there is a brief interval between the definition of
  // the transformation and the initialization of modelGridDisplay (at which point this method gets called again) and
  // we do not want to create grid lines during that brief interval
  if (transformation.transformIsDefined() &&
      modelGridDisplay.stable()) {

    double startX = modelGridDisplay.startX ();
    double startY = modelGridDisplay.startY ();
    double stepX  = modelGridDisplay.stepX  ();
    double stepY  = modelGridDisplay.stepY  ();
    double stopX  = modelGridDisplay.stopX  ();
    double stopY  = modelGridDisplay.stopY  ();

    // Limit the number of grid lines. This is a noop if the limit is not exceeded
    GridLineLimiter gridLineLimiter;
    gridLineLimiter.limitForXTheta (document,
                                    transformation,
                                    m_modelCoords,
                                    modelMainWindow,
                                    modelGridDisplay,
                                    startX,
                                    stepX,
                                    stopX);
    gridLineLimiter.limitForYRadius (document,
                                     transformation,
                                     m_modelCoords,
                                     modelMainWindow,
                                     modelGridDisplay,
                                     startY,
                                     stepY,
                                     stopY);

    // Apply if possible
    bool isLinearX = (m_modelCoords.coordScaleXTheta() == COORD_SCALE_LINEAR);
    bool isLinearY = (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LINEAR);
    if (stepX > (isLinearX ? 0 : 1) &&
        stepY > (isLinearY ? 0 : 1) &&
        (isLinearX || (startX > 0)) &&
        (isLinearY || (startY > 0))) {

      QColor color (ColorPaletteToQColor (modelGridDisplay.paletteColor()));
      QPen pen (QPen (color,
                      GRID_LINE_WIDTH,
                      GRID_LINE_STYLE));

      for (double x = startX; x <= stopX; (isLinearX ? x += stepX : x *= stepX)) {

        GridLine *gridLine = createGridLine (x, startY, x, stopY, transformation);
        gridLine->setPen (pen);
        gridLines.add (gridLine);
      }

      for (double y = startY; y <= stopY; (isLinearY ? y += stepY : y *= stepY)) {

        GridLine *gridLine = createGridLine (startX, y, stopX, y, transformation);
        gridLine->setPen (pen);
        gridLines.add (gridLine);
      }
    }
  }
}