31 #include <QGraphicsScene>
50 bool VectorGraphicsExporter::Export(shared_ptr<SimPT_Sim::SimInterface> sim,
51 const string& file_path,
53 std::shared_ptr<VectorGraphicsPreferences> prefs)
55 if (ifstream(file_path).good()) {
58 QFile::remove(QString::fromStdString(file_path));
64 QGraphicsScene canvas;
70 if (prefs->m_window_preset) {
71 top_left = QPointF(prefs->m_window_x_min, prefs->m_window_y_min);
72 bottom_right = QPointF(prefs->m_window_x_max, prefs->m_window_y_max);
74 const auto box = MeshGeometry::BoundingBox(sim->GetCoreData().m_mesh);
75 const auto min_p = get<0>(box) - 1.05 * (get<1>(box) - get<0>(box));
76 const auto max_p = get<1>(box) + 1.05 * (get<1>(box) - get<0>(box));
77 top_left = QPointF(get<0>(min_p), get<1>(min_p));
78 bottom_right = QPointF(get<0>(max_p), get<1>(max_p));
82 if (!file_path.empty()) {
83 QPrinter printer(QPrinter::HighResolution);
84 printer.setOutputFileName(QString::fromStdString(file_path));
85 printer.setOutputFormat(QPrinter::PdfFormat);
86 switch (prefs->m_format) {
87 case VectorGraphicsPreferences::Pdf:
88 printer.setOutputFormat(QPrinter::PdfFormat);
90 case VectorGraphicsPreferences::Eps:
94 printer.setColorMode(QPrinter::ColorMode::Color);
95 QPainter painter(&printer);
96 canvas.setBackgroundBrush(QBrush(QColor(QString::fromStdString(prefs->m_background_color)).rgb()));
97 canvas.render(&painter, QRectF(), QRectF(top_left, bottom_right));
103 string VectorGraphicsExporter::GetFileExtension()
Class drawing a simulator/mesh onto a QGraphicsScene.
Core data used during model execution.
Interface for MeshGeometry.
Namespace for SimPT shell package.
Namespace for the core simulator.
void Draw(std::shared_ptr< SimPT_Sim::SimInterface > sim, QGraphicsScene *scene)
Draws the mesh to QGraphicsScene.
Interface for VectorGraphicsExporter.
Interface for MeshDrawer.
Provides wall-clock time stamp using the time call.