void DigitizeStatePointMatch::createTemporaryPoint (CmdMediator *cmdMediator, const QPoint &posScreen) { LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStatePointMatch::createTemporaryPoint"; GeometryWindow *NULL_GEOMETRY_WINDOW = nullptr; const DocumentModelPointMatch &modelPointMatch = cmdMediator->document().modelPointMatch(); // Get point style for current graph, and then override with candidate color const CurveStyles &curveStyles = cmdMediator->document().modelCurveStyles(); PointStyle pointStyle = curveStyles.pointStyle (activeCurve()); pointStyle.setPaletteColor (modelPointMatch.paletteColorCandidate()); // Temporary point that user can see while DlgEditPoint is active GraphicsPoint *point = context().mainWindow().scene().createPoint(Point::temporaryPointIdentifier (), pointStyle, posScreen, NULL_GEOMETRY_WINDOW); context().mainWindow().scene().removeTemporaryPointIfExists(); // Only one temporary point at a time is allowed context().mainWindow().scene().addTemporaryPoint (Point::temporaryPointIdentifier(), point); m_posCandidatePoint = posScreen; }
PointStyle::PointStyle (const PointStyle &other) : m_shape (other.shape()), m_radius (other.radius ()), m_lineWidth (other.lineWidth ()), m_paletteColor (other.paletteColor ()) { }
void DlgSettingsSegments::updatePreview() { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsSegments::updatePreview" << " loading=" << (m_loading ? "true" : "false"); const QString ARBITRARY_IDENTIFIER (""); const QColor COLOR (Qt::blue); const int RADIUS = 5; if (!m_loading) { SegmentFactory segmentFactory (*m_scenePreview, mainWindow().isGnuplot()); clearPoints(); segmentFactory.clearSegments (m_segments); // Create new segments segmentFactory.makeSegments (createPreviewImage(), *m_modelSegmentsAfter, m_segments); // Make the segment visible QList<Segment*>::iterator itrS; for (itrS = m_segments.begin(); itrS != m_segments.end(); itrS++) { Segment *segment = *itrS; segment->slotHover (true); } // Create some points PointStyle pointStyle (POINT_SHAPE_CROSS, RADIUS, BRUSH_WIDTH, COLOR_PALETTE_BLUE); QPolygonF polygon = pointStyle.polygon(); QList<QPoint> points = segmentFactory.fillPoints (*m_modelSegmentsAfter, m_segments); QList<QPoint>::iterator itrP; for (itrP = points.begin(); itrP != points.end(); itrP++) { QPoint pos = *itrP; GraphicsPoint *graphicsPoint = new GraphicsPoint (*m_scenePreview, ARBITRARY_IDENTIFIER, pos, COLOR, polygon, BRUSH_WIDTH); m_points.push_back (graphicsPoint); } } }
QPixmap ViewPointStyle::pixmap (const PointStyle &pointStyle) const { LOG4CPP_INFO_S ((*mainCat)) << "ViewPointStyle::pixmap"; // Polygon that is sized for the main drawing window. QPolygonF polygonUnscaled = 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(pointStyle.paletteColor()); // Image for drawing QImage img (width (), height (), QImage::Format_RGB32); QPainter painter (&img); painter.fillRect (0, 0, width (), height (), QBrush (COLOR_FOR_BRUSH)); painter.setPen (QPen (color)); painter.drawPolygon (polygonScaled); // Create pixmap from image QPixmap pixmap = QPixmap::fromImage (img); return pixmap; }