From cd69f29508f81470af5dd9db1cb85e1c8a52c37a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 09:55:59 +0200 Subject: [PATCH 1/7] Basic feature implemented. Needs improvement. --- src/laybasic/laybasic/layLayoutCanvas.cc | 17 +++++++--- src/laybasic/laybasic/layLayoutCanvas.h | 14 ++++++++ src/laybasic/laybasic/layLayoutViewBase.cc | 7 ++++ src/laybasic/laybasic/layLayoutViewConfig.cc | 1 + src/laybasic/laybasic/laybasicConfig.h | 1 + src/layui/layui/LayoutViewConfigPage7.ui | 34 +++++++++++++------- src/layui/layui/layLayerControlPanel.cc | 20 ------------ src/layui/layui/layLayerControlPanel.h | 12 ------- src/layui/layui/layLayoutViewConfigPages.cc | 5 +++ src/layview/layview/layLayoutView_qt.cc | 18 ----------- 10 files changed, 62 insertions(+), 67 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 78f17f1bc1..811d4040cf 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -151,6 +151,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) m_background (0), m_foreground (0), m_active (0), m_oversampling (1), m_hrm (false), + m_srm (false), m_need_redraw (false), m_redraw_clearing (false), m_redraw_force_update (true), @@ -201,11 +202,7 @@ LayoutCanvas::~LayoutCanvas () double LayoutCanvas::resolution () const { - if (m_hrm) { - return 1.0 / m_oversampling; - } else { - return 1.0 / (m_oversampling * dpr ()); - } + return (m_srm ? 1.0 : 1.0 / m_oversampling) * (m_hrm ? 1.0 : 1.0 / dpr ()); } #if defined(HAVE_QT) @@ -283,6 +280,16 @@ LayoutCanvas::set_highres_mode (bool hrm) } } +void +LayoutCanvas::set_subres_mode (bool srm) +{ + if (srm != m_srm) { + m_image_cache.clear (); + m_srm = srm; + do_redraw_all (); + } +} + double LayoutCanvas::dpr () const { diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index ae4655dc44..a841bb5ee8 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -277,6 +277,19 @@ class LAYBASIC_PUBLIC LayoutCanvas return m_hrm; } + /** + * @brief Set sub resolution mode (sub-pixel resolution in oversampling mode) + */ + void set_subres_mode (bool srm); + + /** + * @brief Gets the sub resolution mode flag + */ + bool subres_mode () const + { + return m_srm; + } + /** * @brief Gets the default device pixel ratio for this canvas */ @@ -412,6 +425,7 @@ class LAYBASIC_PUBLIC LayoutCanvas std::map > m_scaled_view_ops; unsigned int m_oversampling; bool m_hrm; + bool m_srm; double m_gamma; bool m_need_redraw; diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 108644c5e1..af25ce5cb6 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -790,6 +790,13 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) mp_canvas->set_highres_mode (hrm); return true; + } else if (name == cfg_subres_mode) { + + bool srm = false; + tl::from_string (value, srm); + mp_canvas->set_subres_mode (srm); + return true; + } else if (name == cfg_image_cache_size) { int sz = 0; diff --git a/src/laybasic/laybasic/layLayoutViewConfig.cc b/src/laybasic/laybasic/layLayoutViewConfig.cc index d1372d9664..4d879a0241 100644 --- a/src/laybasic/laybasic/layLayoutViewConfig.cc +++ b/src/laybasic/laybasic/layLayoutViewConfig.cc @@ -114,6 +114,7 @@ class LayoutViewBasicConfigDeclaration options.push_back (std::pair (cfg_array_border_instances, "false")); options.push_back (std::pair (cfg_bitmap_oversampling, "1")); options.push_back (std::pair (cfg_highres_mode, "false")); + options.push_back (std::pair (cfg_subres_mode, "false")); options.push_back (std::pair (cfg_image_cache_size, "1")); options.push_back (std::pair (cfg_default_font_size, "0")); options.push_back (std::pair (cfg_color_palette, lay::ColorPalette ().to_string ())); diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index 9fb24ee863..a9b654c2dc 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -126,6 +126,7 @@ static const std::string cfg_tip_window_hidden ("tip-window-hidden"); static const std::string cfg_bitmap_oversampling ("bitmap-oversampling"); static const std::string cfg_highres_mode ("highres-mode"); +static const std::string cfg_subres_mode ("subres-mode"); static const std::string cfg_image_cache_size ("image-cache-size"); static const std::string cfg_default_font_size ("default-font-size"); diff --git a/src/layui/layui/LayoutViewConfigPage7.ui b/src/layui/layui/LayoutViewConfigPage7.ui index c5f922f109..279f88998f 100644 --- a/src/layui/layui/LayoutViewConfigPage7.ui +++ b/src/layui/layui/LayoutViewConfigPage7.ui @@ -6,8 +6,8 @@ 0 0 - 791 - 403 + 613 + 496 @@ -50,18 +50,14 @@ 6 - - - - Oversampling mode - - - - + High resolution mode utilizes the full pixel density on high-DPI displays. Features may look small but rich in details. + + true + @@ -83,6 +79,13 @@ + + + + Oversampling mode + + + @@ -99,20 +102,27 @@ - Oversampling increases the image quality by using an internal resolution larger than the image resolution. Drawing speed is somewhat reduced and lines may appear thinner. + Oversampling increases the image quality by using an internal resolution larger than the image resolution. Drawing speed is somewhat reduced. true - + High resolution mode enabled + + + + Subresolution mode - scale down line widths and stipples with oversampling + + + diff --git a/src/layui/layui/layLayerControlPanel.cc b/src/layui/layui/layLayerControlPanel.cc index e5a41832b4..5b501993f1 100644 --- a/src/layui/layui/layLayerControlPanel.cc +++ b/src/layui/layui/layLayerControlPanel.cc @@ -210,8 +210,6 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma m_hidden_flags_need_update (true), m_in_update (false), m_phase (0), - m_oversampling (1), - m_hrm (false), m_do_update_content_dm (this, &LayerControlPanel::do_update_content), m_do_update_visibility_dm (this, &LayerControlPanel::do_update_visibility), m_no_stipples (false), @@ -1792,24 +1790,6 @@ LayerControlPanel::set_phase (int phase) } } -void -LayerControlPanel::set_highres_mode (bool hrm) -{ - if (m_hrm != hrm) { - m_hrm = hrm; - m_do_update_content_dm (); - } -} - -void -LayerControlPanel::set_oversampling (int os) -{ - if (m_oversampling != os) { - m_oversampling = os; - m_do_update_content_dm (); - } -} - static void set_hidden_flags_rec (LayerTreeModel *model, QTreeView *tree_view, const QModelIndex &parent) { diff --git a/src/layui/layui/layLayerControlPanel.h b/src/layui/layui/layLayerControlPanel.h index 390c2aea38..acd6617d9d 100644 --- a/src/layui/layui/layLayerControlPanel.h +++ b/src/layui/layui/layLayerControlPanel.h @@ -220,16 +220,6 @@ Q_OBJECT */ void set_phase (int phase); - /** - * @brief Sets highres mode - */ - void set_highres_mode (bool hrm); - - /** - * @brief Sets oversampling mode - */ - void set_oversampling (int os); - /** * @brief Tell, if the model has been updated already (true) or if it is still under construction (false) */ @@ -373,8 +363,6 @@ private slots: bool m_in_update; std::vector m_new_sel; int m_phase; - int m_oversampling; - bool m_hrm; tl::DeferredMethod m_do_update_content_dm; tl::DeferredMethod m_do_update_visibility_dm; bool m_no_stipples; diff --git a/src/layui/layui/layLayoutViewConfigPages.cc b/src/layui/layui/layLayoutViewConfigPages.cc index 81d7cbf1e2..7611440371 100644 --- a/src/layui/layui/layLayoutViewConfigPages.cc +++ b/src/layui/layui/layLayoutViewConfigPages.cc @@ -1501,6 +1501,10 @@ LayoutViewConfigPage7::setup (lay::Dispatcher *root) root->config_get (cfg_highres_mode, highres_mode); mp_ui->highres_mode->setChecked (highres_mode); + bool subres_mode = false; + root->config_get (cfg_subres_mode, subres_mode); + mp_ui->subres_mode->setChecked (subres_mode); + int default_font_size = 0; root->config_get (cfg_default_font_size, default_font_size); mp_ui->default_font_size->setCurrentIndex (default_font_size); @@ -1525,6 +1529,7 @@ LayoutViewConfigPage7::commit (lay::Dispatcher *root) { root->config_set (cfg_bitmap_oversampling, mp_ui->oversampling->currentIndex () + 1); root->config_set (cfg_highres_mode, mp_ui->highres_mode->isChecked ()); + root->config_set (cfg_subres_mode, mp_ui->subres_mode->isChecked ()); root->config_set (cfg_default_font_size, mp_ui->default_font_size->currentIndex ()); root->config_set (cfg_global_trans, db::DCplxTrans (db::DFTrans (mp_ui->global_trans->currentIndex ())).to_string ()); root->config_set (cfg_initial_hier_depth, mp_ui->def_depth->value ()); diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index a63b74492f..86aeaf7743 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -873,24 +873,6 @@ LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) bool LayoutView::configure (const std::string &name, const std::string &value) { - if (name == cfg_bitmap_oversampling) { - - int os = 1; - tl::from_string (value, os); - if (mp_control_panel) { - mp_control_panel->set_oversampling (os); - } - - } else if (name == cfg_highres_mode) { - - bool hrm = false; - tl::from_string (value, hrm); - if (mp_control_panel) { - mp_control_panel->set_highres_mode (hrm); - } - - } - if (LayoutViewBase::configure (name, value)) { return true; } From a802cd0e911c9aeba00907eb31171692098162d2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 18:41:55 +0200 Subject: [PATCH 2/7] Proper scaling with resolution - stipple display in layer list now follows view resolution - using DCoord for text default size for cases where default size < DBU --- src/laybasic/laybasic/layBitmapRenderer.cc | 8 +++--- src/laybasic/laybasic/layLayoutCanvas.h | 8 ++++++ src/laybasic/laybasic/layLayoutViewBase.cc | 25 ++++++++++++------- src/laybasic/laybasic/layLayoutViewBase.h | 5 ++++ src/laybasic/laybasic/layMarker.cc | 6 ++--- .../laybasic/layRedrawThreadWorker.cc | 2 +- src/laybasic/laybasic/layRenderer.cc | 8 +++--- src/laybasic/laybasic/layRenderer.h | 16 ++++++------ src/layui/layui/layLayerControlPanel.cc | 7 ++++++ src/layui/layui/layLayerControlPanel.h | 1 + 10 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/laybasic/laybasic/layBitmapRenderer.cc b/src/laybasic/laybasic/layBitmapRenderer.cc index a3037ed951..ef7b3517d7 100644 --- a/src/laybasic/laybasic/layBitmapRenderer.cc +++ b/src/laybasic/laybasic/layBitmapRenderer.cc @@ -386,12 +386,12 @@ BitmapRenderer::draw (const db::Shape &shape, const db::CplxTrans &trans, if (m_draw_texts && text) { db::DFTrans fp (db::DFTrans::r0); - db::DCoord h = trans.ctrans (m_default_text_size); + db::DCoord h = trans.mag () * m_default_text_size; db::Font font = shape.text_font () == db::NoFont ? m_font : shape.text_font (); if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) { fp = db::DFTrans (trans.fp_trans () * shape.text_trans ()); - h = trans.ctrans (shape.text_size () > 0 ? shape.text_size () : m_default_text_size); + h = trans.mag () * (shape.text_size () > 0 ? shape.text_size () : m_default_text_size); } db::HAlign halign = shape.text_halign (); @@ -1087,12 +1087,12 @@ BitmapRenderer::draw (const db::Text &txt, const db::CplxTrans &trans, if (m_draw_texts && text) { db::DFTrans fp (db::DFTrans::r0); - db::DCoord h = trans.ctrans (m_default_text_size); + db::DCoord h = trans.mag () * m_default_text_size; db::Font font = txt.font () == db::NoFont ? m_font : txt.font (); if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) { fp = db::DFTrans (trans.fp_trans () * txt.trans ()); - h = trans.ctrans (txt.size () > 0 ? txt.size () : m_default_text_size); + h = trans.mag () * (txt.size () > 0 ? txt.size () : m_default_text_size); } double fy = 0.0; diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index a841bb5ee8..2bc68edf77 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -338,6 +338,14 @@ class LAYBASIC_PUBLIC LayoutCanvas */ double resolution () const; + /** + * @brief Gets the gamma value + */ + double gamma () const + { + return m_gamma; + } + /** * @brief Reimplementation of ViewObjectCanvas: Background color */ diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index af25ce5cb6..bfef34ba54 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -780,21 +780,30 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) int os = 1; tl::from_string (value, os); - mp_canvas->set_oversampling (os); + if (os != mp_canvas->oversampling ()) { + mp_canvas->set_oversampling (os); + resolution_changed_event (); + } return true; } else if (name == cfg_highres_mode) { bool hrm = false; tl::from_string (value, hrm); - mp_canvas->set_highres_mode (hrm); + if (hrm != mp_canvas->highres_mode ()) { + mp_canvas->set_highres_mode (hrm); + resolution_changed_event (); + } return true; } else if (name == cfg_subres_mode) { bool srm = false; tl::from_string (value, srm); - mp_canvas->set_subres_mode (srm); + if (srm != mp_canvas->subres_mode ()) { + mp_canvas->set_subres_mode (srm); + resolution_changed_event (); + } return true; } else if (name == cfg_image_cache_size) { @@ -1565,14 +1574,12 @@ tl::PixelBuffer LayoutViewBase::icon_for_layer (const LayerPropertiesConstIterator &iter, unsigned int w, unsigned int h, double dpr, unsigned int di_off, bool no_state) { if (dpr < 0.0) { - dpr = canvas ()->dpr (); + dpr = canvas () ? canvas ()->dpr () : 1.0; } - int oversampling = canvas () ? canvas ()->oversampling () : 1; - double gamma = 2.0; - - bool hrm = canvas () ? canvas ()->highres_mode () : false; - double dpr_drawing = oversampling * (hrm ? 1.0 : dpr); + double gamma = canvas () ? canvas ()->gamma () : 2.0; + double dpr_drawing = canvas () ? 1.0 / canvas ()->resolution () : 1.0; + unsigned int oversampling = canvas () ? canvas ()->oversampling () : 1; h = std::max ((unsigned int) 16, h) * oversampling * dpr + 0.5; w = std::max ((unsigned int) 16, w) * oversampling * dpr + 0.5; diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index c6181b6b9b..e18dee2bc8 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -789,6 +789,11 @@ class LAYBASIC_PUBLIC LayoutViewBase : */ tl::Event cell_visibility_changed_event; + /** + * @brief An event signalling that the resolution has changed + */ + tl::Event resolution_changed_event; + /** * @brief Save the given cellview into the given file (with options) * If "update" is true, the cell view's properties will be updated (options, filename etc.). diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 017b22f74d..2f08d2289b 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -637,7 +637,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) r.set_font (db::Font (view ()->text_font ())); r.apply_text_trans (view ()->apply_text_trans ()); - r.default_text_size (db::Coord (view ()->default_text_size () / ly->dbu ())); + r.default_text_size (view ()->default_text_size () / ly->dbu ()); r.set_precise (true); if (trans_vector ()) { @@ -1168,7 +1168,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas) r.set_font (db::Font (view ()->text_font ())); r.apply_text_trans (view ()->apply_text_trans ()); - r.default_text_size (db::Coord (view ()->default_text_size () / dbu ())); + r.default_text_size (view ()->default_text_size () / dbu ()); r.set_precise (true); if (! trans_vector ()) { @@ -1316,7 +1316,7 @@ DMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) r.set_font (db::Font (view ()->text_font ())); r.apply_text_trans (view ()->apply_text_trans ()); - r.default_text_size (view ()->default_text_size ()); + r.default_text_size_dbl (view ()->default_text_size ()); r.set_precise (true); db::DCplxTrans t = vp.trans (); diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index b6046cd724..8232d3520e 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -204,7 +204,7 @@ RedrawThreadWorker::perform_task (tl::Task *task) mp_renderer->draw_texts (m_text_visible); mp_renderer->draw_properties (m_show_properties); mp_renderer->draw_description_property (false); - mp_renderer->default_text_size (db::Coord (m_default_text_size / mp_layout->dbu ())); + mp_renderer->default_text_size (m_default_text_size / mp_layout->dbu ()); mp_renderer->set_font (db::Font (m_text_font)); mp_renderer->apply_text_trans (m_apply_text_trans); diff --git a/src/laybasic/laybasic/layRenderer.cc b/src/laybasic/laybasic/layRenderer.cc index 6af40f40a5..247f89403c 100644 --- a/src/laybasic/laybasic/layRenderer.cc +++ b/src/laybasic/laybasic/layRenderer.cc @@ -40,8 +40,8 @@ Renderer::Renderer (unsigned int width, unsigned int height, double resolution) : m_draw_texts (true), m_draw_properties (false), m_draw_description_property (false), - m_default_text_size (16), - m_default_text_size_dbl (16), + m_default_text_size (1000), + m_default_text_size_dbl (1.0), m_apply_text_trans (true), m_precise (false), m_xfill (false), @@ -94,7 +94,7 @@ Renderer::draw_propstring (db::properties_id_type id, lay::CanvasPlane *text, const db::CplxTrans &trans) { db::DPoint tp1 (pref + db::DVector (2.0, -2.0)); - db::DPoint tp2 (pref + db::DVector (2.0, -2.0 - trans.ctrans (m_default_text_size))); + db::DPoint tp2 (pref + db::DVector (2.0, -2.0 - trans.mag () * m_default_text_size)); std::string ptext; @@ -119,7 +119,7 @@ Renderer::draw_description_propstring (db::properties_id_type id, lay::CanvasPlane *text, const db::CplxTrans &trans) { db::DPoint tp1 (pref + db::DVector (5.0, -5.0)); - db::DPoint tp2 (pref + db::DVector (5.0, -5.0 - trans.ctrans (m_default_text_size))); + db::DPoint tp2 (pref + db::DVector (5.0, -5.0 - trans.mag () * m_default_text_size)); const db::PropertiesRepository::properties_set &props = prep->properties (id); // TODO: get rid of this const_cast hack (i.e. by a mutable definition inside the properties repository) diff --git a/src/laybasic/laybasic/layRenderer.h b/src/laybasic/laybasic/layRenderer.h index e3078fd025..a1ddaf5fcf 100644 --- a/src/laybasic/laybasic/layRenderer.h +++ b/src/laybasic/laybasic/layRenderer.h @@ -116,31 +116,31 @@ class LAYBASIC_PUBLIC Renderer } /** - * @brief The default text size to use for draw(db::Text..) + * @brief The default text size to use for draw(db::Text..) - i.e in DBU units */ - void default_text_size (db::Coord sz) + void default_text_size (db::DCoord sz) { m_default_text_size = sz; } /** - * @brief Get the default text size + * @brief Get the default text size to use for draw(db::Text..) - i.e in DBU units */ - db::Coord default_text_size () const + db::DCoord default_text_size () const { return m_default_text_size; } /** - * @brief The default text size to use for draw(db::DText..) + * @brief The default text size to use for draw(db::DText..) - i.e. in micron units */ - void default_text_size (double sz) + void default_text_size_dbl (double sz) { m_default_text_size_dbl = sz; } /** - * @brief Get the default text size for draw (DText ...) + * @brief Get the default text size for draw (DText ...) - i.e. in micron units */ double default_text_size_dbl () const { @@ -404,7 +404,7 @@ class LAYBASIC_PUBLIC Renderer bool m_draw_texts; bool m_draw_properties; bool m_draw_description_property; - db::Coord m_default_text_size; + db::DCoord m_default_text_size; double m_default_text_size_dbl; bool m_apply_text_trans; bool m_precise; diff --git a/src/layui/layui/layLayerControlPanel.cc b/src/layui/layui/layLayerControlPanel.cc index 5b501993f1..86155f0907 100644 --- a/src/layui/layui/layLayerControlPanel.cc +++ b/src/layui/layui/layLayerControlPanel.cc @@ -338,6 +338,7 @@ LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *ma mp_view->cellview_changed_event.add (this, &LayerControlPanel::signal_cv_changed_with_int); mp_view->viewport_changed_event.add (this, &LayerControlPanel::signal_vp_changed); mp_view->hier_levels_changed_event.add (this, &LayerControlPanel::signal_vp_changed); + mp_view->resolution_changed_event.add (this, &LayerControlPanel::signal_resolution_changed); QFrame *tb = new QFrame (this); l->addWidget (tb); @@ -2051,6 +2052,12 @@ LayerControlPanel::redo (db::Op *op) } } +void +LayerControlPanel::signal_resolution_changed () +{ + m_do_update_content_dm (); +} + void LayerControlPanel::signal_vp_changed () { diff --git a/src/layui/layui/layLayerControlPanel.h b/src/layui/layui/layLayerControlPanel.h index acd6617d9d..0a77f19bde 100644 --- a/src/layui/layui/layLayerControlPanel.h +++ b/src/layui/layui/layLayerControlPanel.h @@ -385,6 +385,7 @@ private slots: void signal_cv_changed (); void signal_cv_changed_with_int (int index); void signal_vp_changed (); + void signal_resolution_changed (); void do_update_content (); void do_update_visibility (); From 3290d0ab214dfe4c487dad5ce904e2e0a9475cd0 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 21:10:25 +0200 Subject: [PATCH 3/7] Introducing font resolution With the subresolution mode, the "Default" fonts get very small. Hence, a separate font resolution is provided which applies to "Default" font rendering only. --- src/laybasic/laybasic/layBitmap.cc | 9 +++-- src/laybasic/laybasic/layBitmap.h | 16 +++++++- src/laybasic/laybasic/layBitmapRenderer.cc | 4 +- src/laybasic/laybasic/layBitmapRenderer.h | 2 +- src/laybasic/laybasic/layBitmapsToImage.cc | 4 +- src/laybasic/laybasic/layLayoutCanvas.cc | 28 +++++++++----- src/laybasic/laybasic/layLayoutCanvas.h | 7 +++- src/laybasic/laybasic/layLayoutViewBase.cc | 8 ++-- .../laybasic/layPixelBufferPainter.cc | 38 ++++++++++++++++--- src/laybasic/laybasic/layPixelBufferPainter.h | 7 +++- src/laybasic/laybasic/layRedrawThread.cc | 13 ++++--- src/laybasic/laybasic/layRedrawThread.h | 5 ++- .../laybasic/layRedrawThreadCanvas.cc | 14 +++---- src/laybasic/laybasic/layRedrawThreadCanvas.h | 19 ++++++++-- .../laybasic/layRedrawThreadWorker.cc | 10 ++--- src/laybasic/laybasic/layRenderer.cc | 5 ++- src/laybasic/laybasic/layRenderer.h | 14 ++++++- src/laybasic/laybasic/layTextInfo.cc | 2 +- src/laybasic/laybasic/layViewObject.cc | 23 +++++------ src/laybasic/laybasic/layViewObject.h | 22 +++++++++-- src/laybasic/unit_tests/layBitmap.cc | 10 ++--- src/laybasic/unit_tests/layBitmapsToImage.cc | 16 ++++---- src/laybasic/unit_tests/layRenderer.cc | 28 +++++++------- src/layview/layview/layGridNet.cc | 13 +++---- 24 files changed, 210 insertions(+), 107 deletions(-) diff --git a/src/laybasic/laybasic/layBitmap.cc b/src/laybasic/laybasic/layBitmap.cc index 5e1abbde24..9a23bca4d3 100644 --- a/src/laybasic/laybasic/layBitmap.cc +++ b/src/laybasic/laybasic/layBitmap.cc @@ -33,13 +33,15 @@ Bitmap::Bitmap () { init (0, 0); m_resolution = 1.0; + m_font_resolution = 1.0; } -Bitmap::Bitmap (unsigned int w, unsigned int h, double r) +Bitmap::Bitmap (unsigned int w, unsigned int h, double r, double rf) : m_empty_scanline (0) { init (w, h); m_resolution = r; + m_font_resolution = rf; } Bitmap::Bitmap (const Bitmap &d) @@ -60,6 +62,7 @@ Bitmap::operator= (const Bitmap &d) } m_resolution = d.m_resolution; + m_font_resolution = d.m_font_resolution; for (unsigned int i = 0; i < m_height; ++i) { if (! d.m_scanlines.empty () && d.m_scanlines [i] != 0) { @@ -796,7 +799,7 @@ Bitmap::render_text (const lay::RenderText &text) { if (text.font == db::DefaultFont) { - const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); + const lay::FixedFont &ff = lay::FixedFont::get_font (m_font_resolution); // count the lines and max. characters per line @@ -877,7 +880,7 @@ Bitmap::render_text (const lay::RenderText &text) } else { // Create a sub-renderer so we do not need to clear *this - lay::BitmapRenderer hr (m_width, m_height, m_resolution); + lay::BitmapRenderer hr (m_width, m_height, m_resolution, m_font_resolution); db::DHershey ht (text.text, text.font); hr.reserve_edges (ht.count_edges ()); diff --git a/src/laybasic/laybasic/layBitmap.h b/src/laybasic/laybasic/layBitmap.h index 0a1461b680..742b5840fa 100644 --- a/src/laybasic/laybasic/layBitmap.h +++ b/src/laybasic/laybasic/layBitmap.h @@ -157,8 +157,9 @@ class LAYBASIC_PUBLIC Bitmap * @param w The width of the bitmap * @param h The height of the bitmap * @param r The resolution of the bitmap + * @param rf The font resolution of the bitmap */ - Bitmap (unsigned int w, unsigned int h, double r); + Bitmap (unsigned int w, unsigned int h, double r, double rf); /** * @brief Copy constructor @@ -218,6 +219,11 @@ class LAYBASIC_PUBLIC Bitmap */ double resolution () const; + /** + * @brief Get the font resolution of the bitmap (applies to "Default" font) + */ + double font_resolution () const; + /** * @brief Get the width of the bitmap */ @@ -311,7 +317,7 @@ class LAYBASIC_PUBLIC Bitmap private: unsigned int m_width; unsigned int m_height; - double m_resolution; + double m_resolution, m_font_resolution; std::vector m_scanlines; std::vector m_free; uint32_t *m_empty_scanline; @@ -357,6 +363,12 @@ Bitmap::resolution () const return m_resolution; } +inline double +Bitmap::font_resolution () const +{ + return m_font_resolution; +} + inline unsigned int Bitmap::width () const { diff --git a/src/laybasic/laybasic/layBitmapRenderer.cc b/src/laybasic/laybasic/layBitmapRenderer.cc index ef7b3517d7..5f9501f957 100644 --- a/src/laybasic/laybasic/layBitmapRenderer.cc +++ b/src/laybasic/laybasic/layBitmapRenderer.cc @@ -30,8 +30,8 @@ namespace lay // ---------------------------------------------------------------------------------------------- // BitmapRenderer implementation -BitmapRenderer::BitmapRenderer (unsigned int width, unsigned int height, double resolution) - : Renderer (width, height, resolution), +BitmapRenderer::BitmapRenderer (unsigned int width, unsigned int height, double resolution, double font_resolution) + : Renderer (width, height, resolution, font_resolution), m_xmin (0.0), m_xmax (0.0), m_ymin (0.0), m_ymax (0.0), m_ortho (true) { diff --git a/src/laybasic/laybasic/layBitmapRenderer.h b/src/laybasic/laybasic/layBitmapRenderer.h index 0076f65a0e..f43dd362a4 100644 --- a/src/laybasic/laybasic/layBitmapRenderer.h +++ b/src/laybasic/laybasic/layBitmapRenderer.h @@ -53,7 +53,7 @@ class LAYBASIC_PUBLIC BitmapRenderer /** * @brief The default ctor */ - BitmapRenderer (unsigned int width, unsigned int height, double resolution); + BitmapRenderer (unsigned int width, unsigned int height, double resolution, double font_resolution); /** * @brief Reserve space for n edges diff --git a/src/laybasic/laybasic/layBitmapsToImage.cc b/src/laybasic/laybasic/layBitmapsToImage.cc index 3d00290fb2..40ac5b0eb4 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.cc +++ b/src/laybasic/laybasic/layBitmapsToImage.cc @@ -449,7 +449,7 @@ static void create_precursor_bitmaps (const std::vector &view_ops_i mutex->lock (); } - lay::Bitmap &bp = precursors.insert (std::make_pair (bm_index, lay::Bitmap (width, height, 1.0))).first->second; + lay::Bitmap &bp = precursors.insert (std::make_pair (bm_index, lay::Bitmap (width, height, 1.0, 1.0))).first->second; const LineStyleInfo &ls_info = ls.style (op.line_style_index ()).scaled (op.width ()); for (unsigned int y = 0; y < height; y++) { @@ -961,7 +961,7 @@ bitmap_to_bitmap (const lay::ViewOp &view_op, const lay::Bitmap &bitmap, lay::Bitmap precursor; if (ls_info.width () > 0) { - precursor = lay::Bitmap (width, height, 1.0); + precursor = lay::Bitmap (width, height, 1.0, 1.0); LineStyleInfo lsi = ls_info; diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 811d4040cf..4278809d0b 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -205,6 +205,14 @@ LayoutCanvas::resolution () const return (m_srm ? 1.0 : 1.0 / m_oversampling) * (m_hrm ? 1.0 : 1.0 / dpr ()); } +double +LayoutCanvas::font_resolution () const +{ + // NOTE: for font resolution we do not include the subresolution mode - otherwise + // the labels will become very hard to read. + return (1.0 / m_oversampling) * (m_hrm ? 1.0 : 1.0 / dpr ()); +} + #if defined(HAVE_QT) void LayoutCanvas::init_ui (QWidget *parent) @@ -370,7 +378,7 @@ LayoutCanvas::prepare_drawing () { if (m_need_redraw) { - BitmapViewObjectCanvas::set_size (m_viewport_l.width (), m_viewport_l.height (), resolution ()); + BitmapViewObjectCanvas::set_size (m_viewport_l.width (), m_viewport_l.height (), resolution (), font_resolution ()); if (! mp_image || (unsigned int) mp_image->width () != m_viewport_l.width () || @@ -406,7 +414,7 @@ LayoutCanvas::prepare_drawing () ++c; } - mp_redraw_thread->commit (m_layers, m_viewport_l, resolution ()); + mp_redraw_thread->commit (m_layers, m_viewport_l, resolution (), font_resolution ()); if (tl::verbosity () >= 20) { tl::info << "Restored image from cache"; @@ -456,7 +464,7 @@ LayoutCanvas::prepare_drawing () } if (m_redraw_clearing) { - mp_redraw_thread->start (mp_view->synchronous () ? 0 : mp_view->drawing_workers (), m_layers, m_viewport_l, resolution (), m_redraw_force_update); + mp_redraw_thread->start (mp_view->synchronous () ? 0 : mp_view->drawing_workers (), m_layers, m_viewport_l, resolution (), font_resolution (), m_redraw_force_update); } else { mp_redraw_thread->restart (m_need_redraw_layer); } @@ -642,8 +650,8 @@ class DetachedViewObjectCanvas : public BitmapViewObjectCanvas { public: - DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, tl::PixelBuffer *img) - : BitmapViewObjectCanvas (width_l, height_l, resolution), + DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, double font_resolution, tl::PixelBuffer *img) + : BitmapViewObjectCanvas (width_l, height_l, resolution, font_resolution), m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img) { // TODO: Good choice? @@ -728,7 +736,7 @@ class DetachedViewObjectCanvasMono { public: DetachedViewObjectCanvasMono (bool bg, bool fg, bool ac, unsigned int width, unsigned int height) - : BitmapViewObjectCanvas (width, height, 1.0), + : BitmapViewObjectCanvas (width, height, 1.0, 1.0), m_bg (bg), m_fg (fg), m_ac (ac) { // .. nothing yet .. @@ -798,7 +806,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l // provide canvas objects for the layout bitmaps and the foreground/background objects BitmapRedrawThreadCanvas rd_canvas; - DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, &img); + DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, resolution, &img); // compute the new viewport db::DBox tb (target_box); @@ -811,7 +819,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l lay::RedrawThread redraw_thread (&rd_canvas, mp_view); // render the layout - redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, true); + redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, resolution, true); redraw_thread.stop (); // safety // paint the background objects. It uses "img" to paint on. @@ -859,7 +867,7 @@ LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, lay::RedrawThread redraw_thread (&rd_canvas, mp_view); // render the layout - redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true); + redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, 1.0, true); redraw_thread.stop (); // safety tl::BitmapBuffer img (width, height); @@ -879,7 +887,7 @@ LayoutCanvas::screenshot () tl::PixelBuffer img (m_viewport.width (), m_viewport.height ()); img.fill (m_background); - DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), resolution (), &img); + DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), resolution (), font_resolution (), &img); // and paint the background objects. It uses "img" to paint on. do_render_bg (m_viewport_l, vo_canvas); diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 2bc68edf77..027705b1a0 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -334,10 +334,15 @@ class LAYBASIC_PUBLIC LayoutCanvas } /** - * @brief Reimplementation of ViewObjectCanvas: Resolution + * @brief Reimplementation of ViewObjectCanvas interface */ double resolution () const; + /** + * @brief Reimplementation of ViewObjectCanvas interface + */ + double font_resolution () const; + /** * @brief Gets the gamma value */ diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index bfef34ba54..a4ae68e4fb 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -1598,10 +1598,10 @@ LayoutViewBase::icon_for_layer (const LayerPropertiesConstIterator &iter, unsign *sl0++ = 0; } - lay::Bitmap fill (w, h, 1.0); - lay::Bitmap frame (w, h, 1.0); - lay::Bitmap text (w, h, 1.0); - lay::Bitmap vertex (w, h, 1.0); + lay::Bitmap fill (w, h, 1.0, 1.0); + lay::Bitmap frame (w, h, 1.0, 1.0); + lay::Bitmap text (w, h, 1.0, 1.0); + lay::Bitmap vertex (w, h, 1.0, 1.0); unsigned int wp = w - 1; diff --git a/src/laybasic/laybasic/layPixelBufferPainter.cc b/src/laybasic/laybasic/layPixelBufferPainter.cc index 105a8f1864..60d501c891 100644 --- a/src/laybasic/laybasic/layPixelBufferPainter.cc +++ b/src/laybasic/laybasic/layPixelBufferPainter.cc @@ -24,13 +24,14 @@ #include "layFixedFont.h" #include "tlPixelBuffer.h" +#include "dbVector.h" namespace lay { -PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution) +PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution, double font_resolution) : mp_img (&img), - m_resolution (resolution), m_width (width), m_height (height) + m_resolution (resolution), m_font_resolution (font_resolution), m_width (width), m_height (height) { // .. nothing yet .. } @@ -38,13 +39,29 @@ PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width void PixelBufferPainter::set (const db::Point &p, tl::Color c) { - if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { + if (m_resolution < 1.0 - 1e-10) { + fill_rect (p, p, c); + } else if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { ((unsigned int *) mp_img->scan_line (p.y ())) [p.x ()] = c.rgb (); } } void PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, tl::Color c) +{ + if (m_resolution < 1.0 - 1e-10) { + if (p1.x () == p2.x () || p1.y () == p2.y ()) { + fill_rect (p1, p2, c); + } else { + // TODO: not implemented yet. + } + } else { + draw_line_int (p1, p2, c); + } +} + +void +PixelBufferPainter::draw_line_int (const db::Point &p1, const db::Point &p2, tl::Color c) { if (p1.x () == p2.x ()) { @@ -80,11 +97,22 @@ PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, tl::Col void PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, tl::Color c) +{ + unsigned int f = (unsigned int) (1.0 / m_resolution + 1e-10); + if (f == 1) { + fill_rect_int (p1, p2, c); + } else { + fill_rect_int (p1 - db::Vector (db::Coord (f / 2), db::Coord (f / 2)), p2 + db::Vector (db::Coord (f - f / 2 - 1), db::Coord (f - f / 2 - 1)), c); + } +} + +void +PixelBufferPainter::fill_rect_int (const db::Point &p1, const db::Point &p2, tl::Color c) { int y1 = std::min (p1.y (), p2.y ()); int y2 = std::max (p1.y (), p2.y ()); for (int y = y1; y <= y2; ++y) { - draw_line (db::Point (p1.x (), y), db::Point (p2.x (), y), c); + draw_line_int (db::Point (p1.x (), y), db::Point (p2.x (), y), c); } } @@ -104,7 +132,7 @@ PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, tl::Col void PixelBufferPainter::draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign) { - const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); + const lay::FixedFont &ff = lay::FixedFont::get_font (m_font_resolution); int x = p.x (), y = p.y (); if (halign < 0) { diff --git a/src/laybasic/laybasic/layPixelBufferPainter.h b/src/laybasic/laybasic/layPixelBufferPainter.h index 99d2585f22..97deb161be 100644 --- a/src/laybasic/laybasic/layPixelBufferPainter.h +++ b/src/laybasic/laybasic/layPixelBufferPainter.h @@ -44,7 +44,7 @@ namespace lay { class LAYBASIC_PUBLIC PixelBufferPainter { public: - PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution); + PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution, double font_resolution); void set (const db::Point &p, tl::Color c); void draw_line (const db::Point &p1, const db::Point &p2, tl::Color c); @@ -54,8 +54,11 @@ class LAYBASIC_PUBLIC PixelBufferPainter private: tl::PixelBuffer *mp_img; - double m_resolution; + double m_resolution, m_font_resolution; int m_width, m_height; + + void fill_rect_int (const db::Point &p1, const db::Point &p2, tl::Color c); + void draw_line_int (const db::Point &p1, const db::Point &p2, tl::Color c); }; } diff --git a/src/laybasic/laybasic/layRedrawThread.cc b/src/laybasic/laybasic/layRedrawThread.cc index ecdd02b5bd..4ee9685f6c 100644 --- a/src/laybasic/laybasic/layRedrawThread.cc +++ b/src/laybasic/laybasic/layRedrawThread.cc @@ -46,6 +46,7 @@ RedrawThread::RedrawThread (lay::RedrawThreadCanvas *canvas, LayoutViewBase *vie m_width = 0; m_height = 0; m_resolution = 1.0; + m_font_resolution = 1.0; m_boxes_already_drawn = false; m_custom_already_drawn = false; m_nlayers = 0; @@ -106,12 +107,13 @@ subtract_box (const db::DBox &subject, const db::DBox &with) } void -RedrawThread::commit (const std::vector &layers, const lay::Viewport &vp, double resolution) +RedrawThread::commit (const std::vector &layers, const lay::Viewport &vp, double resolution, double font_resolution) { m_vp_trans = vp.trans (); m_width = vp.width (); m_height = vp.height (); m_resolution = resolution; + m_font_resolution = font_resolution; m_layers = layers; m_nlayers = int (m_layers.size ()); @@ -131,12 +133,13 @@ RedrawThread::commit (const std::vector &layers, const la } void -RedrawThread::start (int workers, const std::vector &layers, const lay::Viewport &vp, double resolution, bool force_redraw) +RedrawThread::start (int workers, const std::vector &layers, const lay::Viewport &vp, double resolution, double font_resolution, bool force_redraw) { m_vp_trans = vp.trans (); m_width = vp.width (); m_height = vp.height (); m_resolution = resolution; + m_font_resolution = font_resolution; db::DBox new_region = m_vp_trans.inverted () * db::DBox (db::DPoint (0, 0), db::DPoint (m_width, m_height)); double epsilon = m_vp_trans.inverted ().ctrans (1e-3); @@ -261,7 +264,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v if (clear) { - mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, shift_vector, 0, mp_view->drawings ()); + mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, m_font_resolution, shift_vector, 0, mp_view->drawings ()); m_boxes_already_drawn = false; m_custom_already_drawn = false; @@ -281,7 +284,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v } } - mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, shift_vector, &planes_to_init, mp_view->drawings ()); + mp_canvas->prepare (m_nlayers * planes_per_layer + special_planes_before + special_planes_after, m_width, m_height, m_resolution, m_font_resolution, shift_vector, &planes_to_init, mp_view->drawings ()); for (std::vector::const_iterator l = restart.begin (); l != restart.end (); ++l) { if (*l >= 0 && *l < int (m_layers.size ())) { @@ -315,7 +318,7 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v } } else { - mp_canvas->prepare (1, m_width, m_height, m_resolution, 0, 0, mp_view->drawings ()); + mp_canvas->prepare (1, m_width, m_height, m_resolution, m_font_resolution, 0, 0, mp_view->drawings ()); } } diff --git a/src/laybasic/laybasic/layRedrawThread.h b/src/laybasic/laybasic/layRedrawThread.h index 071372965f..decb57160c 100644 --- a/src/laybasic/laybasic/layRedrawThread.h +++ b/src/laybasic/laybasic/layRedrawThread.h @@ -55,8 +55,8 @@ class RedrawThread RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutViewBase *view); virtual ~RedrawThread (); - void commit (const std::vector &layers, const lay::Viewport &vp, double resolution); - void start (int workers, const std::vector &layers, const lay::Viewport &vp, double resolution, bool force_redraw); + void commit (const std::vector &layers, const lay::Viewport &vp, double resolution, double font_resolution); + void start (int workers, const std::vector &layers, const lay::Viewport &vp, double resolution, double font_resolution, bool force_redraw); void restart (const std::vector &restart); void wakeup_checked (); void wakeup (); @@ -107,6 +107,7 @@ class RedrawThread db::DCplxTrans m_vp_trans; int m_width, m_height; double m_resolution; + double m_font_resolution; std::vector m_redraw_regions; db::DBox m_stored_region, m_valid_region; db::DPoint m_last_center; diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.cc b/src/laybasic/laybasic/layRedrawThreadCanvas.cc index a3a945a0ed..ba43c0d21e 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.cc +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.cc @@ -242,9 +242,9 @@ shift_bitmap (const lay::Bitmap *from, lay::Bitmap *to, int dx, int dy) } void -BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, const db::Vector *shift_vector, const std::vector *planes, const lay::Drawings *drawings) +BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector *shift_vector, const std::vector *planes, const lay::Drawings *drawings) { - RedrawThreadCanvas::prepare (nlayers, width, height, resolution, shift_vector, planes, drawings); + RedrawThreadCanvas::prepare (nlayers, width, height, resolution, font_resolution, shift_vector, planes, drawings); lock (); @@ -256,7 +256,7 @@ BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, uns for (size_t i = 0; i < mp_plane_buffers.size (); ++i) { lay::Bitmap *from = mp_plane_buffers [i]; - lay::Bitmap *to = mp_plane_buffers [i] = new lay::Bitmap (width, height, resolution); + lay::Bitmap *to = mp_plane_buffers [i] = new lay::Bitmap (width, height, resolution, font_resolution); shift_bitmap (from, to, shift_vector->x (), shift_vector->y ()); delete from; } @@ -265,7 +265,7 @@ BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, uns for (lay::Drawings::const_iterator d = drawings->begin (); d != drawings->end (); ++d, ++di) { for (unsigned int i = 0; i < d->num_planes (); ++i) { lay::Bitmap *from = mp_drawing_plane_buffers[di][i]; - lay::Bitmap *to = mp_drawing_plane_buffers[di][i] = new lay::Bitmap (width, height, resolution); + lay::Bitmap *to = mp_drawing_plane_buffers[di][i] = new lay::Bitmap (width, height, resolution, font_resolution); shift_bitmap (from, to, shift_vector->x (), shift_vector->y ()); delete from; } @@ -305,13 +305,13 @@ BitmapRedrawThreadCanvas::prepare (unsigned int nlayers, unsigned int width, uns clear_planes (); for (unsigned int i = 0; i < nlayers; ++i) { - mp_plane_buffers.push_back (new lay::Bitmap (width, height, resolution)); + mp_plane_buffers.push_back (new lay::Bitmap (width, height, resolution, font_resolution)); } for (lay::Drawings::const_iterator d = drawings->begin (); d != drawings->end (); ++d) { mp_drawing_plane_buffers.push_back (std::vector ()); for (unsigned int i = 0; i < d->num_planes (); ++i) { - mp_drawing_plane_buffers.back ().push_back (new lay::Bitmap (width, height, resolution)); + mp_drawing_plane_buffers.back ().push_back (new lay::Bitmap (width, height, resolution, font_resolution)); } } @@ -364,7 +364,7 @@ BitmapRedrawThreadCanvas::clear_planes () lay::CanvasPlane * BitmapRedrawThreadCanvas::create_drawing_plane () { - return new lay::Bitmap(m_width, m_height, resolution ()); + return new lay::Bitmap(m_width, m_height, resolution (), font_resolution ()); } void diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index a88b9a8f02..9e156effa2 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -49,7 +49,7 @@ class RedrawThreadCanvas * @brief Constructor */ RedrawThreadCanvas () - : m_resolution (1.0), m_width (0), m_height (0) + : m_resolution (1.0), m_font_resolution (1.0), m_width (0), m_height (0) { } /** @@ -91,11 +91,13 @@ class RedrawThreadCanvas * @param shifting The shift vector by which the original image should be shifted to form the background or 0 if no shifting is required * @param layers The set of plane indexes to initialize (if null, all planes are initialized). A negative value initializes the drawing planes. * @param resolution The resolution in which the image is drawn + * @param font_resolution The resolution in which the "Default" font is drawn * @param drawings The custom drawing interface which is responsible to draw user objects */ - virtual void prepare (unsigned int /*nlayers*/, unsigned int width, unsigned int height, double resolution, const db::Vector * /*shift_vector*/, const std::vector * /*planes*/, const lay::Drawings * /*drawings*/) + virtual void prepare (unsigned int /*nlayers*/, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector * /*shift_vector*/, const std::vector * /*planes*/, const lay::Drawings * /*drawings*/) { m_resolution = resolution; + m_resolution = font_resolution; m_width = width; m_height = height; } @@ -162,6 +164,14 @@ class RedrawThreadCanvas return m_resolution; } + /** + * @brief Get the font resolution value + */ + double font_resolution () const + { + return m_font_resolution; + } + /** * @brief Get the canvas width */ @@ -186,6 +196,7 @@ class RedrawThreadCanvas private: tl::Mutex m_mutex; double m_resolution; + double m_font_resolution; unsigned int m_width, m_height; }; @@ -271,7 +282,7 @@ class BitmapRedrawThreadCanvas * This method is called from RedrawThread::start (), not from the * redraw thread. */ - virtual void prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, const db::Vector *shift_vector, const std::vector *planes, const lay::Drawings *drawings); + virtual void prepare (unsigned int nlayers, unsigned int width, unsigned int height, double resolution, double font_resolution, const db::Vector *shift_vector, const std::vector *planes, const lay::Drawings *drawings); /** * @brief Test a plane with the given index for emptiness @@ -313,7 +324,7 @@ class BitmapRedrawThreadCanvas */ virtual lay::Renderer *create_renderer () { - return new lay::BitmapRenderer (m_width, m_height, resolution ()); + return new lay::BitmapRenderer (m_width, m_height, resolution (), font_resolution ()); } /** diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index 8232d3520e..b16f638b3e 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -1284,7 +1284,7 @@ RedrawThreadWorker::draw_text_layer (bool drawing_context, db::cell_index_type c std::unique_ptr opt_bitmap; lay::Bitmap *vertex_bitmap = dynamic_cast (vertex); if (m_text_lazy_rendering && vertex_bitmap) { - opt_bitmap.reset (new lay::Bitmap (vertex_bitmap->width (), vertex_bitmap->height (), vertex_bitmap->resolution ())); + opt_bitmap.reset (new lay::Bitmap (vertex_bitmap->width (), vertex_bitmap->height (), vertex_bitmap->resolution (), vertex_bitmap->font_resolution ())); } for (std::vector::const_iterator b = vp.begin (); b != vp.end (); ++b) { @@ -1991,10 +1991,10 @@ RedrawThreadWorker::draw_layer (int from_level, int to_level, db::cell_index_typ int width = int (cell_box_trans.width () + 3); // +3 = one pixel for a one-pixel frame at both sides and one for safety int height = int (cell_box_trans.height () + 3); - cached_cell->second.fill = new lay::Bitmap (width, height, 1.0); - cached_cell->second.frame = new lay::Bitmap (width, height, 1.0); - cached_cell->second.vertex = new lay::Bitmap (width, height, 1.0); - cached_cell->second.text = new lay::Bitmap (width, height, 1.0); + cached_cell->second.fill = new lay::Bitmap (width, height, 1.0, 1.0); + cached_cell->second.frame = new lay::Bitmap (width, height, 1.0, 1.0); + cached_cell->second.vertex = new lay::Bitmap (width, height, 1.0, 1.0); + cached_cell->second.text = new lay::Bitmap (width, height, 1.0, 1.0); // this object is responsible for doing updates when a snapshot is taken UpdateSnapshotWithCache update_cached_snapshot (update_snapshot, &trans, &cached_cell->second, fill, frame, vertex, text); diff --git a/src/laybasic/laybasic/layRenderer.cc b/src/laybasic/laybasic/layRenderer.cc index 247f89403c..c7d5fd8b4e 100644 --- a/src/laybasic/laybasic/layRenderer.cc +++ b/src/laybasic/laybasic/layRenderer.cc @@ -36,7 +36,7 @@ namespace lay // ---------------------------------------------------------------------------------------------- // Renderer implementation -Renderer::Renderer (unsigned int width, unsigned int height, double resolution) +Renderer::Renderer (unsigned int width, unsigned int height, double resolution, double font_resolution) : m_draw_texts (true), m_draw_properties (false), m_draw_description_property (false), @@ -47,7 +47,8 @@ Renderer::Renderer (unsigned int width, unsigned int height, double resolution) m_xfill (false), m_font (db::DefaultFont), m_width (width), m_height (height), - m_resolution (resolution) + m_resolution (resolution), + m_font_resolution (font_resolution) { // .. nothing else .. } diff --git a/src/laybasic/laybasic/layRenderer.h b/src/laybasic/laybasic/layRenderer.h index a1ddaf5fcf..71a87feea7 100644 --- a/src/laybasic/laybasic/layRenderer.h +++ b/src/laybasic/laybasic/layRenderer.h @@ -66,7 +66,7 @@ class LAYBASIC_PUBLIC Renderer /** * @brief The ctor */ - Renderer (unsigned int width, unsigned int height, double resolution); + Renderer (unsigned int width, unsigned int height, double resolution, double font_resolution); /** * @brief The destructor @@ -400,6 +400,17 @@ class LAYBASIC_PUBLIC Renderer return m_resolution; } + /** + * @brief Get the font resolution value + * + * The resolution value is used to convert dimensions on the output device into canvas + * units. This value applies to rendering the "Default" font. + */ + double font_resolution () const + { + return m_font_resolution; + } + protected: bool m_draw_texts; bool m_draw_properties; @@ -412,6 +423,7 @@ class LAYBASIC_PUBLIC Renderer db::Font m_font; unsigned int m_width, m_height; double m_resolution; + double m_font_resolution; }; } // namespace lay diff --git a/src/laybasic/laybasic/layTextInfo.cc b/src/laybasic/laybasic/layTextInfo.cc index a49afb7fcf..2e90847000 100644 --- a/src/laybasic/laybasic/layTextInfo.cc +++ b/src/laybasic/laybasic/layTextInfo.cc @@ -33,7 +33,7 @@ TextInfo::TextInfo (const LayoutViewBase *view) : m_default_text_size (view->default_text_size ()), m_default_font (db::Font (view->text_font ())), m_apply_text_trans (view->apply_text_trans ()), - m_resolution (view->canvas ()->resolution ()), + m_resolution (view->canvas ()->font_resolution ()), m_point_mode (view->text_point_mode ()) { // .. nothing yet .. diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 3b9e5013be..1242f9d4d7 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -1274,14 +1274,14 @@ ViewObjectUI::mouse_event_viewport () const // BitmapViewObjectCanvas implementation BitmapViewObjectCanvas::BitmapViewObjectCanvas () - : ViewObjectCanvas (), m_renderer (1, 1, 1.0), m_width (1), m_height (1), m_resolution (1.0) + : ViewObjectCanvas (), m_renderer (1, 1, 1.0, 1.0), m_width (1), m_height (1), m_resolution (1.0), m_font_resolution (1.0) { // .. nothing yet .. } -BitmapViewObjectCanvas::BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution) - : ViewObjectCanvas (), m_renderer (width, height, resolution), - m_width (width), m_height (height), m_resolution (resolution) +BitmapViewObjectCanvas::BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution, double font_resolution) + : ViewObjectCanvas (), m_renderer (width, height, resolution, font_resolution), + m_width (width), m_height (height), m_resolution (resolution), m_font_resolution (font_resolution) { // .. nothing yet .. } @@ -1299,7 +1299,7 @@ BitmapViewObjectCanvas::plane (const lay::ViewOp &style) // we need to create a new plane m_fg_bitmap_table.insert (std::make_pair (style, (unsigned int) mp_alloc_bitmaps.size ())); - lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution); + lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution, m_font_resolution); mp_fg_bitmaps.push_back (bm); mp_alloc_bitmaps.push_back (bm); m_fg_view_ops.push_back (style); @@ -1319,7 +1319,7 @@ BitmapViewObjectCanvas::plane (const std::vector &style) // we need to create a new bitmap m_fgv_bitmap_table.insert (std::make_pair (style, (unsigned int) mp_alloc_bitmaps.size ())); - lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution); + lay::Bitmap *bm = new lay::Bitmap (m_width, m_height, m_resolution, m_font_resolution); mp_alloc_bitmaps.push_back (bm); for (std::vector::const_iterator s = style.begin (); s != style.end (); ++s) { mp_fg_bitmaps.push_back (bm); @@ -1366,26 +1366,27 @@ BitmapViewObjectCanvas::sort_planes () } void -BitmapViewObjectCanvas::set_size (unsigned int width, unsigned int height, double resolution) +BitmapViewObjectCanvas::set_size (unsigned int width, unsigned int height, double resolution, double font_resolution) { - m_renderer = lay::BitmapRenderer (width, height, resolution); + m_renderer = lay::BitmapRenderer (width, height, resolution, font_resolution); m_width = width; m_height = height; m_resolution = resolution; + m_font_resolution = font_resolution; } void BitmapViewObjectCanvas::set_size (unsigned int width, unsigned int height) { - m_renderer = lay::BitmapRenderer (width, height, m_resolution); + m_renderer = lay::BitmapRenderer (width, height, m_resolution, m_font_resolution); m_width = width; m_height = height; } void -BitmapViewObjectCanvas::set_size (double resolution) +BitmapViewObjectCanvas::set_size (double resolution, double font_resolution) { - m_renderer = lay::BitmapRenderer (m_width, m_height, resolution); + m_renderer = lay::BitmapRenderer (m_width, m_height, resolution, font_resolution); m_resolution = resolution; } diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index 3c5ee7199a..89698149eb 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -1172,6 +1172,13 @@ class LAYBASIC_PUBLIC ViewObjectCanvas */ virtual double resolution () const = 0; + /** + * @brief Get the font resolution + * + * The resolution describes the size of one pixel for the rendering of the "Default" font. + */ + virtual double font_resolution () const = 0; + /** * @brief CanvasPlane provider * @@ -1225,7 +1232,7 @@ class LAYBASIC_PUBLIC BitmapViewObjectCanvas /** * @brief Constructor */ - BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution); + BitmapViewObjectCanvas (unsigned int width, unsigned int height, double resolution, double font_resolution); /** * @brief The destructor @@ -1276,6 +1283,14 @@ class LAYBASIC_PUBLIC BitmapViewObjectCanvas return m_resolution; } + /** + * @brief Get the font resolution + */ + virtual double font_resolution () const + { + return m_font_resolution; + } + /** * @brief Return the number of bitmaps stored so far */ @@ -1330,7 +1345,7 @@ class LAYBASIC_PUBLIC BitmapViewObjectCanvas /** * @brief Set the width and height and resolution */ - void set_size (unsigned int width, unsigned int height, double resolution); + void set_size (unsigned int width, unsigned int height, double resolution, double font_resolution); /** * @brief Set the width and height @@ -1340,7 +1355,7 @@ class LAYBASIC_PUBLIC BitmapViewObjectCanvas /** * @brief Set the resolution */ - void set_size (double resolution); + void set_size (double resolution, double font_resolution); /** * @brief Get the width @@ -1377,6 +1392,7 @@ class LAYBASIC_PUBLIC BitmapViewObjectCanvas lay::BitmapRenderer m_renderer; unsigned int m_width, m_height; double m_resolution; + double m_font_resolution; }; } // namespace lay diff --git a/src/laybasic/unit_tests/layBitmap.cc b/src/laybasic/unit_tests/layBitmap.cc index 72c76b2363..da676a7348 100644 --- a/src/laybasic/unit_tests/layBitmap.cc +++ b/src/laybasic/unit_tests/layBitmap.cc @@ -45,7 +45,7 @@ to_string (const lay::Bitmap &bm) TEST(1) { - lay::Bitmap b1 (8, 8, 1.0); + lay::Bitmap b1 (8, 8, 1.0, 1.0); EXPECT_EQ (to_string (b1), "--------\n" "--------\n" "--------\n" @@ -78,7 +78,7 @@ TEST(1) TEST(2) { - lay::Bitmap b1 (8, 8, 1.0); + lay::Bitmap b1 (8, 8, 1.0, 1.0); EXPECT_EQ (to_string (b1), "--------\n" "--------\n" "--------\n" @@ -88,7 +88,7 @@ TEST(2) "--------\n" "--------\n"); - lay::Bitmap b2 (3, 2, 1.0); + lay::Bitmap b2 (3, 2, 1.0, 1.0); b2.fill (0, 0, 3); b2.fill (1, 1, 3); EXPECT_EQ (to_string (b2), "-##\n###\n"); @@ -135,7 +135,7 @@ TEST(2) "--------\n" "--------\n"); - b1 = lay::Bitmap (40, 8, 1.0); + b1 = lay::Bitmap (40, 8, 1.0, 1.0); EXPECT_EQ (to_string (b1), "----------------------------------------\n" "----------------------------------------\n" "----------------------------------------\n" @@ -145,7 +145,7 @@ TEST(2) "----------------------------------------\n" "----------------------------------------\n"); - b2 = lay::Bitmap (40, 8, 1.0); + b2 = lay::Bitmap (40, 8, 1.0, 1.0); b2.fill (1, 4, 36); b2.fill (2, 5, 15); b2.fill (2, 34, 35); diff --git a/src/laybasic/unit_tests/layBitmapsToImage.cc b/src/laybasic/unit_tests/layBitmapsToImage.cc index 6e68e375c8..dd66c7c750 100644 --- a/src/laybasic/unit_tests/layBitmapsToImage.cc +++ b/src/laybasic/unit_tests/layBitmapsToImage.cc @@ -43,14 +43,14 @@ to_string (const tl::PixelBuffer &img, unsigned int mask) TEST(1) { - lay::Bitmap b1 (32, 32, 1.0); - lay::Bitmap b2 (32, 32, 1.0); - lay::Bitmap b3 (32, 32, 1.0); - lay::Bitmap b4 (32, 32, 1.0); - lay::Bitmap b5 (32, 32, 1.0); - lay::Bitmap b6 (32, 32, 1.0); - lay::Bitmap b7 (32, 32, 1.0); - lay::Bitmap b8 (32, 32, 1.0); + lay::Bitmap b1 (32, 32, 1.0, 1.0); + lay::Bitmap b2 (32, 32, 1.0, 1.0); + lay::Bitmap b3 (32, 32, 1.0, 1.0); + lay::Bitmap b4 (32, 32, 1.0, 1.0); + lay::Bitmap b5 (32, 32, 1.0, 1.0); + lay::Bitmap b6 (32, 32, 1.0, 1.0); + lay::Bitmap b7 (32, 32, 1.0, 1.0); + lay::Bitmap b8 (32, 32, 1.0, 1.0); std::vector pbitmaps; pbitmaps.push_back (&b1); diff --git a/src/laybasic/unit_tests/layRenderer.cc b/src/laybasic/unit_tests/layRenderer.cc index 4f763cb704..fb9a37ac87 100644 --- a/src/laybasic/unit_tests/layRenderer.cc +++ b/src/laybasic/unit_tests/layRenderer.cc @@ -68,9 +68,9 @@ to_string (const lay::Bitmap &bm, const lay::Bitmap &bf) TEST(1) { - lay::Bitmap b1 (16, 16, 1.0); + lay::Bitmap b1 (16, 16, 1.0, 1.0); - lay::BitmapRenderer r (16, 16, 1.0); + lay::BitmapRenderer r (16, 16, 1.0, 1.0); r.insert (db::DEdge (3.4, 2.1, 12.7, -2.1)); r.insert (db::DEdge (12.7, -2.1, 3.4, 2.1)); r.insert (db::DEdge (3.4, 2.1, 12.7, 2.1)); @@ -103,9 +103,9 @@ TEST(1) TEST(2) { - lay::Bitmap b1 (16, 16, 1.0); + lay::Bitmap b1 (16, 16, 1.0, 1.0); - lay::BitmapRenderer r(16, 16, 1.0); + lay::BitmapRenderer r(16, 16, 1.0, 1.0); r.clear (); r.insert (db::DEdge (3.4, 2.1, 12.7, 12.1)); r.insert (db::DEdge (3.4, 0.1, 100.0, 22.5)); @@ -135,7 +135,7 @@ TEST(2) r.insert (db::DEdge (100.0, 0.1, 3.4, 14.5)); r.insert (db::DEdge (12.7, 5.1, 3.4, 5.1)); r.insert (db::DEdge (15.3, -5.1, -5.1, 5.0)); - b1 = lay::Bitmap (16, 16, 1.0); + b1 = lay::Bitmap (16, 16, 1.0, 1.0); r.render_contour (b1); EXPECT_EQ (to_string (b1), "---#------------\n" @@ -159,10 +159,10 @@ TEST(2) TEST(3) { - lay::Bitmap b1 (16, 16, 1.0); - lay::Bitmap b2 (16, 16, 1.0); + lay::Bitmap b1 (16, 16, 1.0, 1.0); + lay::Bitmap b2 (16, 16, 1.0, 1.0); - lay::BitmapRenderer r(16, 16, 1.0); + lay::BitmapRenderer r(16, 16, 1.0, 1.0); r.insert (db::DEdge (3.4, 2.1, 12.7, 14.5)); r.insert (db::DEdge (12.7, 14.5, 10.7, 0.6)); r.insert (db::DEdge (10.7, 0.6, 3.4, 2.1)); @@ -190,8 +190,8 @@ TEST(3) r.insert (db::DEdge (3.1, 9.0, 12.7, 14.5)); r.insert (db::DEdge (12.7, 14.5, 10.7, 0.6)); r.insert (db::DEdge (10.7, 0.6, 3.1, 9.0)); - b1 = lay::Bitmap (16, 16, 1.0); - b2 = lay::Bitmap (16, 16, 1.0); + b1 = lay::Bitmap (16, 16, 1.0, 1.0); + b2 = lay::Bitmap (16, 16, 1.0, 1.0); r.render_fill (b1); r.render_contour (b2); @@ -217,8 +217,8 @@ TEST(3) r.insert (db::DEdge (3.0, 14.0, 12.0, 14.0)); r.insert (db::DEdge (12.0, 14.0, 12.0, 9.0)); r.insert (db::DEdge (12.0, 9.0, 3.0, 9.0)); - b1 = lay::Bitmap (16, 16, 1.0); - b2 = lay::Bitmap (16, 16, 1.0); + b1 = lay::Bitmap (16, 16, 1.0, 1.0); + b2 = lay::Bitmap (16, 16, 1.0, 1.0); r.render_fill (b1); // r.render_contour (b2); @@ -250,8 +250,8 @@ TEST(3) r.insert (db::DEdge (8.8, 6.0, 4.2, 2.9)); r.insert (db::DEdge (4.2, 2.9, 12.2, 0.4)); r.insert (db::DEdge (12.2, 0.4, 0.2, 9.6)); - b1 = lay::Bitmap (16, 16, 1.0); - b2 = lay::Bitmap (16, 16, 1.0); + b1 = lay::Bitmap (16, 16, 1.0, 1.0); + b2 = lay::Bitmap (16, 16, 1.0, 1.0); r.render_fill (b1); r.render_contour (b2); diff --git a/src/layview/layview/layGridNet.cc b/src/layview/layview/layGridNet.cc index 399dbbefec..cabc0396b2 100644 --- a/src/layview/layview/layGridNet.cc +++ b/src/layview/layview/layGridNet.cc @@ -237,7 +237,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) return; } - PixelBufferPainter painter (*bmp_canvas->bg_image (), bmp_canvas->canvas_width (), bmp_canvas->canvas_height (), bmp_canvas->resolution ()); + PixelBufferPainter painter (*bmp_canvas->bg_image (), bmp_canvas->canvas_width (), bmp_canvas->canvas_height (), bmp_canvas->resolution (), bmp_canvas->font_resolution ()); db::DCplxTrans trans = vp.trans (); db::DCplxTrans::inverse_trans trans_inv (trans.inverted ()); @@ -245,15 +245,14 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) db::DBox dbworld (trans_inv * db::DBox (0.0, 0.0, double (vp.width ()), double (vp.height ()))); // fw is the basic unit of the ruler geometry - const lay::FixedFont &ff = lay::FixedFont::get_font (bmp_canvas->resolution ()); - int fw = ff.width (); + int fwr = lay::FixedFont::get_font (bmp_canvas->font_resolution ()).width (); double dgrid = trans.ctrans (m_grid); GridStyle style = m_style1; // compute major grid and switch to secondary style if necessary int s = 0; - while (dgrid < fw * 4) { + while (dgrid < fwr * 4) { if (s == 0) { dgrid *= 2.0; } else if (s == 1) { @@ -282,9 +281,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) if (m_show_ruler && dgrid < vp.width () * 0.2) { - int rh = int (floor (0.5 + fw * 0.8)); - int xoffset = int (floor (0.5 + fw * 2.5)); - int yoffset = int (floor (0.5 + fw * 2.5)); + int rh = int (floor (0.5 + fwr * 0.8)); + int xoffset = int (floor (0.5 + fwr * 2.5)); + int yoffset = int (floor (0.5 + fwr * 2.5)); painter.fill_rect (db::Point (xoffset, vp.height () - yoffset - rh / 2), db::Point (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2), From 40e360e6404a580fecccc7b8781c553166460ed3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 22:23:48 +0200 Subject: [PATCH 4/7] Fixed a potential segfault in the text renderer --- src/laybasic/laybasic/layBitmap.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/laybasic/laybasic/layBitmap.cc b/src/laybasic/laybasic/layBitmap.cc index 9a23bca4d3..f82b5506e8 100644 --- a/src/laybasic/laybasic/layBitmap.cc +++ b/src/laybasic/laybasic/layBitmap.cc @@ -293,16 +293,14 @@ Bitmap::fill_pattern (int y, int x, const uint32_t *pp, unsigned int stride, uns while (n > 0 && y >= 0) { - for (unsigned int s = 0; s < stride; ++s) { + for (unsigned int s = 0; s < stride; ++s, pp++) { - int x1 = x + s * 32; - - uint32_t p = *pp++; + uint32_t p = *pp; - if (x1 < 0) { - if (x1 <= -32) { - return; - } + int x1 = x + s * 32; + if (x1 <= -32 || x1 >= m_width) { + continue; + } else if (x1 < 0) { p >>= (unsigned int)-x1; x1 = 0; } From 7470023d3805a016146c5d173ebcd136da859856 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 3 Aug 2024 22:47:10 +0200 Subject: [PATCH 5/7] Deploying font_resolution somewhat further, but not using it for now --- src/lay/lay/layMainWindow.cc | 1 + .../laybasic/gsiDeclLayLayoutViewBase.cc | 6 +++--- src/laybasic/laybasic/layLayoutCanvas.cc | 11 +++++++---- src/laybasic/laybasic/layLayoutCanvas.h | 2 +- src/laybasic/laybasic/layLayoutViewBase.cc | 12 ++++++------ src/laybasic/laybasic/layLayoutViewBase.h | 9 ++++++--- src/layview/unit_tests/layLayoutViewTests.cc | 16 ++++++++-------- 7 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index dce7dd237c..5669b39363 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -1559,6 +1559,7 @@ MainWindow::cm_print () scale_factor, 1, 1.0 / scale_factor, + 1.0 / scale_factor, tl::Color (QColor (Qt::white)), // foreground tl::Color (QColor (Qt::black)), // background tl::Color (QColor (Qt::black)), // active diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index a36fd04682..f88f1aa3d9 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -332,7 +332,7 @@ static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std:: static tl::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box) { - return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box); + return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, resolution, tl::Color (), tl::Color (), tl::Color (), target_box); } static tl::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box) @@ -342,13 +342,13 @@ static tl::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, static void save_image_with_options (lay::LayoutViewBase *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { - view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome); + view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome); } #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { - return view->get_image_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome); + return view->get_image_with_options (width, height, linewidth, oversampling, resolution, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome); } static QWidget *widget (lay::LayoutViewBase *view) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 4278809d0b..85574a1ad0 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -769,11 +769,11 @@ class DetachedViewObjectCanvasMono tl::PixelBuffer LayoutCanvas::image (unsigned int width, unsigned int height) { - return image_with_options (width, height, -1, -1, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ()); + return image_with_options (width, height, -1, -1, -1.0, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ()); } tl::PixelBuffer -LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box) +LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box) { if (oversampling <= 0) { oversampling = m_oversampling; @@ -781,6 +781,9 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l if (resolution <= 0.0) { resolution = 1.0 / oversampling; } + if (font_resolution <= 0.0) { + font_resolution = resolution; + } if (linewidth <= 0) { linewidth = 1.0 / resolution + 0.5; } @@ -806,7 +809,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l // provide canvas objects for the layout bitmaps and the foreground/background objects BitmapRedrawThreadCanvas rd_canvas; - DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, resolution, &img); + DetachedViewObjectCanvas vo_canvas (background, foreground, active, width * oversampling, height * oversampling, resolution, font_resolution, &img); // compute the new viewport db::DBox tb (target_box); @@ -819,7 +822,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l lay::RedrawThread redraw_thread (&rd_canvas, mp_view); // render the layout - redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, resolution, true); + redraw_thread.start (0 /*synchronous*/, m_layers, vp, resolution, font_resolution, true); redraw_thread.stop (); // safety // paint the background objects. It uses "img" to paint on. diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 027705b1a0..6f425d060d 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -175,7 +175,7 @@ class LAYBASIC_PUBLIC LayoutCanvas tl::PixelBuffer screenshot (); tl::PixelBuffer image (unsigned int width, unsigned int height); - tl::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box); + tl::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box); tl::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box); void update_image (); diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index a4ae68e4fb..80eaa2456b 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -2899,7 +2899,7 @@ LayoutViewBase::get_pixels (unsigned int width, unsigned int height) #if defined(HAVE_QT) QImage -LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, +LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); @@ -2909,20 +2909,20 @@ LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, if (monochrome) { return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image_copy (); } else { - return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image_copy (); + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box).to_image_copy (); } } #endif tl::PixelBuffer -LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, +LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); refresh (); - return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box); + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box); } tl::BitmapBuffer @@ -2987,7 +2987,7 @@ LayoutViewBase::save_image (const std::string &, unsigned int, unsigned int) #if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) void LayoutViewBase::save_image_with_options (const std::string &fn, - unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); @@ -3007,7 +3007,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } else { - if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image ())) { + if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box).to_image ())) { throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index e18dee2bc8..872ba20c38 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -922,13 +922,14 @@ class LAYBASIC_PUBLIC LayoutViewBase : * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param font_resolution The resolution for rendering the "Default" font * @param background The background color or tl::Color() for default * @param foreground The foreground color or tl::Color() for default * @param active The active color or tl::Color() for default * @param target_box The box to draw or db::DBox() for default * @param monochrome If true, monochrome images will be produced */ - void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome); + void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome); #if defined(HAVE_QT) /** @@ -951,13 +952,14 @@ class LAYBASIC_PUBLIC LayoutViewBase : * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param font_resolution The resolution for rendering the "Default" font * @param background The background color or tl::Color() for default * @param foreground The foreground color or tl::Color() for default * @param active The active color or tl::Color() for default * @param target_box The box to draw or db::DBox() for default * @param monochrome If true, monochrome images will be produced */ - QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome); + QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome); #endif /** @@ -968,12 +970,13 @@ class LAYBASIC_PUBLIC LayoutViewBase : * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param font_resolution The resolution for rendering the "Default" font * @param background The background color or tl::Color() for default * @param foreground The foreground color or tl::Color() for default * @param active The active color or tl::Color() for default * @param target_box The box to draw or db::DBox() for default */ - tl::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box); + tl::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box); /** * @brief Get the screen content as a monochrome tl::BitmapBuffer object with the given options diff --git a/src/layview/unit_tests/layLayoutViewTests.cc b/src/layview/unit_tests/layLayoutViewTests.cc index 4b84218209..ed56b57089 100644 --- a/src/layview/unit_tests/layLayoutViewTests.cc +++ b/src/layview/unit_tests/layLayoutViewTests.cc @@ -91,7 +91,7 @@ TEST(1) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); QImage qimg; - qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); @@ -113,7 +113,7 @@ TEST(2) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); QImage qimg; - qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); @@ -136,7 +136,7 @@ TEST(3) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); QImage qimg; - qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true); + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true); EXPECT_EQ (qimg.format () == QImage::Format_MonoLSB, true); @@ -182,7 +182,7 @@ TEST(11) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); tl::PixelBuffer img; - img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ()); + img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ()); std::string tmp = tmp_file ("test.png"); { @@ -210,7 +210,7 @@ TEST(12) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); tl::PixelBuffer img; - img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ()); + img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox ()); std::string tmp = tmp_file ("test.png"); { @@ -269,7 +269,7 @@ TEST(21) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); std::string tmp = tmp_file ("test.png"); - lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); tl::PixelBuffer img; { @@ -297,7 +297,7 @@ TEST(22) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); std::string tmp = tmp_file ("test.png"); - lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), false); tl::PixelBuffer img; { @@ -326,7 +326,7 @@ TEST(23) lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); std::string tmp = tmp_file ("test.png"); - lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, 1.0, tl::Color (255, 255, 255), tl::Color (0, 0, 0), tl::Color (128, 128, 128), db::DBox (), true); tl::BitmapBuffer img; { From 13dec274a378308ba6ca0337181761531f73fea5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 4 Aug 2024 21:38:05 +0200 Subject: [PATCH 6/7] Small redesign of the UI --- src/layui/layui/LayoutViewConfigPage7.ui | 49 ++++++++++++++++-------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/layui/layui/LayoutViewConfigPage7.ui b/src/layui/layui/LayoutViewConfigPage7.ui index 279f88998f..7f7939b75f 100644 --- a/src/layui/layui/LayoutViewConfigPage7.ui +++ b/src/layui/layui/LayoutViewConfigPage7.ui @@ -7,7 +7,7 @@ 0 0 613 - 496 + 559 @@ -50,16 +50,33 @@ 6 - + + + + Oversampling increases the image quality by using an internal resolution larger than the image resolution. Drawing speed is somewhat reduced. + + + true + + + + - High resolution mode utilizes the full pixel density on high-DPI displays. Features may look small but rich in details. + High resolution mode utilizes the full pixel density on high-DPI displays. Features may look smaller, but richer in details. true + + + + Oversampling mode + + + @@ -79,10 +96,10 @@ - - + + - Oversampling mode + High resolution mode enabled @@ -99,27 +116,27 @@ - - + + - Oversampling increases the image quality by using an internal resolution larger than the image resolution. Drawing speed is somewhat reduced. + With small rendering, the line widths and stipples are scaled down - a single pixel line becomes half a pixel wide with 2x oversampling. This provides a virtual sub-pixel resolution with finer details. true - - + + - High resolution mode enabled + Small rendering in oversampling mode - - - - Subresolution mode - scale down line widths and stipples with oversampling + + + + Qt::Horizontal From aada3424a9bccc1787a4bd900ea5d6bdbcb5f44b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 9 Aug 2024 17:45:24 +0200 Subject: [PATCH 7/7] Fixed non-Qt builds --- src/laybasic/laybasic/layLayoutViewBase.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 80eaa2456b..e991a10221 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -3017,7 +3017,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, #elif defined(HAVE_PNG) void LayoutViewBase::save_image_with_options (const std::string &fn, - unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, double font_resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); @@ -3036,7 +3036,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, } else { - tl::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box); + tl::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, font_resolution, background, foreground, active, target_box); img.set_texts (texts); img.write_png (stream);