From 2378f7964e1f3ae1a222a06a7b0565cd7f462530 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 30 Apr 2022 19:13:36 +0200 Subject: [PATCH] WIP --- src/laybasic/laybasic/layLayoutView.cc | 5222 +------------------- src/laybasic/laybasic/layLayoutView.h | 148 +- src/laybasic/laybasic/layLayoutViewBase.cc | 361 +- src/laybasic/laybasic/layLayoutViewBase.h | 99 +- src/laybasic/laybasic/layMouseTracker.cc | 2 +- 5 files changed, 247 insertions(+), 5585 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 9fd12f057..0cfd4853a 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -85,245 +85,37 @@ namespace lay { -// factor for "zoom in & out" -const double zoom_factor = 0.7; - -// factor by which panning is faster in "fast" (+Shift) mode -const double fast_factor = 3.0; - // ------------------------------------------------------------- -struct OpHideShowCell - : public db::Op -{ - OpHideShowCell (lay::CellView::cell_index_type ci, int cv_index, bool show) - : m_cell_index (ci), m_cellview_index (cv_index), m_show (show) - { } - - lay::CellView::cell_index_type m_cell_index; - int m_cellview_index; - bool m_show; -}; - -struct OpSetDitherPattern - : public db::Op -{ - OpSetDitherPattern (const lay::DitherPattern &o, const lay::DitherPattern &n) - : db::Op (), m_old (o), m_new (n) - { - // nothing yet. - } - - lay::DitherPattern m_old, m_new; -}; - -struct OpSetLineStyles - : public db::Op -{ - OpSetLineStyles (const lay::LineStyles &o, const lay::LineStyles &n) - : db::Op (), m_old (o), m_new (n) - { - // nothing yet. - } - - lay::LineStyles m_old, m_new; -}; - -struct OpSetLayerProps - : public db::Op -{ - OpSetLayerProps (unsigned int li, unsigned int i, const lay::LayerProperties &o, const lay::LayerProperties &n) - : m_list_index (li), m_index (i), m_old (o), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - size_t m_index; - lay::LayerProperties m_old, m_new; -}; - -struct OpSetLayerPropsNode - : public db::Op -{ - OpSetLayerPropsNode (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &o, const lay::LayerPropertiesNode &n) - : m_list_index (li), m_index (i), m_old (o), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - size_t m_index; - lay::LayerPropertiesNode m_old, m_new; -}; - -struct OpDeleteLayerList - : public db::Op -{ - OpDeleteLayerList (unsigned int li, const lay::LayerPropertiesList &o) - : m_list_index (li), m_old (o) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - lay::LayerPropertiesList m_old; -}; - -struct OpInsertLayerList - : public db::Op -{ - OpInsertLayerList (unsigned int li, const lay::LayerPropertiesList &n) - : m_list_index (li), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - lay::LayerPropertiesList m_new; -}; - -struct OpRenameProps - : public db::Op -{ - OpRenameProps (unsigned int li, const std::string &old_name, const std::string &new_name) - : m_list_index (li), m_old (old_name), m_new (new_name) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - std::string m_old, m_new; -}; - -struct OpSetAllProps - : public db::Op -{ - OpSetAllProps (unsigned int li, const lay::LayerPropertiesList &o, const lay::LayerPropertiesList &n) - : m_list_index (li), m_old (o), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - lay::LayerPropertiesList m_old, m_new; -}; - -struct OpLayerList - : public db::Op -{ - enum Mode { Delete, Insert }; - - OpLayerList (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n, Mode m) - : m_list_index (li), m_index (i), m_mode (m), m_node (n) - { } - - unsigned int m_list_index; - size_t m_index; - Mode m_mode; - lay::LayerPropertiesNode m_node; -}; - -struct OpInsertLayerProps - : public OpLayerList -{ - OpInsertLayerProps (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n) - : OpLayerList (li, i, n, Insert) - { - // .. nothing yet .. - } -}; - -struct OpDeleteLayerProps - : public OpLayerList -{ - OpDeleteLayerProps (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n) - : OpLayerList (li, i, n, Delete) - { - // .. nothing yet .. - } -}; - -// ------------------------------------------------------------- - -const int timer_interval = 500; +const int timer_interval = 10; static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) - : QFrame (parent), - lay::Dispatcher (this, plugin_parent, false /*not standalone*/), - m_editable (editable), - m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutView::do_prop_changed), + : QFrame (parent), + LayoutViewBase (manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { - // either it's us or the parent has a dispatcher - tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8(name)); - init (manager, parent); + init_ui (); } LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - lay::Dispatcher (plugin_parent, false /*not standalone*/), - m_editable (editable), - m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutView::do_prop_changed), + LayoutViewBase (source, manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { - // either it's us or the parent has a dispatcher - tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8 (name)); - - m_annotation_shapes = source->m_annotation_shapes; - - init (manager, parent); - - // set the handle reference and clear all cell related stuff - m_cellviews = source->cellview_list (); - m_hidden_cells = source->m_hidden_cells; - - // clear the history, store path and zoom box - m_display_states.clear (); - m_display_state_ptr = 0; - m_synchronous = source->synchronous (); - m_drawing_workers = source->drawing_workers (); - - // duplicate the layer properties - for (size_t i = 0; i < source->m_layer_properties_lists.size (); ++i) { - if (i >= m_layer_properties_lists.size ()) { - m_layer_properties_lists.push_back (new lay::LayerPropertiesList (*source->m_layer_properties_lists [i])); - } else { - *m_layer_properties_lists [i] = *source->m_layer_properties_lists [i]; - } - m_layer_properties_lists [i]->attach_view (this, (unsigned int) i); - } - - if (! m_layer_properties_lists.empty ()) { - mp_canvas->set_dither_pattern (m_layer_properties_lists [0]->dither_pattern ()); - } + init_ui (); bookmarks (source->bookmarks ()); - set_active_cellview_index (source->active_cellview_index ()); - - // copy the title - m_title = source->m_title; - - layer_list_changed_event (3); - - finish_cellviews_changed (); } bool @@ -370,120 +162,15 @@ LayoutView::init_menu () } void -LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) +LayoutView::init_ui () { - manager (mgr); - - if (dispatcher () == this) { - // if we're the root dispatcher initialize the menu and build the context menus. No other menus are built so far. - init_menu (); - menu ()->build (0, 0); - } - - m_annotation_shapes.manager (mgr); - - m_visibility_changed = false; - m_active_cellview_changed_event_enabled = true; - m_disabled_edits = 0; - m_synchronous = false; - m_drawing_workers = 1; - mp_control_panel = 0; - mp_control_frame = 0; - mp_hierarchy_panel = 0; - mp_hierarchy_frame = 0; - mp_libraries_view = 0; - mp_bookmarks_view = 0; - mp_libraries_frame = 0; - mp_editor_options_frame = 0; - mp_bookmarks_frame = 0; - mp_min_hier_spbx = 0; - mp_max_hier_spbx = 0; - m_from_level = 0; - m_pan_distance = 0.15; - m_wheel_mode = 0; - m_paste_display_mode = 2; - m_guiding_shape_visible = true; - m_guiding_shape_line_width = 1; - m_guiding_shape_color = lay::Color (); - m_guiding_shape_vertex_size = 5; - m_to_level = 0; - m_ctx_dimming = 50; - m_ctx_hollow = false; - m_child_ctx_dimming = 50; - m_child_ctx_hollow = false; - m_child_ctx_enabled = false; - m_abstract_mode_width = 10.0; - m_abstract_mode_enabled = false; - m_box_text_transform = true; - m_box_font = 0; - m_min_size_for_label = 16; - m_cell_box_visible = true; - m_text_visible = true; - m_default_font_size = lay::FixedFont::default_font_size (); - m_text_lazy_rendering = true; - m_bitmap_caching = true; - m_show_properties = false; - m_apply_text_trans = true; - m_default_text_size = 0.1; - m_text_font = 0; - m_show_markers = true; - m_no_stipples = false; - m_stipple_offset = true; - m_fit_new_cell = true; - m_full_hier_new_cell = true; - m_clear_ruler_new_cell = false; - m_dbu_coordinates = false; - m_absolute_coordinates = false; - m_drop_small_cells = false; - m_drop_small_cells_value = 10; - m_drop_small_cells_cond = DSC_Max; - m_draw_array_border_instances = false; - m_dirty = false; m_activated = true; - m_animated = false; - m_phase = 0; - m_palette = lay::ColorPalette::default_palette (); - m_stipple_palette = lay::StipplePalette::default_palette (); - m_display_state_ptr = 0; - m_mode = std::numeric_limits::min (); // nothing selected yet. - mp_tracker = 0; - mp_zoom_service = 0; - mp_selection_service = 0; - mp_move_service = 0; - m_marker_line_width = 0; - m_marker_vertex_size = 0; - m_marker_dither_pattern = 1; - m_marker_line_style = 0; - m_marker_halo = true; - m_transient_selection_mode = true; - m_sel_inside_pcells = false; - m_add_other_layers = false; - m_always_show_source = false; - m_always_show_ld = true; - m_always_show_layout_index = false; - m_search_range = 5; - m_search_range_box = 0; - - m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); - m_current_layer_list = 0; QVBoxLayout *vbl = new QVBoxLayout (this); vbl->setContentsMargins (0, 0, 0, 0); vbl->setSpacing (0); - mp_canvas = new lay::LayoutCanvas (this, this); - vbl->addWidget (mp_canvas); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed ()), this, SLOT (pan_left ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ())); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed_with_shift ()), this, SLOT (pan_left_fast ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed_with_shift ()), this, SLOT (pan_up_fast ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed_with_shift ()), this, SLOT (pan_right_fast ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed_with_shift ()), this, SLOT (pan_down_fast ())); - - if ((m_options & LV_NoHierarchyPanel) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoHierarchyPanel) == 0 && (options () & LV_Naked) == 0) { QFrame *hierarchy_frame = new QFrame (0); hierarchy_frame->setObjectName (QString::fromUtf8 ("left")); @@ -530,7 +217,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - if ((m_options & LV_NoBookmarksView) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoBookmarksView) == 0 && (options () & LV_Naked) == 0) { QFrame *bookmarks_frame = new QFrame (0); bookmarks_frame->setObjectName (QString::fromUtf8 ("bookmarks_frame")); @@ -546,7 +233,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoLibrariesView) == 0 && (options () & LV_Naked) == 0) { mp_libraries_frame = new QFrame (0); mp_libraries_frame->setObjectName (QString::fromUtf8 ("libs_frame")); @@ -562,7 +249,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - if ((m_options & LV_NoEditorOptionsPanel) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoEditorOptionsPanel) == 0 && (options () & LV_Naked) == 0) { mp_editor_options_frame = new lay::EditorOptionsFrame (0); mp_editor_options_frame->populate (this); @@ -571,22 +258,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - // occupy services and editables: - // these services get deleted by the canvas destructor automatically: - if ((m_options & LV_NoTracker) == 0) { - mp_tracker = new lay::MouseTracker (this); - } - if ((m_options & LV_NoZoom) == 0) { - mp_zoom_service = new lay::ZoomService (this); - } - if ((m_options & LV_NoSelection) == 0) { - mp_selection_service = new lay::SelectionService (this); - } - if ((m_options & LV_NoMove) == 0) { - mp_move_service = new lay::MoveService (this); - } - - if ((m_options & LV_NoLayers) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoLayers) == 0 && (options () & LV_Naked) == 0) { mp_control_panel = new lay::LayerControlPanel (this, manager (), 0, "lcp"); mp_control_frame = mp_control_panel; @@ -620,69 +292,6 @@ LayoutView::~LayoutView () { close_event (); - if (ms_current == this) { - ms_current = 0; - } - - // detach all observers - // This is to prevent signals to partially destroyed observers that own a LayoutView - close_event.clear (); - layer_list_changed_event.clear (); - layer_list_deleted_event.clear (); - layer_list_inserted_event.clear (); - current_layer_list_changed_event.clear (); - cell_visibility_changed_event.clear (); - cellviews_about_to_change_event.clear (); - cellview_about_to_change_event.clear (); - cellviews_changed_event.clear (); - cellview_changed_event.clear (); - rdb_list_changed_event.clear (); - l2ndb_list_changed_event.clear (); - file_open_event.clear (); - hier_changed_event.clear (); - geom_changed_event.clear (); - annotations_changed_event.clear (); - - // detach ourselves from any observed objects to prevent signals while destroying - tl::Object::detach_from_all_events (); - - // remove all rdb's - while (num_rdbs () > 0) { - remove_rdb (0); - } - - // remove all L2N DB's - while (num_l2ndbs () > 0) { - remove_l2ndb (0); - } - - // delete layer lists - std::vector layer_properties_lists; - layer_properties_lists.swap (m_layer_properties_lists); - for (std::vector::iterator l = layer_properties_lists.begin (); l != layer_properties_lists.end (); ++l) { - if (*l) { - delete *l; - } - } - - // delete all plugins - std::vector plugins; - plugins.swap (mp_plugins); - for (std::vector::iterator p = plugins.begin (); p != plugins.end (); ++p) { - delete *p; - } - - // detach from the manager, so we can safely delete the manager - manager (0); - - stop (); - - // because LayoutView and LayoutCanvas both control lifetimes of - // ruler objects for example, it is safer to explicitly delete the - // LayoutCanvas object here: - delete mp_canvas; - mp_canvas = 0; - if (mp_control_frame) { delete mp_control_frame; } @@ -785,83 +394,9 @@ LayoutView *LayoutView::current () return ms_current; } -void LayoutView::update_event_handlers () -{ - tl::Object::detach_from_all_events (); - - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - // TODO: get rid of the const_cast hack - const_cast ((*p)->plugin_declaration ())->editable_enabled_changed_event.add (this, &LayoutView::signal_plugin_enabled_changed); - } - - for (unsigned int i = 0; i < cellviews (); ++i) { - cellview (i)->layout ().hier_changed_event.add (this, &LayoutView::signal_hier_changed); - cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutView::signal_bboxes_from_layer_changed, i); - cellview (i)->layout ().dbu_changed_event.add (this, &LayoutView::signal_bboxes_changed); - cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutView::signal_prop_ids_changed); - cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutView::signal_layer_properties_changed); - cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutView::signal_cell_name_changed); - cellview (i)->apply_technology_with_sender_event.add (this, &LayoutView::signal_apply_technology); - } - - annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutView::signal_annotations_changed); - - mp_canvas->viewport_changed_event.add (this, &LayoutView::viewport_changed); -} - -void LayoutView::viewport_changed () -{ - viewport_changed_event (); -} - -bool LayoutView::accepts_drop (const std::string &path_or_url) const -{ - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->accepts_drop (path_or_url)) { - return true; - } - } - return false; -} - -void LayoutView::drop_url (const std::string &path_or_url) -{ - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->accepts_drop (path_or_url)) { - (*p)->drop_url (path_or_url); - break; - } - } -} - -lay::Plugin *LayoutView::create_plugin (const lay::PluginDeclaration *cls) -{ - lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); - if (p) { - - // unhook the plugin from the script side if created there (prevent GC from destroying it) - p->gsi::ObjectBase::keep (); - - mp_plugins.push_back (p); - p->set_plugin_declaration (cls); - - // enable editable functionality - if (p->editable_interface ()) { - enable (p->editable_interface (), cls->editable_enabled ()); - } - - update_event_handlers (); - - } - return p; -} - void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - delete *p; - } - mp_plugins.clear (); + clear_plugins (); // create the plugins for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { @@ -872,10 +407,10 @@ void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { // ant and img are created always create_plugin (&*cls); - } else if ((m_options & LV_NoPlugins) == 0) { + } else if ((options () & LV_NoPlugins) == 0) { // others: only create unless LV_NoPlugins is set create_plugin (&*cls); - } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { + } else if ((options () & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { // except grid net plugin which is created on request create_plugin (&*cls); } @@ -889,26 +424,6 @@ void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) mode (default_mode ()); } -Plugin *LayoutView::get_plugin_by_name (const std::string &name) const -{ - lay::PluginDeclaration *decl = 0; - for (tl::Registrar::iterator cls = tl::Registrar::begin (); !decl && cls != tl::Registrar::end (); ++cls) { - if (cls.current_name () == name) { - decl = cls.operator-> (); - } - } - - if (decl) { - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->plugin_declaration () == decl) { - return *p; - } - } - } - - return 0; -} - namespace { class GotoBookmarkAction @@ -963,119 +478,14 @@ LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) } } -void -LayoutView::set_drawing_workers (int workers) -{ - m_drawing_workers = std::max (0, std::min (100, workers)); -} - -void -LayoutView::set_synchronous (bool s) -{ - m_synchronous = s; -} - -bool -LayoutView::is_dirty () const -{ - return m_dirty; -} - -std::string -LayoutView::title () const -{ - if (! m_title.empty ()) { - return m_title; - } else if (cellviews () == 0) { - return tl::to_string (QObject::tr ("")); - } else { - - int cv_index = active_cellview_index (); - if (cv_index < 0 || cv_index >= int (cellviews ())) { - cv_index = 0; - } - - const lay::CellView &cv0 = cellview (cv_index); - - std::string t; - - t += cv0->name (); - if (cv0->layout ().is_valid_cell_index (cv0.cell_index ())) { - t += " ["; - t += cv0->layout ().cell_name (cv0.cell_index ()); - t += "]"; - } - - if (cellviews () > 1) { - t += " ..."; - } - - return t; - - } -} - -void -LayoutView::set_title (const std::string &t) -{ - if (m_title != t) { - m_title = t; - emit title_changed (); - } -} - -void -LayoutView::reset_title () -{ - if (! m_title.empty ()) { - m_title = ""; - emit title_changed (); - } -} - bool LayoutView::configure (const std::string &name, const std::string &value) { - lay::Dispatcher::configure (name, value); - - if (mp_move_service && mp_move_service->configure (name, value)) { + if (LayoutViewBase::configure (name, value)) { return true; } - if (name == cfg_default_lyp_file) { - - m_def_lyp_file = value; - return false; // not taken - let others set it too. - - } else if (name == cfg_default_add_other_layers) { - - tl::from_string (value, m_add_other_layers); - return false; // not taken - let others set it too. - - } else if (name == cfg_layers_always_show_source) { - - bool a = false; - tl::from_string (value, a); - if (a != m_always_show_source) { - m_always_show_source = a; - layer_list_changed_event (4); - } - - return true; - - } else if (name == cfg_layers_always_show_ld) { - - tl::from_string (value, m_always_show_ld); - update_content (); - return true; - - } else if (name == cfg_layers_always_show_layout_index) { - - tl::from_string (value, m_always_show_layout_index); - update_content (); - return true; - - } else if (name == cfg_flat_cell_list) { + if (name == cfg_flat_cell_list) { bool f; tl::from_string (value, f); @@ -1149,522 +559,6 @@ LayoutView::configure (const std::string &name, const std::string &value) } return true; - } else if (name == cfg_background_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - background_color (color); - // do not take - let others receive the background color events as well - return false; - - } else if (name == cfg_default_font_size) { - - int df = 0; - tl::from_string (value, df); - if (m_default_font_size != df) { - // keep a shadow state to correctly issue the redraw call - m_default_font_size = df; - lay::FixedFont::set_default_font_size (df); - redraw (); - } - // do not take - let others have the event for the redraw call - return false; - - } else if (name == cfg_bitmap_oversampling) { - - int os = 1; - tl::from_string (value, os); - mp_canvas->set_oversampling (os); - return true; - - } else if (name == cfg_image_cache_size) { - - int sz = 0; - tl::from_string (value, sz); - mp_canvas->set_image_cache_size (size_t (sz)); - return true; - - } else if (name == cfg_global_trans) { - - tl::Extractor ex (value.c_str ()); - try { - db::DCplxTrans t; - ex.read (t); - set_global_trans (t); - } catch (...) { } - return true; - - } else if (name == cfg_ctx_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - ctx_color (color); - return true; - - } else if (name == cfg_ctx_dimming) { - - int n; - tl::from_string (value, n); - ctx_dimming (n); - return true; - - } else if (name == cfg_ctx_hollow) { - - bool h; - tl::from_string (value, h); - ctx_hollow (h); - return true; - - } else if (name == cfg_child_ctx_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - child_ctx_color (color); - return true; - - } else if (name == cfg_child_ctx_dimming) { - - int n; - tl::from_string (value, n); - child_ctx_dimming (n); - return true; - - } else if (name == cfg_child_ctx_hollow) { - - bool h; - tl::from_string (value, h); - child_ctx_hollow (h); - return true; - - } else if (name == cfg_child_ctx_enabled) { - - bool h; - tl::from_string (value, h); - child_ctx_enabled (h); - return true; - - } else if (name == cfg_search_range) { - - unsigned int n; - tl::from_string (value, n); - set_search_range (n); - return true; - - } else if (name == cfg_search_range_box) { - - unsigned int n; - tl::from_string (value, n); - set_search_range_box (n); - return true; - - } else if (name == cfg_abstract_mode_enabled) { - - bool e; - tl::from_string (value, e); - abstract_mode_enabled (e); - return true; - - } else if (name == cfg_abstract_mode_width) { - - double w; - tl::from_string (value, w); - abstract_mode_width (w); - return true; - - } else if (name == cfg_min_inst_label_size) { - - int n; - tl::from_string (value, n); - min_inst_label_size (n); - return true; - - } else if (name == cfg_cell_box_text_font) { - - int n; - tl::from_string (value, n); - cell_box_text_font (n); - return true; - - } else if (name == cfg_cell_box_text_transform) { - - bool flag; - tl::from_string (value, flag); - cell_box_text_transform (flag); - return true; - - } else if (name == cfg_cell_box_visible) { - - bool flag; - tl::from_string (value, flag); - cell_box_visible (flag); - return true; - - } else if (name == cfg_cell_box_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - cell_box_color (color); - return true; - - } else if (name == cfg_text_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - text_color (color); - return true; - - } else if (name == cfg_text_visible) { - - bool flag; - tl::from_string (value, flag); - text_visible (flag); - return true; - - } else if (name == cfg_bitmap_caching) { - - bool flag; - tl::from_string (value, flag); - bitmap_caching (flag); - return true; - - } else if (name == cfg_text_lazy_rendering) { - - bool flag; - tl::from_string (value, flag); - text_lazy_rendering (flag); - return true; - - } else if (name == cfg_show_properties) { - - bool flag; - tl::from_string (value, flag); - show_properties_as_text (flag); - return true; - - } else if (name == cfg_apply_text_trans) { - - bool flag; - tl::from_string (value, flag); - apply_text_trans (flag); - return true; - - } else if (name == cfg_markers_visible) { - - bool flag; - tl::from_string (value, flag); - mp_canvas->set_dismiss_view_objects (! flag); - return true; - - } else if (name == cfg_no_stipple) { - - bool flag; - tl::from_string (value, flag); - no_stipples (flag); - return true; - - } else if (name == cfg_stipple_offset) { - - bool flag; - tl::from_string (value, flag); - offset_stipples (flag); - return true; - - } else if (name == cfg_default_text_size) { - - double sz; - tl::from_string (value, sz); - default_text_size (sz); - return true; - - } else if (name == cfg_text_font) { - - int n; - tl::from_string (value, n); - text_font (n); - return true; - - } else if (name == cfg_full_hier_new_cell) { - - bool flag; - tl::from_string (value, flag); - full_hier_new_cell (flag); - return true; - - } else if (name == cfg_fit_new_cell) { - - bool flag; - tl::from_string (value, flag); - fit_new_cell (flag); - return true; - - } else if (name == cfg_clear_ruler_new_cell) { - - bool flag; - tl::from_string (value, flag); - clear_ruler_new_cell (flag); - return true; - - } else if (name == cfg_abs_units) { - - bool flag; - tl::from_string (value, flag); - absolute_coordinates (flag); - return true; - - } else if (name == cfg_guiding_shape_visible) { - - bool v = false; - tl::from_string (value, v); - guiding_shapes_visible (v); - return true; - - } else if (name == cfg_guiding_shape_line_width) { - - int v = 0; - tl::from_string (value, v); - guiding_shapes_line_width (v); - return true; - - } else if (name == cfg_guiding_shape_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - guiding_shapes_color (color); - return true; - - } else if (name == cfg_guiding_shape_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - guiding_shapes_color (color); - return true; - - } else if (name == cfg_guiding_shape_vertex_size) { - - int v = 0; - tl::from_string (value, v); - guiding_shapes_vertex_size (v); - return true; - - } else if (name == cfg_paste_display_mode) { - - tl::from_string (value, m_paste_display_mode); - return true; - - } else if (name == cfg_mouse_wheel_mode) { - - tl::from_string (value, m_wheel_mode); - return true; - - } else if (name == cfg_pan_distance) { - - double pd; - tl::from_string (value, pd); - pan_distance (pd); - return true; - - } else if (name == cfg_drawing_workers) { - - int workers; - tl::from_string (value, workers); - set_drawing_workers (workers); - return true; - - } else if (name == cfg_drop_small_cells) { - - bool flag; - tl::from_string (value, flag); - drop_small_cells (flag); - return true; - - } else if (name == cfg_drop_small_cells_cond) { - - unsigned int n; - tl::from_string (value, n); - drop_small_cells_cond (drop_small_cells_cond_type (n)); - return true; - - } else if (name == cfg_drop_small_cells_value) { - - unsigned int n; - tl::from_string (value, n); - drop_small_cells_value (n); - return true; - - } else if (name == cfg_array_border_instances) { - - bool f; - tl::from_string (value, f); - draw_array_border_instances (f); - return true; - - } else if (name == cfg_dbu_units) { - - bool flag; - tl::from_string (value, flag); - dbu_coordinates (flag); - return true; - - } else if (name == cfg_stipple_palette) { - - lay::StipplePalette palette = lay::StipplePalette::default_palette (); - - try { - // empty string means: default palette - if (! value.empty ()) { - palette.from_string (value); - } - } catch (...) { - // ignore errors: just reset the palette - palette = lay::StipplePalette::default_palette (); - } - - set_palette (palette); - - // others need this property too .. - return false; - - } else if (name == cfg_line_style_palette) { - - lay::LineStylePalette palette = lay::LineStylePalette::default_palette (); - - try { - // empty string means: default palette - if (! value.empty ()) { - palette.from_string (value); - } - } catch (...) { - // ignore errors: just reset the palette - palette = lay::LineStylePalette::default_palette (); - } - - set_palette (palette); - - // others need this property too .. - return false; - - } else if (name == cfg_color_palette) { - - lay::ColorPalette palette = lay::ColorPalette::default_palette (); - - try { - // empty string means: default palette - if (! value.empty ()) { - palette.from_string (value); - } - } catch (...) { - // ignore errors: just reset the palette - palette = lay::ColorPalette::default_palette (); - } - - set_palette (palette); - - // others need this property too .. - return false; - - } else if (name == cfg_sel_inside_pcells_mode) { - - bool flag; - tl::from_string (value, flag); - - if (m_sel_inside_pcells != flag) { - m_sel_inside_pcells = flag; - clear_selection (); - } - - return true; - - } else if (name == cfg_sel_transient_mode) { - - bool flag; - tl::from_string (value, flag); - m_transient_selection_mode = flag; - - if (! m_transient_selection_mode) { - clear_transient_selection (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_color) { - - lay::Color color; - lay::ColorConverter ().from_string (value, color); - - // Change the color - if (lay::test_and_set (m_marker_color, color)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_line_width) { - - int lw = 0; - tl::from_string (value, lw); - - // Change the line width - if (lay::test_and_set (m_marker_line_width, lw)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_dither_pattern) { - - int dp = 0; - tl::from_string (value, dp); - - // Change the vertex_size - if (lay::test_and_set (m_marker_dither_pattern, dp)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_line_style) { - - int dp = 0; - tl::from_string (value, dp); - - // Change the vertex_size - if (lay::test_and_set (m_marker_line_style, dp)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_vertex_size) { - - int vs = 0; - tl::from_string (value, vs); - - // Change the vertex_size - if (lay::test_and_set (m_marker_vertex_size, vs)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_halo) { - - bool halo = 0; - tl::from_string (value, halo); - - // Change the vertex_size - if (lay::test_and_set (m_marker_halo, halo)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - } else { return false; } @@ -1678,40 +572,6 @@ LayoutView::config_finalize () dm_setup_editor_option_pages (); } -void -LayoutView::enable_edits (bool enable) -{ - // enable or disable these services: - if (mp_selection_service) { - mp_selection_service->enable (enable); - } - if (mp_move_service) { - mp_move_service->enable (enable); - } - - // enable or disable the services that implement "lay::ViewService" - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - lay::ViewService *svc = (*p)->view_service_interface (); - if (svc) { - svc->enable (enable); - } - } - - bool is_enabled = edits_enabled (); - - if (enable) { - if (m_disabled_edits > 0) { - --m_disabled_edits; - } - } else { - ++m_disabled_edits; - } - - if (edits_enabled () != is_enabled) { - emit edits_enabled_changed (); - } -} - bool LayoutView::set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &lp) { @@ -1797,2201 +657,6 @@ LayoutView::set_selected_layers (const std::vectorline_styles () != styles) { - - if (transacting ()) { - manager ()->queue (this, new OpSetLineStyles (mp_canvas->line_styles (), styles)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - mp_canvas->set_line_styles (styles); - - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_line_styles (styles); - } - - layer_list_changed_event (1); - - } -} - -void -LayoutView::set_dither_pattern (const lay::DitherPattern &pattern) -{ - if (mp_canvas->dither_pattern () != pattern) { - - if (transacting ()) { - manager ()->queue (this, new OpSetDitherPattern (mp_canvas->dither_pattern (), pattern)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - mp_canvas->set_dither_pattern (pattern); - - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_dither_pattern (pattern); - } - - layer_list_changed_event (1); - - } -} - -const LayerPropertiesList & -LayoutView::get_properties (unsigned int index) const -{ - if (index >= layer_lists ()) { - static lay::LayerPropertiesList empty; - return empty; - } else { - return *m_layer_properties_lists [index]; - } -} - -void -LayoutView::set_current_layer_list (unsigned int index) -{ - if (index != m_current_layer_list && index < layer_lists ()) { - m_current_layer_list = index; - current_layer_list_changed_event (index); - redraw (); - } -} - -void -LayoutView::insert_layer_list (unsigned index, const LayerPropertiesList &props) -{ - if (index > layer_lists ()) { - return; - } - - if (transacting ()) { - manager ()->queue (this, new OpInsertLayerList (index, props)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); - m_layer_properties_lists [index]->attach_view (this, index); - merge_dither_pattern (*m_layer_properties_lists [index]); - - m_current_layer_list = index; - current_layer_list_changed_event (index); - - layer_list_inserted_event (index); - - redraw (); - - dm_prop_changed (); -} - -void -LayoutView::delete_layer_list (unsigned index) -{ - if (index >= layer_lists ()) { - return; - } - - if (transacting ()) { - manager ()->queue (this, new OpDeleteLayerList (index, *m_layer_properties_lists [index])); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - delete m_layer_properties_lists [index]; - m_layer_properties_lists.erase (m_layer_properties_lists.begin () + index); - - if (m_current_layer_list > index) { - - --m_current_layer_list; - current_layer_list_changed_event (m_current_layer_list); - - // don't tell the other observers because effectively nothing has changed. - - } else if (m_current_layer_list == index) { - - if (m_current_layer_list > 0) { - --m_current_layer_list; - } - - current_layer_list_changed_event (m_current_layer_list); - - // the current list has been deleted. - layer_list_changed_event (3); - - redraw (); - - } - - layer_list_deleted_event (index); - dm_prop_changed (); -} - -void -LayoutView::rename_properties (unsigned int index, const std::string &new_name) -{ - if (index >= layer_lists ()) { - return; - } - - if (transacting ()) { - manager ()->queue (this, new OpRenameProps (index, m_layer_properties_lists [index]->name (), new_name)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - m_layer_properties_lists [index]->set_name (new_name); - - layer_list_changed_event (4); -} - -void -LayoutView::merge_dither_pattern (lay::LayerPropertiesList &props) -{ - { - lay::DitherPattern dp (dither_pattern ()); - - std::map index_map; - dp.merge (props.dither_pattern (), index_map); - - // remap the dither pattern index - for (lay::LayerPropertiesIterator l = props.begin_recursive (); l != props.end_recursive (); ++l) { - int dpi = l->dither_pattern (false /*local*/); - std::map ::iterator m = index_map.find ((unsigned int) dpi); - if (m != index_map.end ()) { - l->set_dither_pattern (int (m->second)); - } - } - - // install the new custom pattern table - if (mp_canvas->dither_pattern () != dp) { - mp_canvas->set_dither_pattern (dp); - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_dither_pattern (dp); - } - } - } - - { - lay::LineStyles ls (line_styles ()); - - std::map index_map; - ls.merge (props.line_styles (), index_map); - - // remap the dither pattern index - for (lay::LayerPropertiesIterator l = props.begin_recursive (); l != props.end_recursive (); ++l) { - int lsi = l->line_style (false /*local*/); - std::map ::iterator m = index_map.find ((unsigned int) lsi); - if (m != index_map.end ()) { - l->set_line_style (int (m->second)); - } - } - - // install the new custom pattern table - if (mp_canvas->line_styles () != ls) { - mp_canvas->set_line_styles (ls); - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_line_styles (ls); - } - } - } -} - -void -LayoutView::set_properties (unsigned int index, const LayerPropertiesList &props) -{ - // If index is not a valid tab index, don't do anything except for the case of - // index 0 in which the first entry is created (this can happen as a result of - // delete_properties). - if (index >= layer_lists ()) { - if (index > 0) { - return; - } else { - m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); - } - } - - // HINT: this method is quite frequently used in an imperative way. - // Since it has some desired side effects such as forcing a recomputation of the internals, - // it should be executed in any case, even if props == get_properties (). - - if (transacting ()) { - manager ()->queue (this, new OpSetAllProps (index, get_properties (), props)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - *m_layer_properties_lists [index] = props; - m_layer_properties_lists [index]->attach_view (this, index); - - merge_dither_pattern (*m_layer_properties_lists [index]); - - if (index == current_layer_list ()) { - - layer_list_changed_event (3); - - redraw (); - - dm_prop_changed (); - - } -} - -void -LayoutView::expand_properties () -{ - expand_properties (std::map (), false); -} - -void -LayoutView::expand_properties (unsigned int index) -{ - expand_properties (index, std::map (), false); -} - -void -LayoutView::expand_properties (const std::map &map_cv_index, bool add_default) -{ - for (unsigned int i = 0; i < cellviews (); ++i) { - expand_properties (i, map_cv_index, add_default); - } -} - -void -LayoutView::expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default) -{ - if (index < m_layer_properties_lists.size ()) { - m_layer_properties_lists [index]->expand (map_cv_index, add_default); - } -} - -void -LayoutView::replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &node) -{ - if (index >= layer_lists ()) { - return; - } - - // if the source specification changed, a redraw is required - if (*iter != node) { - - if (transacting ()) { - manager ()->queue (this, new OpSetLayerPropsNode (index, (unsigned int) iter.uint (), *iter, node)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); - *non_const_iter = node; - non_const_iter->attach_view (this, index); - - if (index == current_layer_list ()) { - - layer_list_changed_event (2); - - // TODO: check, if redraw is actually necessary (this is complex!) - redraw (); - - dm_prop_changed (); - - } - } -} - -void -LayoutView::set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props) -{ - if (index >= layer_lists ()) { - return; - } - - // if the source specification changed, a redraw is required - const LayerProperties &l = *iter; - if (l != props) { - - if (transacting ()) { - manager ()->queue (this, new OpSetLayerProps (index, (unsigned int) iter.uint (), l, props)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - bool need_redraw = (l.source (false /*local*/) != props.source (false /*local*/) || l.xfill (false /*local*/) != props.xfill (false /*local*/)); - bool visible_changed = (l.visible (true /*real*/) != props.visible (true /*real*/)); - - LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); - *non_const_iter = props; - - if (index == current_layer_list ()) { - - layer_list_changed_event (1); - - if (need_redraw) { - redraw (); - } - - if (visible_changed) { - m_visibility_changed = true; - } - - // perform the callbacks asynchronously to collect the necessary calls instead - // of executing them immediately. - dm_prop_changed (); - - } - } -} - -const LayerPropertiesNode & -LayoutView::insert_layer (unsigned int index, const LayerPropertiesConstIterator &before, const LayerPropertiesNode &node) -{ - tl_assert (index < layer_lists ()); - - if (transacting ()) { - manager ()->queue (this, new OpInsertLayerProps (index, (unsigned int) before.uint (), node)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - const LayerPropertiesNode &ret = m_layer_properties_lists [index]->insert (LayerPropertiesIterator (*m_layer_properties_lists [index], before.uint ()), node); - - // signal to the observers that something has changed - if (index == current_layer_list ()) { - layer_list_changed_event (2); - redraw (); - dm_prop_changed (); - } - - return ret; -} - -void -LayoutView::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter) -{ - if (index >= layer_lists ()) { - return; - } - - lay::LayerPropertiesNode orig = *iter; - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - // delete the element - m_layer_properties_lists [index]->erase (LayerPropertiesIterator (*m_layer_properties_lists [index], iter.uint ())); - - if (transacting ()) { - manager ()->queue (this, new OpDeleteLayerProps (index, (unsigned int) iter.uint (), orig)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - // signal to the observers that something has changed - if (index == current_layer_list ()) { - layer_list_changed_event (2); - redraw (); - dm_prop_changed (); - } - - // invalidate the iterator so it can be used to refer to the next element - iter.invalidate (); -} - -void -LayoutView::signal_selection_changed () -{ - if (selection_size () > 1) { - message (tl::sprintf (tl::to_string (QObject::tr ("selected: %ld objects")), selection_size ())); - } - - lay::Editables::signal_selection_changed (); -} - -void -LayoutView::save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups) -{ - tl_assert (index < cellviews ()); - - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Saving"))); - cellview (index)->save_as (filename, om, options, update, keep_backups); - - cellview_changed (index); -} - -void -LayoutView::redo (db::Op *op) -{ - tl_assert (! transacting ()); - - OpSetLayerProps *sop = dynamic_cast (op); - if (sop) { - if (sop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (sop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [sop->m_list_index], sop->m_index), sop->m_new); - } - return; - } - - OpSetLayerPropsNode *snop = dynamic_cast (op); - if (snop) { - if (snop->m_list_index < m_layer_properties_lists.size ()) { - replace_layer_node (snop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [snop->m_list_index], snop->m_index), snop->m_new); - } - return; - } - - OpInsertLayerList *ilop = dynamic_cast (op); - if (ilop) { - if (ilop->m_list_index <= m_layer_properties_lists.size ()) { - insert_layer_list (ilop->m_list_index, ilop->m_new); - } - return; - } - - OpDeleteLayerList *dlop = dynamic_cast (op); - if (dlop) { - if (dlop->m_list_index < m_layer_properties_lists.size ()) { - delete_layer_list (dlop->m_list_index); - } - return; - } - - OpSetAllProps *saop = dynamic_cast (op); - if (saop) { - if (saop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (saop->m_list_index, saop->m_new); - } - return; - } - - OpRenameProps *rnop = dynamic_cast (op); - if (rnop) { - if (rnop->m_list_index < m_layer_properties_lists.size ()) { - rename_properties (rnop->m_list_index, rnop->m_new); - } - return; - } - - OpLayerList *lop = dynamic_cast (op); - if (lop) { - if (lop->m_list_index < m_layer_properties_lists.size ()) { - if (lop->m_mode == OpLayerList::Insert) { - insert_layer (lop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [lop->m_list_index], lop->m_index), lop->m_node); - } else { - lay::LayerPropertiesConstIterator iter (*m_layer_properties_lists [lop->m_list_index], lop->m_index); - delete_layer (lop->m_list_index, iter); - } - } - return; - } - - OpSetDitherPattern *stpop = dynamic_cast (op); - if (stpop) { - set_dither_pattern (stpop->m_new); - return; - } - - OpHideShowCell *hscop = dynamic_cast (op); - if (hscop) { - if (hscop->m_show) { - show_cell (hscop->m_cell_index, hscop->m_cellview_index); - } else { - hide_cell (hscop->m_cell_index, hscop->m_cellview_index); - } - return; - } - - db::Object::redo (op); -} - -void -LayoutView::undo (db::Op *op) -{ - tl_assert (! transacting ()); - - OpSetLayerProps *sop = dynamic_cast (op); - if (sop) { - if (sop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (sop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [sop->m_list_index], sop->m_index), sop->m_old); - } - return; - } - - OpSetLayerPropsNode *snop = dynamic_cast (op); - if (snop) { - if (snop->m_list_index < m_layer_properties_lists.size ()) { - replace_layer_node (snop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [snop->m_list_index], snop->m_index), snop->m_old); - } - return; - } - - OpInsertLayerList *ilop = dynamic_cast (op); - if (ilop) { - if (ilop->m_list_index <= m_layer_properties_lists.size ()) { - delete_layer_list (ilop->m_list_index); - } - return; - } - - OpDeleteLayerList *dlop = dynamic_cast (op); - if (dlop) { - if (dlop->m_list_index < m_layer_properties_lists.size ()) { - insert_layer_list (dlop->m_list_index, dlop->m_old); - } - return; - } - - OpSetAllProps *saop = dynamic_cast (op); - if (saop) { - if (saop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (saop->m_list_index, saop->m_old); - } - return; - } - - OpRenameProps *rnop = dynamic_cast (op); - if (rnop) { - if (rnop->m_list_index < m_layer_properties_lists.size ()) { - rename_properties (rnop->m_list_index, rnop->m_old); - } - return; - } - - OpLayerList *lop = dynamic_cast (op); - if (lop) { - if (lop->m_list_index < m_layer_properties_lists.size ()) { - if (lop->m_mode == OpLayerList::Insert) { - lay::LayerPropertiesConstIterator iter (*m_layer_properties_lists [lop->m_list_index], lop->m_index); - delete_layer (lop->m_list_index, iter); - } else { - insert_layer (lop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [lop->m_list_index], lop->m_index), lop->m_node); - } - } - return; - } - - OpHideShowCell *hscop = dynamic_cast (op); - if (hscop) { - - if (hscop->m_show) { - hide_cell (hscop->m_cell_index, hscop->m_cellview_index); - } else { - show_cell (hscop->m_cell_index, hscop->m_cellview_index); - } - - return; - - } - - OpSetDitherPattern *stpop = dynamic_cast (op); - if (stpop) { - set_dither_pattern (stpop->m_old); - return; - } - - db::Object::undo (op); -} - -void -LayoutView::signal_hier_changed () -{ - // schedule a redraw request for all layers - redraw (); - // forward this event to our observers - hier_changed_event (); -} - -void -LayoutView::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index) -{ - if (layer_index == std::numeric_limits::max ()) { - - // redraw all - signal_bboxes_changed (); - - } else { - - // redraw only the layers required for redrawing - for (std::vector::const_iterator l = mp_canvas->get_redraw_layers ().begin (); l != mp_canvas->get_redraw_layers ().end (); ++l) { - if (l->cellview_index == int (cv_index) && l->layer_index == int (layer_index)) { - redraw_layer ((unsigned int) (l - mp_canvas->get_redraw_layers ().begin ())); - } - } - - // forward this event to our observers - geom_changed_event (); - - } -} - -void -LayoutView::signal_bboxes_changed () -{ - // schedule a redraw request for all layers - redraw (); - - // forward this event to our observers - geom_changed_event (); -} - -void -LayoutView::signal_cell_name_changed () -{ - cell_visibility_changed_event (); // HINT: that is not what actually is intended, but it serves the function ... - redraw (); // needs redraw -} - -void -LayoutView::signal_layer_properties_changed () -{ - // recompute the source - // TODO: this is a side effect of this method - provide a special method for this purpose - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (this, i); - } - - // schedule a redraw request - since the layer views might not have changed, this is necessary - redraw (); -} - -void -LayoutView::signal_prop_ids_changed () -{ - // inform the layer list observers that they need to recompute the property selectors - layer_list_changed_event (1); - - // recompute the source - // TODO: this is a side effect of this method - provide a special method for this purpose - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (this, i); - } -} - -void -LayoutView::signal_plugin_enabled_changed () -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->editable_interface ()) { - enable ((*p)->editable_interface (), (*p)->plugin_declaration ()->editable_enabled ()); - } - } -} - -void -LayoutView::signal_annotations_changed () -{ - // schedule a redraw request for the annotation shapes - redraw_deco_layer (); - // forward this event to our observers - annotations_changed_event (); -} - -void -LayoutView::finish_cellviews_changed () -{ - update_event_handlers (); - - cellviews_changed_event (); - - redraw (); -} - -std::list::iterator -LayoutView::cellview_iter (int cv_index) -{ - std::list::iterator i = m_cellviews.begin (); - while (cv_index > 0 && i != m_cellviews.end ()) { - ++i; - --cv_index; - } - tl_assert (i != m_cellviews.end ()); - return i; -} - -std::list::const_iterator -LayoutView::cellview_iter (int cv_index) const -{ - std::list::const_iterator i = m_cellviews.begin (); - while (cv_index > 0 && i != m_cellviews.end ()) { - ++i; - --cv_index; - } - tl_assert (i != m_cellviews.end ()); - return i; -} - -void -LayoutView::erase_cellview (unsigned int index) -{ - if (index >= m_cellviews.size ()) { - return; - } - - cancel_esc (); - - // issue to event that signals a change in the cellviews - cellviews_about_to_change_event (); - - // no undo available - clear all transactions - if (manager ()) { - manager ()->clear (); - } - - if (mp_control_panel) { - mp_control_panel->begin_updates (); - } - - m_cellviews.erase (cellview_iter (int (index))); - - if (m_hidden_cells.size () > index) { - m_hidden_cells.erase (m_hidden_cells.begin () + index); - } - - for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { - - // remove all references to the cellview - m_layer_properties_lists [lindex]->remove_cv_references (index); - - // rename the ones that got shifted. - lay::LayerPropertiesConstIterator l = begin_layers (lindex); - while (! l.at_end ()) { - lay::ParsedLayerSource source (l->source (false)); - if (source.cv_index () >= int (index)) { - lay::LayerProperties new_props (*l); - source.cv_index (source.cv_index () == int (index) ? -1 : source.cv_index () - 1); - new_props.set_source (source); - LayerPropertiesIterator non_const_iter (*m_layer_properties_lists [lindex], l.uint ()); - *non_const_iter = new_props; - } - ++l; - } - - } - - // clear the history - m_display_states.clear (); - m_display_state_ptr = 0; - - // signal to the observers that something has changed - layer_list_changed_event (3); - - finish_cellviews_changed (); - - update_content (); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::clear_cellviews () -{ - // issue to event that signals a change in the cellviews - cellviews_about_to_change_event (); - - // no undo available - clear all transactions - if (manager ()) { - manager ()->clear (); - } - - // clear the layer lists and cellviews - while (layer_lists () > 0) { - delete_layer_list (layer_lists () - 1); - } - set_properties (lay::LayerPropertiesList ()); - m_cellviews.clear (); - - // clear the history, store path and zoom box - m_display_states.clear (); - m_display_state_ptr = 0; - - finish_cellviews_changed (); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -const CellView & -LayoutView::cellview (unsigned int index) const -{ - static const CellView empty; - if (index >= m_cellviews.size ()) { - return empty; - } else { - return *cellview_iter (int (index)); - } -} - -CellViewRef -LayoutView::cellview_ref (unsigned int index) -{ - if (index >= m_cellviews.size ()) { - return CellViewRef (); - } else { - return CellViewRef (cellview_iter (index).operator-> (), this); - } -} - -int -LayoutView::index_of_cellview (const lay::CellView *cv) const -{ - int index = 0; - for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end (); ++i, ++index) { - if (cv == i.operator-> ()) { - return index; - } - } - return -1; -} - -void -LayoutView::set_layout (const lay::CellView &cv, unsigned int cvindex) -{ - // issue to event that signals a change in the cellviews - cellviews_about_to_change_event (); - - // no undo available - clear all transactions - if (manager ()) { - manager ()->clear (); - } - - // signal the change of layer properties to the observer - layer_list_changed_event (3); - - // create a new cellview if required - while (m_cellviews.size () <= cvindex) { - m_cellviews.push_back (lay::CellView ()); - } - - // set the handle reference and clear all cell related stuff - *cellview_iter (cvindex) = cv; - - // clear the history, store path and zoom box - clear_states (); - - finish_cellviews_changed (); - - // since the hierarchy panel may hold cellviews, we explicitly request an initialization - // of the tree. This will release such references. This way, set_layout guarantees that - // the layouts are released as far as possible. This is important for reload () for example. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (cvindex); - } - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::signal_apply_technology (lay::LayoutHandle *layout_handle) -{ - // find the cellview which issued the event - for (unsigned int i = 0; i < cellviews (); ++i) { - - if (cellview (i).handle () == layout_handle) { - - cancel_esc (); - - std::string lyp_file; - const db::Technology *tech = db::Technologies::instance ()->technology_by_name (cellview (i)->tech_name ()); - if (tech && ! tech->eff_layer_properties_file ().empty ()) { - lyp_file = tech->eff_layer_properties_file (); - } - - if (! lyp_file.empty ()) { - - // interpolate the layout properties file name - tl::Eval expr; - expr.set_var ("layoutfile", cellview (i)->filename ()); - lyp_file = expr.interpolate (lyp_file); - - // remove all references to the cellview in the layer properties - for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { - m_layer_properties_lists [lindex]->remove_cv_references (i); - } - - // if a layer properties file is set, create the layer properties now - create_initial_layer_props (i, lyp_file, tech->add_other_layers ()); - - } - - } - - } -} - -void -LayoutView::load_layer_props (const std::string &fn) -{ - do_load_layer_props (fn, false, -1, false); -} - -void -LayoutView::load_layer_props (const std::string &fn, bool add_default) -{ - do_load_layer_props (fn, false, -1, add_default); -} - -void -LayoutView::load_layer_props (const std::string &fn, int cv_index, bool add_default) -{ - do_load_layer_props (fn, true, cv_index, add_default); -} - -void -LayoutView::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default) -{ - std::vector props; - bool single_list = false; - - // read the layer properties from the file - try { - tl::XMLFileSource in (fn); - props.push_back (lay::LayerPropertiesList ()); - props.back ().load (in); - single_list = true; - } catch (...) { - props.clear (); - tl::XMLFileSource in (fn); - lay::LayerPropertiesList::load (in, props); - } - - // expand the wildcards and map to the target cv. - for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { - std::map cv_map; - if (map_cv) { - cv_map.insert (std::make_pair (-1, cv_index)); - } - p->attach_view (this, p - props.begin ()); - p->expand (cv_map, add_default); - } - - transaction (tl::to_string (QObject::tr ("Load layer properties"))); - - if (single_list) { - - // a single list will only replace the current tab - if (map_cv && cv_index >= 0) { - lay::LayerPropertiesList new_props (get_properties ()); - new_props.remove_cv_references (cv_index); - new_props.append (props [0]); - set_properties (new_props); - } else { - set_properties (props [0]); - } - - } else { - - for (unsigned int i = 0; i < props.size (); ++i) { - - if (i < layer_lists ()) { - - if (map_cv && cv_index >= 0) { - lay::LayerPropertiesList new_props (get_properties (i)); - new_props.remove_cv_references (cv_index); - new_props.append (props [i]); - set_properties (i, new_props); - } else { - set_properties (i, props [i]); - } - - } else { - insert_layer_list (i, props [i]); - } - - } - - while (layer_lists () > props.size () && layer_lists () > 1) { - delete_layer_list (layer_lists () - 1); - } - - } - - commit (); - - update_content (); - - tl::log << "Loaded layer properties from " << fn; -} - -void -LayoutView::save_layer_props (const std::string &fn) -{ - tl::OutputStream os (fn, tl::OutputStream::OM_Plain); - - if (layer_lists () == 1) { - - // a single list is written in the traditional format - get_properties ().save (os); - - } else { - - // multiple tabs are written in the multi-tab format - std::vector props; - for (unsigned int i = 0; i < layer_lists (); ++i) { - props.push_back (get_properties (i)); - } - - lay::LayerPropertiesList::save (os, props); - - } - - tl::log << "Saved layer properties to " << fn; -} - -void -LayoutView::add_new_layers (const std::vector &layer_ids, int cv_index) -{ - if (cv_index >= 0 && cv_index < int (cellviews ())) { - - const lay::CellView &cv = cellview (cv_index); - - // create the layers and do a basic recoloring .. - lay::LayerPropertiesList new_props (get_properties ()); - - bool was_empty = new_props.begin_const_recursive ().at_end (); - - // don't create new layers for those, for which there are layers already: compute a - // set of layers already present - std::set present_layers; - for (LayerPropertiesConstIterator lay_iter = begin_layers (); ! lay_iter.at_end (); ++lay_iter) { - if (! lay_iter->has_children () && lay_iter->cellview_index () == cv_index) { - present_layers.insert (lay_iter->source (true /*real*/).layer_props ()); - } - } - - // determine layers which are new and need to be created - std::vector new_layers; - for (std::vector ::const_iterator l = layer_ids.begin (); l != layer_ids.end (); ++l) { - const db::LayerProperties &lp = cv->layout ().get_properties (*l); - if (present_layers.find (lp) == present_layers.end ()) { - new_layers.push_back (lp); - } - } - - // create them in the sorting order provided by db::LayerProperties - std::sort (new_layers.begin (), new_layers.end (), db::LPLogicalLessFunc ()); - - // and actually create them - for (std::vector ::const_iterator l = new_layers.begin (); l != new_layers.end (); ++l) { - lay::LayerProperties p; - p.set_source (lay::ParsedLayerSource (*l, cv_index)); - init_layer_properties (p, new_props); - new_props.push_back (p); - } - - set_properties (new_props); - - if (was_empty) { - set_current_layer (new_props.begin_const_recursive ()); - } - - } -} - -void -LayoutView::init_layer_properties (LayerProperties &p) const -{ - init_layer_properties (p, get_properties ()); -} - -void -LayoutView::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const -{ - lay::color_t c = 0; - if (m_palette.luminous_colors () > 0) { - c = m_palette.luminous_color_by_index (p.source (true /*real*/).color_index ()); - } - - p.set_dither_pattern (m_stipple_palette.standard_stipple_by_index (lp_list.end_const () - lp_list.begin_const ())); - p.set_fill_color (c); - p.set_frame_color (c); - p.set_fill_brightness (0); - p.set_frame_brightness (0); - p.set_frame_brightness (0); - p.set_transparent (false); // :TODO: make variable - p.set_visible (true); - p.set_width (1); - p.set_animation (0); - p.set_marked (false); -} - -QImage -LayoutView::get_screenshot () -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - return mp_canvas->screenshot (); -} - -void -LayoutView::save_screenshot (const std::string &fn) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } - } - - db::DBox b (box ()); - std::string desc; - desc += tl::micron_to_string (b.left ()) + "," + tl::micron_to_string (b.bottom ()); - desc += "/"; - desc += tl::micron_to_string (b.right ()) + "," + tl::micron_to_string (b.top ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (desc)); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->screenshot ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); - } - - tl::log << "Saved screen shot to " << fn; -} - -QImage -LayoutView::get_image (unsigned int width, unsigned int height) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - return mp_canvas->image (width, height); -} - -QImage -LayoutView::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome); -} - -void -LayoutView::save_image (const std::string &fn, unsigned int width, unsigned int height) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } - } - - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->image (width, height))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); - } - - tl::log << "Saved screen shot to " << fn; -} - -void -LayoutView::save_image_with_options (const std::string &fn, - unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } - } - - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); - } - - tl::log << "Saved screen shot to " << fn; -} - -void -LayoutView::reload_layout (unsigned int cv_index) -{ - stop (); - cancel_esc (); - - // save the current view state - lay::DisplayState state; - save_view (state); - - // this is the cellview at the given index (use a copy since the original is overwritten) - CellView cvorg = cellview (cv_index); - - // obtain the original filename - std::string filename = cvorg->filename (); - std::string technology = cvorg->tech_name (); - std::string name = cvorg->name (); - - // recreate hidden cells by doing a name referencing - std::vector hidden_cells; - if (m_hidden_cells.size () > cv_index) { - hidden_cells.reserve (m_hidden_cells [cv_index].size ()); - for (std::set ::const_iterator ci = m_hidden_cells [cv_index].begin (); ci != m_hidden_cells [cv_index].end (); ++ci) { - hidden_cells.push_back (std::string (cvorg->layout ().cell_name (*ci))); - } - } - - // Set up a list of present layers - std::set present_layers; - for (LayerPropertiesConstIterator lay_iter = begin_layers (); ! lay_iter.at_end (); ++lay_iter) { - if (! lay_iter->has_children ()) { - present_layers.insert (lay_iter->source (true /*real*/).layer_props ()); - } - } - - std::map org_layers; - - for (unsigned int i = 0; i < cvorg->layout ().layers (); ++i) { - if (cvorg->layout ().is_valid_layer (i)) { - const db::LayerProperties &p = cvorg->layout ().get_properties (i); - if (! p.log_equal (db::LayerProperties ())) { - org_layers.insert (std::make_pair (i, p)); - } - } - } - - lay::LayoutHandle *handle; - - // reset the layout: create a dummy handle and install this in between - // this will clear the original layout if not further referenced. - // Since the dummy layout will act as a placeholder if something goes wrong - // when reading the file, it must have the layers created as well - lay::CellView cv_empty; - - handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); - handle->set_tech_name (technology); - cv_empty.set (handle); - - for (std::map ::const_iterator ol = org_layers.begin (); ol != org_layers.end (); ++ol) { - cv_empty->layout ().insert_layer (ol->first, ol->second); - } - cv_empty->rename (name, true); - - set_layout (cv_empty, cv_index); - - // create a new handle - lay::CellView cv; - handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); - cv.set (handle); - - try { - - // re-create the layers required - for (std::map ::const_iterator ol = org_layers.begin (); ol != org_layers.end (); ++ol) { - cv->layout ().insert_layer (ol->first, ol->second); - } - - { - tl::log << tl::to_string (QObject::tr ("Loading file: ")) << filename; - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - - // Load with the previous options again. - db::LoadLayoutOptions options (cvorg->load_options ()); - cv->load (cvorg->load_options (), technology); - } - - // sort the layout explicitly here. Otherwise it would be done - // implicitly at some other time. This may throw an exception - // if the operation was cancelled. - { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Sorting"))); - cv->layout ().update (); - } - - // print the memory statistics now. - if (tl::verbosity () >= 31) { - db::MemStatisticsCollector m (false); - cv->layout ().mem_stat (&m, db::MemStatistics::LayoutInfo, 0); - m.print (); - } - - // this is required to release every reference to the cv_empty layout - cv_empty = lay::CellView (); - - // install the new layout - cv->rename (name, true); - set_layout (cv, cv_index); - - } catch (...) { - update_content (); - throw; - } - - // recreate the hidden cell indices from the names - if (m_hidden_cells.size () > cv_index) { - m_hidden_cells [cv_index].clear (); - for (std::vector ::const_iterator cn = hidden_cells.begin (); cn != hidden_cells.end (); ++cn) { - std::pair cid = cv->layout ().cell_by_name (cn->c_str ()); - if (cid.first) { - m_hidden_cells [cv_index].insert (cid.second); - } - } - } - - // Determine which layers to create as new layers. New layer need to be created - // if these have not been present in the original layout and there are no layer views - // referring to them. - std::vector new_layers; - for (unsigned int i = 0; i < cv->layout ().layers (); ++i) { - if (cv->layout ().is_valid_layer (i)) { - std::map ::iterator ol = org_layers.find (i); - if (ol == org_layers.end () && present_layers.find (cv->layout ().get_properties (i)) == present_layers.end ()) { - new_layers.push_back (cv->layout ().get_properties (i)); - } - } - } - - std::sort (new_layers.begin (), new_layers.end (), db::LPLogicalLessFunc ()); - - // create the layers and do a basic recoloring .. - lay::LayerPropertiesList new_props (get_properties ()); - - for (std::vector ::const_iterator l = new_layers.begin (); l != new_layers.end (); ++l) { - lay::LayerProperties p; - p.set_source (lay::ParsedLayerSource (*l, int (cv_index))); - init_layer_properties (p, new_props); - new_props.push_back (p); - } - - set_properties (new_props); - - goto_view (state); - -} - -unsigned int -LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers) -{ - unsigned int cv_index = 0; - - try { - - m_active_cellview_changed_event_enabled = false; - - stop_redraw (); - - bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); - - lay::CellView cv; - - if (! add_cellview) { - clear_cellviews (); - } - - cv.set (layout_handle); - - cv->layout ().update (); - - // select the cell with the largest area as the first top cell - db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); - for (db::Layout::top_down_const_iterator t = cv->layout ().begin_top_down (); t != cv->layout ().end_top_cells (); ++t) { - if (cv->layout ().cell (*t).bbox ().area () > cv->layout ().cell (*top).bbox ().area ()) { - top = t; - } - } - - if (top != cv->layout ().end_top_down ()) { - std::vector p; - p.push_back (*top); - cv.set_unspecific_path (p); - } - - cv_index = cellviews (); - set_layout (cv, cv_index); - - if (top != cv->layout ().end_top_cells ()) { - std::vector p; - p.push_back (*top); - select_cell (p, cv_index); - } else { - // even if there is no cell, select the cellview item - // to support applications with an active cellview (that is however invalid) - set_active_cellview_index (cv_index); - } - - if (initialize_layers) { - - bool add_other_layers = m_add_other_layers; - - // Use the "layer-properties-file" meta info from the handle to get the layer properties file. - // If no such file is present, use the default file or the technology specific file. - std::string lyp_file = m_def_lyp_file; - const db::Technology *tech = db::Technologies::instance ()->technology_by_name (layout_handle->tech_name ()); - if (tech && ! tech->eff_layer_properties_file ().empty ()) { - lyp_file = tech->eff_layer_properties_file (); - add_other_layers = tech->add_other_layers (); - } - - // Give the layout object a chance to specify a certain layer property file - for (db::Layout::meta_info_iterator meta = cv->layout ().begin_meta (); meta != cv->layout ().end_meta (); ++meta) { - if (meta->name == "layer-properties-file") { - lyp_file = meta->value; - } - if (meta->name == "layer-properties-add-other-layers") { - try { - tl::from_string (meta->value, add_other_layers); - } catch (...) { - } - } - } - - // interpolate the layout properties file name - tl::Eval expr; - expr.set_var ("layoutfile", layout_handle->filename ()); - lyp_file = expr.interpolate (lyp_file); - - // create the initial layer properties - create_initial_layer_props (cv_index, lyp_file, add_other_layers); - - } - - // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } - } - - // signal to any observers - file_open_event (); - - if (cv->layout ().begin_top_down () != cv->layout ().end_top_down ()) { - - // do a fit and update layer lists etc. - zoom_fit (); - if (set_max_hier) { - max_hier (); - } - update_content (); - - } else { - // even if there is no cell, select the cellview item - // to support applications with an active cellview (that is however invalid) - set_active_cellview_index (cv_index); - } - - m_active_cellview_changed_event_enabled = true; - - } catch (...) { - - update_content (); - - m_active_cellview_changed_event_enabled = true; - throw; - - } - - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - - return cv_index; -} - -unsigned int -LayoutView::create_layout (const std::string &technology, bool add_cellview, bool initialize_layers) -{ - const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); - - db::Layout *layout = new db::Layout (manager ()); - if (tech) { - layout->dbu (tech->dbu ()); - } - - lay::LayoutHandle *handle = new lay::LayoutHandle (layout, ""); - handle->set_tech_name (technology); - return add_layout (handle, add_cellview, initialize_layers); -} - -unsigned int -LayoutView::load_layout (const std::string &filename, const std::string &technology, bool add_cellview) -{ - return load_layout (filename, db::LoadLayoutOptions (), technology, add_cellview); -} - -unsigned int -LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview) -{ - stop (); - - bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); - - const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); - - // create a new layout handle - lay::CellView cv; - lay::LayoutHandle *handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); - cv.set (handle); - - unsigned int cv_index; - db::LayerMap lmap; - - try { - - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - - // load the file - { - tl::log << tl::to_string (QObject::tr ("Loading file: ")) << filename << tl::to_string (QObject::tr (" with technology: ")) << technology; - lmap = cv->load (options, technology); - } - - // sort the layout explicitly here. Otherwise it would be done - // implicitly at some other time. This may throw an exception - // if the operation was cancelled. - { - cv->layout ().update (); - } - - // print the memory statistics now. - if (tl::verbosity () >= 31) { - db::MemStatisticsCollector m (false); - cv->layout ().mem_stat (&m, db::MemStatistics::LayoutInfo, 0); - m.print (); - } - - // clear the cellviews if required - if (! add_cellview) { - clear_cellviews (); - } - - // set the new layout as the layout for the last cellview - cv_index = cellviews (); - set_layout (cv, cv_index); - - } catch (...) { - - update_content (); - throw; - - } - - try { - - m_active_cellview_changed_event_enabled = false; - - // select the cell with the largest area as the first top cell - db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); - for (db::Layout::top_down_const_iterator t = cv->layout ().begin_top_down (); t != cv->layout ().end_top_cells (); ++t) { - if (cv->layout ().cell (*t).bbox ().area () > cv->layout ().cell (*top).bbox ().area ()) { - top = t; - } - } - if (top != cv->layout ().end_top_cells ()) { - std::vector p; - p.push_back (*top); - select_cell (p, cv_index); - } else { - // even if there is no cell, select the cellview item - // to support applications with an active cellview (that is however invalid) - set_active_cellview_index (cv_index); - } - - bool add_other_layers = m_add_other_layers; - - // Use the "layer-properties-file" meta info from the handle to get the layer properties file. - // If no such file is present, use the default file or the technology specific file. - std::string lyp_file = m_def_lyp_file; - if (tech && ! tech->eff_layer_properties_file ().empty ()) { - lyp_file = tech->eff_layer_properties_file (); - add_other_layers = tech->add_other_layers (); - } - - // Give the layout object a chance to specify a certain layer property file - for (db::Layout::meta_info_iterator meta = cv->layout().begin_meta (); meta != cv->layout().end_meta (); ++meta) { - if (meta->name == "layer-properties-file") { - lyp_file = meta->value; - } - if (meta->name == "layer-properties-add-other-layers") { - try { - tl::from_string (meta->value, add_other_layers); - } catch (...) { - } - } - } - - // interpolate the layout properties file name - tl::Eval expr; - expr.set_var ("layoutfile", filename); - lyp_file = expr.interpolate (lyp_file); - - // create the initial layer properties - create_initial_layer_props (cv_index, lyp_file, add_other_layers); - - // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } - } - - // signal to any observers - file_open_event (); - - // do a fit and update layer lists etc. - zoom_fit (); - if (set_max_hier) { - max_hier (); - } - update_content (); - - m_active_cellview_changed_event_enabled = true; - - } catch (...) { - - update_content (); - - m_active_cellview_changed_event_enabled = true; - throw; - - } - - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - - return cv_index; -} - -void -LayoutView::create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing) -{ - std::vector props; - bool loaded = false; - - if (! lyp_file.empty ()) { - - // read the layer properties from the file - try { - - try { - tl::XMLFileSource in (lyp_file); - props.push_back (lay::LayerPropertiesList ()); - props.back ().load (in); - loaded = true; - } catch (...) { - props.clear (); - tl::XMLFileSource in (lyp_file); - tl::log << tl::to_string (QObject::tr ("Loading layer properties file: ")) << lyp_file; - lay::LayerPropertiesList::load (in, props); - loaded = true; - } - - } catch (tl::Exception &ex) { - tl::warn << tl::to_string (QObject::tr ("Initialization of layers failed: ")) << ex.msg (); - } catch (...) { - tl::warn << tl::to_string (QObject::tr ("Initialization of layers failed: unspecific error")); - } - - } - - std::map cv_map; - cv_map.insert (std::make_pair (-1, cv_index)); - - if (! loaded) { - - props.clear (); - props.push_back (lay::LayerPropertiesList ()); - - } else { - - // do't map cv's if the input file is a multi-cv one. - std::set cv; - for (std::vector::const_iterator p = props.begin (); p != props.end (); ++p) { - for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) { - if (! lp->has_children ()) { - cv.insert (lp->source (true).cv_index ()); - if (cv.size () >= 2) { - cv_map.clear (); - cv_map.insert (std::make_pair (cv_index, cv_index)); - // erase the others: - cv_map.insert (std::make_pair (-1, -2)); - break; - } - } - } - } - - } - - // expand the wildcards and map to the target cv. - for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { - p->attach_view (this, p - props.begin ()); - p->expand (cv_map, add_missing || !loaded); - } - - merge_layer_props (props); -} - -void -LayoutView::merge_layer_props (const std::vector &props) -{ - lay::LayerPropertiesList p0; - if (layer_lists () > 0) { - p0 = get_properties (0); - } - - // merge the new layer views into the present ones - // If the specific list is a single list (no tabs), it is merged into every tab present. - if (props.size () == 1) { - - for (size_t n = 0; n < layer_lists () || n == 0; ++n) { - - std::vector::const_iterator p = props.begin (); - - if (n < layer_lists ()) { - lay::LayerPropertiesList new_props (get_properties ((unsigned int) n)); - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - set_properties ((unsigned int) n, new_props); - } else { - - lay::LayerPropertiesList new_props = p0; - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - insert_layer_list ((unsigned int) n, new_props); - } - - } - - } else { - - size_t n = 0; - for (std::vector::const_iterator p = props.begin (); p != props.end (); ++p, ++n) { - - if (n < layer_lists ()) { - lay::LayerPropertiesList new_props (get_properties ((unsigned int) n)); - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - set_properties ((unsigned int) n, new_props); - } else { - lay::LayerPropertiesList new_props = p0; - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - insert_layer_list ((unsigned int) n, new_props); - } - - } - - } -} - -void -LayoutView::pop_state () -{ - if (m_display_state_ptr > 0) { - m_display_states.erase (m_display_states.begin () + m_display_state_ptr, m_display_states.end ()); - --m_display_state_ptr; - } -} - -void -LayoutView::clear_states () -{ - m_display_states.clear (); - m_display_state_ptr = 0; -} - -void -LayoutView::store_state () -{ - // erase all states after the current position - if (m_display_state_ptr + 1 < m_display_states.size ()) { - m_display_states.erase (m_display_states.begin () + m_display_state_ptr + 1, m_display_states.end ()); - } - - // save the state - DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); - m_display_states.push_back (state); - - m_display_state_ptr = (unsigned int) (m_display_states.size () - 1); -} - -db::DBox -LayoutView::box () const -{ - return mp_canvas->viewport ().box (); -} - -void -LayoutView::timer () -{ - bool dirty = false; - for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end () && ! dirty; ++i) { - dirty = (*i)->layout ().is_editable () && (*i)->is_dirty (); - } - - if (dirty != m_dirty) { - m_dirty = dirty; - emit dirty_changed (); - } - - if (m_animated) { - set_view_ops (); - if (mp_control_panel) { - mp_control_panel->set_phase (int (m_phase)); - } - if (m_animated) { - ++m_phase; - } - } -} - -bool -LayoutView::layer_model_updated () -{ - // because check_updated is called in the initialization phase, we check if the pointers - // to the widgets are non-null: - if (mp_control_panel) { - return mp_control_panel->model_updated (); - } else { - return false; - } -} - -void -LayoutView::force_update_content () -{ - set_view_ops (); -} - -void -LayoutView::update_content () -{ - if (m_activated) { - set_view_ops (); - } -} - -void -LayoutView::zoom_fit_sel () -{ - db::DBox bbox = selection_bbox (); - if (! bbox.empty ()) { - bbox = db::DBox (bbox.left () - 0.025 * bbox.width (), bbox.bottom () - 0.025 * bbox.height (), - bbox.right () + 0.025 * bbox.width (), bbox.top () + 0.025 * bbox.height ()); - zoom_box (bbox); - } -} - -db::DBox -LayoutView::full_box () const -{ - // compute the bounding box over all layers - // this will trigger the update procedures of the layout objects if not done yet .. - - db::DBox bbox; - - for (LayerPropertiesConstIterator l = get_properties ().begin_const_recursive (); ! l.at_end (); ++l) { - bbox += l->bbox (); - } - - for (lay::AnnotationShapes::iterator a = annotation_shapes ().begin (); ! a.at_end (); ++a) { - bbox += a->box (); - } - - if (bbox.empty ()) { - bbox = db::DBox (0, 0, 0, 0); // default box - } else { - bbox = db::DBox (bbox.left () - 0.025 * bbox.width (), bbox.bottom () - 0.025 * bbox.height (), - bbox.right () + 0.025 * bbox.width (), bbox.top () + 0.025 * bbox.height ()); - } - - return bbox; -} - -void -LayoutView::zoom_fit () -{ - mp_canvas->zoom_box (full_box (), true /*precious*/); - store_state (); -} - -void -LayoutView::ensure_selection_visible () -{ - ensure_visible (selection_bbox ()); -} - -void -LayoutView::ensure_visible (const db::DBox &bbox) -{ - db::DBox new_box = bbox + viewport ().box (); - mp_canvas->zoom_box (new_box); - store_state (); -} - -void -LayoutView::zoom_box_and_set_hier_levels (const db::DBox &bbox, const std::pair &levels) -{ - mp_canvas->zoom_box (bbox); - set_hier_levels_basic (levels); - store_state (); -} - -void -LayoutView::zoom_box (const db::DBox &bbox) -{ - mp_canvas->zoom_box (bbox); - store_state (); -} - -void -LayoutView::set_global_trans (const db::DCplxTrans &trans) -{ - mp_canvas->set_global_trans (trans); - store_state (); -} - -void -LayoutView::zoom_trans (const db::DCplxTrans &trans) -{ - mp_canvas->zoom_trans (trans); - store_state (); -} - -void -LayoutView::pan_left () -{ - shift_window (1.0, -m_pan_distance, 0.0); -} - -void -LayoutView::pan_right () -{ - shift_window (1.0, m_pan_distance, 0.0); -} - -void -LayoutView::pan_up () -{ - shift_window (1.0, 0.0, m_pan_distance); -} - -void -LayoutView::pan_down () -{ - shift_window (1.0, 0.0, -m_pan_distance); -} - -void -LayoutView::pan_left_fast () -{ - shift_window (1.0, -m_pan_distance * fast_factor, 0.0); -} - -void -LayoutView::pan_right_fast () -{ - shift_window (1.0, m_pan_distance * fast_factor, 0.0); -} - -void -LayoutView::pan_up_fast () -{ - shift_window (1.0, 0.0, m_pan_distance * fast_factor); -} - -void -LayoutView::pan_down_fast () -{ - shift_window (1.0, 0.0, -m_pan_distance * fast_factor); -} - -void -LayoutView::pan_center (const db::DPoint &p) -{ - db::DBox b = mp_canvas->viewport ().box (); - db::DVector d (b.width () * 0.5, b.height () * 0.5); - zoom_box (db::DBox (p - d, p + d)); -} - -void -LayoutView::zoom_in () -{ - shift_window (zoom_factor, 0.0, 0.0); -} - -void -LayoutView::zoom_out () -{ - shift_window (1.0 / zoom_factor, 0.0, 0.0); -} - -void -LayoutView::shift_window (double f, double dx, double dy) -{ - db::DBox b = mp_canvas->viewport ().box (); - - db::DPoint s = mp_canvas->viewport ().global_trans ().inverted () * db::DPoint (dx, dy); - db::DPoint c = b.center () + db::DVector (b.width () * s.x (), b.height () * s.y ()); - - double w = b.width () * f; - double h = b.height () * f; - - db::DVector d (w * 0.5, h * 0.5); - - zoom_box (db::DBox (c - d, c + d)); -} - -void -LayoutView::goto_window (const db::DPoint &p, double s) -{ - if (s > 1e-6) { - db::DBox b (p.x () - s * 0.5, p.y () - s * 0.5, p.x () + s * 0.5, p.y () + s * 0.5); - zoom_box (b); - } else { - db::DBox b (box ()); - b.move (p - b.center ()); - zoom_box (b); - } -} - -void -LayoutView::redraw_layer (unsigned int index) -{ - do_redraw (index); -} - -void -LayoutView::redraw_cell_boxes () -{ - do_redraw (lay::draw_boxes_queue_entry); -} - -void -LayoutView::redraw_deco_layer () -{ - // redraw background annotations (images etc.) - mp_canvas->touch_bg (); - - // redraw other annotations: - do_redraw (lay::draw_custom_queue_entry); -} - -void -LayoutView::redraw () -{ - std::vector layers; - - size_t nlayers = 0; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - ++nlayers; - } - } - layers.reserve (nlayers); - - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - layers.push_back (RedrawLayerInfo (*l)); - } - } - - mp_canvas->redraw_new (layers); -} - -void -LayoutView::cancel_edits () -{ - // cancel all drag and pending edit operations such as move operations. - mp_canvas->drag_cancel (); - lay::Editables::cancel_edits (); -} - -void -LayoutView::cancel () -{ - // cancel all drags and pending edit operations such as move operations. - cancel_edits (); - // re-enable edit mode - enable_edits (true); - // and clear the selection - clear_selection (); -} - -void -LayoutView::cancel_esc () -{ - cancel (); - switch_mode (default_mode ()); -} - void LayoutView::bookmark_current_view () { @@ -4037,67 +702,12 @@ LayoutView::bookmarks (const BookmarkList &b) void LayoutView::bookmark_view (const std::string &name) { - DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); + DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), cellview_list ()); m_bookmarks.add (name, state); mp_bookmarks_view->refresh (); emit menu_needs_update (); } -void -LayoutView::goto_view (const DisplayState &state) -{ - mp_canvas->zoom_box (state.box ()); - - std::list cellviews; - for (unsigned int i = 0; i < m_cellviews.size (); ++i) { - cellviews.push_back (state.cellview (i, cellview_iter (i)->operator-> ())); - } - - select_cellviews (cellviews); - - if (state.min_hier () <= state.max_hier ()) { - set_hier_levels_basic (std::make_pair (state.min_hier (), state.max_hier ())); - } - - update_content (); -} - -void -LayoutView::save_view (DisplayState &state) const -{ - state = DisplayState (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); -} - -void -LayoutView::do_redraw (int layer) -{ - std::vector layers; - layers.push_back (layer); - - mp_canvas->redraw_selected (layers); -} - -void -LayoutView::do_prop_changed () -{ - if (m_visibility_changed) { - - // change visibility and redraw exposed layers - std::vector visibility; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - visibility.push_back (l->visible (true /*real*/)); - } - } - mp_canvas->change_visibility (visibility); - - m_visibility_changed = false; - - } - - update_content (); -} - void LayoutView::layer_tab_changed () { @@ -4110,625 +720,29 @@ LayoutView::layer_order_changed () update_content (); } -void -LayoutView::set_view_ops () -{ - bool bright_background = (mp_canvas->background_color ().green () > 128); - int brightness_for_context = ((bright_background ? m_ctx_dimming : -m_ctx_dimming) * 256) / 100; - int brightness_for_child_context = ((bright_background ? m_child_ctx_dimming : -m_child_ctx_dimming) * 256) / 100; - - // count the layers to be able to reserve the number of view_ops - size_t nlayers = 0; - for (LayerPropertiesConstIterator lp = get_properties ().begin_const_recursive (); !lp.at_end (); ++lp) { - if (! lp->has_children ()) { - ++nlayers; - } - } - - std::vector view_ops; - view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after); - - lay::Color box_color; - if (! m_box_color.is_valid ()) { - box_color = mp_canvas->foreground_color (); - } else { - box_color = m_box_color; - } - - // cell boxes - if (m_cell_box_visible) { - - lay::ViewOp vop; - - // context level - if (m_ctx_color.is_valid ()) { - vop = lay::ViewOp (m_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); - } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); - } - - // fill, frame, text, vertex - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - view_ops.push_back (vop); - view_ops.push_back (vop); - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - - // child level - if (m_child_ctx_color.is_valid ()) { - vop = lay::ViewOp (m_child_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); - } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); - } - - // fill, frame, text, vertex - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - view_ops.push_back (vop); - view_ops.push_back (vop); - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - - // current level - vop = lay::ViewOp (box_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); - - // fill, frame, text, vertex - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - view_ops.push_back (vop); - view_ops.push_back (vop); - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - - } else { - // invisible - for (unsigned int i = 0; i < (unsigned int) planes_per_layer; ++i) { // frame, fill, vertex, text - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - } - - // sanity check: number of planes defined in layRedrawThreadWorker must match to view_ops layout - tl_assert (view_ops.size () == (size_t)cell_box_planes); - - // produce the ViewOps for the guiding shapes - - color_t gs_color = box_color.rgb (); - if (m_guiding_shape_color.is_valid ()) { - gs_color = m_guiding_shape_color.rgb (); - } - - for (int ctx = 0; ctx < 3; ++ctx) { // 0 (context), 1 (child), 2 (current) - - lay::ViewOp::Mode mode = lay::ViewOp::Copy; - - color_t fill_color, frame_color, text_color; - int dp = 1; // no stipples for guiding shapes - - if (ctx == 0) { - - // context planes - if (m_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_ctx_color.rgb (); - } else { - frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_context); - } - - if (m_ctx_hollow) { - dp = 1; - } - - } else if (ctx == 1) { - - // child level planes (if used) - if (m_child_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_child_ctx_color.rgb (); - } else { - frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_child_context); - } - - if (m_child_ctx_hollow) { - dp = 1; - } - - } else { - - // current level planes - frame_color = text_color = fill_color = gs_color; - - } - - if (m_guiding_shape_visible) { - - // fill - view_ops.push_back (lay::ViewOp (fill_color, mode, 0, dp, 0)); // fill - - // frame - view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Rect, m_guiding_shape_line_width)); - - // text - if (m_text_visible) { - view_ops.push_back (lay::ViewOp (text_color, mode, 0, 0, 0)); - } else { - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - - // vertex - view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Rect, m_guiding_shape_vertex_size /*mark size*/)); // vertex - - } else { - view_ops.push_back (lay::ViewOp ()); - view_ops.push_back (lay::ViewOp ()); - view_ops.push_back (lay::ViewOp ()); - view_ops.push_back (lay::ViewOp ()); - } - - } - - // sanity check: number of planes defined in layRedrawThreadWorker must match to view_ops layout - tl_assert (view_ops.size () == (size_t)special_planes_before); - - bool animated = false; - - for (int ctx = 0; ctx < 3; ++ctx) { // 0 (context), 1 (child), 2 (current) - - unsigned int ilayer = 0; - for (LayerPropertiesConstIterator lp = get_properties ().begin_const_recursive (); !lp.at_end (); ++lp, ++ilayer) { - - // because accessing the LayerPropertiesNode with lp->... is not quite efficient, we get the pointer here: - const lay::LayerPropertiesNode *l = &*lp; - - if (l->has_children ()) { - continue; - } - - bool animate_visible = true; - unsigned int di_off = m_stipple_offset ? ilayer : 0; - - if (l->animation (true /*real*/)) { - - animated = true; - if (! m_animated) { - m_animated = true; - m_phase = 0; - } - - if (l->animation (true /*real*/) == 1) { - // scrolling - di_off += m_phase; - } else if (l->animation (true /*real*/) == 2) { - // blinking - animate_visible = ((m_phase & 1) == 0); - } else { - // inversely blinking - animate_visible = ((m_phase & 1) != 0); - } - - } - - if (l->visible (true /*real*/) && animate_visible) { - - lay::ViewOp::Mode mode = lay::ViewOp::Copy; - if (l->transparent (true /*real*/)) { - if (bright_background) { - mode = lay::ViewOp::And; - } else { - mode = lay::ViewOp::Or; - } - } - - color_t fill_color, frame_color, text_color; - int dp = m_no_stipples ? 1 : l->dither_pattern (true /*real*/); - int ls = l->line_style (true /*real*/); - - if (ctx == 0) { - - // context planes - if (m_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_ctx_color.rgb (); - } else { - fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_context); - frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_context); - if (m_text_color.is_valid ()) { - text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_context); - } else { - text_color = frame_color; - } - } - - if (m_ctx_hollow) { - dp = 1; - } - - } else if (ctx == 1) { - - // child level planes (if used) - if (m_child_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_child_ctx_color.rgb (); - } else { - fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_child_context); - frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_child_context); - if (m_text_color.is_valid ()) { - text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_child_context); - } else { - text_color = frame_color; - } - } - - if (m_child_ctx_hollow) { - dp = 1; - } - - } else { - - // current level planes - fill_color = l->eff_fill_color (true /*real*/); - frame_color = l->eff_frame_color (true /*real*/); - if (m_text_color.is_valid ()) { - text_color = m_text_color.rgb (); - } else { - text_color = frame_color; - } - - } - - // fill - view_ops.push_back (lay::ViewOp (fill_color, mode, 0, dp, di_off)); // fill - - // frame - int lw = l->width (true /*real*/); - if (lw < 0) { - // default line width is 0 for parents and 1 for leafs - lw = l->has_children () ? 0 : 1; - } - view_ops.push_back (lay::ViewOp (frame_color, mode, ls, 0, 0, lay::ViewOp::Rect, lw)); - - // text - if (m_text_visible) { - view_ops.push_back (lay::ViewOp (text_color, mode, 0, 0, 0)); - } else { - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - // vertex - view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Cross, l->marked (true /*real*/) ? 9/*mark size*/ : 0)); // vertex - - } else { - for (unsigned int i = 0; i < (unsigned int) planes_per_layer / 3; ++i) { - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - } - - } - - } - - if (! animated) { - m_animated = false; - m_phase = 0; - } - - mp_canvas->set_view_ops (view_ops); -} - -void -LayoutView::guiding_shapes_visible (bool v) -{ - if (v != m_guiding_shape_visible) { - m_guiding_shape_visible = v; - update_content (); - } -} - -void -LayoutView::guiding_shapes_color (lay::Color c) -{ - if (c != m_guiding_shape_color) { - m_guiding_shape_color = c; - update_content (); - } -} - -void -LayoutView::guiding_shapes_line_width (int v) -{ - if (v != m_guiding_shape_line_width) { - m_guiding_shape_line_width = v; - update_content (); - } -} - -void -LayoutView::guiding_shapes_vertex_size (int v) -{ - if (v != m_guiding_shape_vertex_size) { - m_guiding_shape_vertex_size = v; - update_content (); - } -} - -void -LayoutView::draw_array_border_instances (bool m) -{ - if (m != m_draw_array_border_instances) { - m_draw_array_border_instances = m; - redraw (); - } -} - -void -LayoutView::drop_small_cells (bool m) -{ - if (m != m_drop_small_cells) { - m_drop_small_cells = m; - redraw (); - } -} - -void -LayoutView::drop_small_cells_value (unsigned int s) -{ - if (s != m_drop_small_cells_value) { - m_drop_small_cells_value = s; - redraw (); - } -} - -void -LayoutView::drop_small_cells_cond (drop_small_cells_cond_type t) -{ - if (t != m_drop_small_cells_cond) { - m_drop_small_cells_cond = t; - redraw (); - } -} - -void -LayoutView::cell_box_color (lay::Color c) -{ - if (c != m_box_color) { - m_box_color = c; - update_content (); - } -} - -void -LayoutView::cell_box_text_transform (bool xform) -{ - if (xform != m_box_text_transform) { - m_box_text_transform = xform; - redraw (); - } -} - -void -LayoutView::cell_box_text_font (unsigned int f) -{ - if (f != m_box_font) { - m_box_font = f; - redraw (); - } -} - -bool -LayoutView::set_hier_levels_basic (std::pair l) -{ - if (l != get_hier_levels ()) { - - if (mp_min_hier_spbx) { - mp_min_hier_spbx->blockSignals (true); - mp_min_hier_spbx->setValue (l.first); - mp_min_hier_spbx->setMaximum (l.second); - mp_min_hier_spbx->blockSignals (false); - } - - if (mp_max_hier_spbx) { - mp_max_hier_spbx->blockSignals (true); - mp_max_hier_spbx->setValue (l.second); - mp_max_hier_spbx->setMinimum (l.first); - mp_max_hier_spbx->blockSignals (false); - } - - m_from_level = l.first; - m_to_level = l.second; - - // notify all connected observers - hier_levels_changed_event (); - - redraw (); - - return true; - - } else { - return false; - } -} - -void -LayoutView::set_hier_levels (std::pair l) -{ - if (set_hier_levels_basic (l)) { - store_state (); - } -} - -std::pair -LayoutView::get_hier_levels () const -{ - return std::make_pair (m_from_level, m_to_level); -} - void LayoutView::min_hier_changed (int i) { mp_max_hier_spbx->setMinimum (i); - set_hier_levels (std::make_pair (i, m_to_level)); + set_hier_levels (std::make_pair (i, get_hier_levels ().second)); } void LayoutView::max_hier_changed (int i) { mp_min_hier_spbx->setMaximum (i); - set_hier_levels (std::make_pair (m_from_level, i)); + set_hier_levels (std::make_pair (get_hier_levels ().first, i)); } -/** - * @brief set the maximum hierarchy level to the number of levels available - */ -void -LayoutView::max_hier () +lay::Color +LayoutView::default_background_color () { - // determine the maximum level of hierarchies - int max_level = max_hier_level (); - - // and set the levels - if (max_level > 0) { - set_hier_levels (std::make_pair (std::min (m_from_level, max_level), max_level)); - } -} - -/** - * @brief determine the maximum hierarchy level - */ -int -LayoutView::max_hier_level () const -{ - int max_level = 0; - for (std::list ::const_iterator cv = m_cellviews.begin (); cv != m_cellviews.end (); ++cv) { - if (cv->is_valid ()) { - int nl = cv->ctx_cell ()->hierarchy_levels () + 1; - if (nl > max_level) { - max_level = nl; - } - } - } - return max_level; -} - -/** - * @brief Returns a value indicating whether the maximum level is shown - */ -bool -LayoutView::has_max_hier () const -{ - int ml = max_hier_level (); - return ml > 0 && m_to_level >= ml; -} - -void -LayoutView::set_palette (const lay::ColorPalette &p) -{ - m_palette = p; -} - -void -LayoutView::set_palette (const lay::StipplePalette &p) -{ - m_stipple_palette = p; -} - -void -LayoutView::set_palette (const lay::LineStylePalette &p) -{ - m_line_style_palette = p; -} - -void -LayoutView::ctx_color (lay::Color c) -{ - if (c != m_ctx_color) { - m_ctx_color = c; - update_content (); - } -} - -void -LayoutView::ctx_dimming (int d) -{ - if (d != m_ctx_dimming) { - m_ctx_dimming = d; - update_content (); - } -} - -void -LayoutView::ctx_hollow (bool h) -{ - if (h != m_ctx_hollow) { - m_ctx_hollow = h; - update_content (); - } -} - -void -LayoutView::child_ctx_color (lay::Color c) -{ - if (c != m_child_ctx_color) { - m_child_ctx_color = c; - update_content (); - } -} - -void -LayoutView::child_ctx_dimming (int d) -{ - if (d != m_child_ctx_dimming) { - m_child_ctx_dimming = d; - update_content (); - } -} - -void -LayoutView::child_ctx_hollow (bool h) -{ - if (h != m_child_ctx_hollow) { - m_child_ctx_hollow = h; - update_content (); - } -} - -void -LayoutView::child_ctx_enabled (bool f) -{ - if (f != m_child_ctx_enabled) { - m_child_ctx_enabled = f; - update_content (); - redraw (); - } -} - -void -LayoutView::abstract_mode_width (double w) -{ - if (fabs (w - m_abstract_mode_width) > 1e-6) { - m_abstract_mode_width = w; - if (m_abstract_mode_enabled) { - redraw (); - } - } -} - -void -LayoutView::abstract_mode_enabled (bool e) -{ - if (e != m_abstract_mode_enabled) { - m_abstract_mode_enabled = e; - redraw (); - } + return lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); } void -LayoutView::background_color (lay::Color c) +LayoutView::do_set_background_color (lay::Color c, lay::Color contrast) { - if (c == mp_canvas->background_color ()) { - return; - } - - // replace by "real" background color if required - if (! c.is_valid ()) { - c = lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); - } - - lay::Color contrast; - if (c.green () > 128) { - contrast = lay::Color (0, 0, 0); - } else { - contrast = lay::Color (255, 255, 255); - } - if (mp_control_panel) { mp_control_panel->set_background_color (c); mp_control_panel->set_text_color (contrast); @@ -4748,67 +762,6 @@ LayoutView::background_color (lay::Color c) mp_bookmarks_view->set_background_color (c); mp_bookmarks_view->set_text_color (contrast); } - - if (mp_selection_service) { - mp_selection_service->set_colors (c, contrast); - } - if (mp_zoom_service) { - mp_zoom_service->set_colors (c, contrast); - } - - // Set the color for all ViewService interfaces - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - lay::ViewService *svc = (*p)->view_service_interface (); - if (svc) { - svc->set_colors (c, contrast); - } - } - - mp_canvas->set_colors (c, contrast, mp_canvas->active_color ()); - - update_content (); - - background_color_changed_event (); -} - -void -LayoutView::dbu_coordinates (bool f) -{ - m_dbu_coordinates = f; -} - -void -LayoutView::absolute_coordinates (bool f) -{ - m_absolute_coordinates = f; -} - -void -LayoutView::select_cellviews_fit (const std::list &cvs) -{ - if (m_cellviews != cvs) { - - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_about_to_change_event (index); - } - - cellviews_about_to_change_event (); - - set_min_hier_levels (0); - cancel_esc (); - m_cellviews = cvs; - zoom_fit (); - finish_cellviews_changed (); - - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_changed (index); - } - - update_content (); - - } else { - zoom_fit (); - } } void @@ -4826,7 +779,7 @@ LayoutView::active_cellview_changed (int index) active_cellview_changed_with_index_event (index); // Because the title reflects the active one, emit a title changed event - if (m_title.empty ()) { + if (title_string ().empty ()) { emit title_changed (); } @@ -4846,435 +799,6 @@ LayoutView::active_library_changed (int /*index*/) dispatcher ()->config_set (cfg_current_lib_view, lib_name); } -void -LayoutView::cellview_changed (unsigned int index) -{ - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (index); - } - - cellview_changed_event (index); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::select_cell_dispatch (const cell_path_type &path, int cellview_index) -{ - bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); - if (m_clear_ruler_new_cell) { - - // This is a HACK, but the clean solution would be to provide a new editable - // method like "clear_annotations": - lay::Plugin *antPlugin = get_plugin_by_name ("ant::Plugin"); - if (antPlugin) { - antPlugin->menu_activated ("ant::clear_all_rulers_internal"); - } - - } - - if (m_fit_new_cell) { - select_cell_fit (path, cellview_index); - } else { - select_cell (path, cellview_index); - } - set_current_cell_path (cellview_index, path); - if (set_max_hier) { - max_hier (); - } -} - -void -LayoutView::select_cell_fit (const cell_path_type &path, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_specific_path (lay::CellView::specific_cell_path_type ()); - cellview_iter (index)->set_unspecific_path (path); - set_active_cellview_index (index); - redraw (); - zoom_fit (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cell_fit (cell_index_type cell_index, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->cell_index () != cell_index) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_cell (cell_index); - set_active_cellview_index (index); - redraw (); - zoom_fit (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cellviews (const std::list &cvs) -{ - if (m_cellviews != cvs) { - - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_about_to_change_event (index); - } - cellviews_about_to_change_event (); - - set_min_hier_levels (0); - cancel_esc (); - m_cellviews = cvs; - redraw (); - - cellviews_changed_event (); - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_changed (index); - } - - update_content (); - - } -} - -void -LayoutView::select_cellview (int index, const CellView &cv) -{ - if (index < 0 || index >= int (m_cellviews.size ())) { - return; - } - - if (*cellview_iter (index) != cv) { - - cellview_about_to_change_event (index); - - cancel_esc (); - *cellview_iter (index) = cv; - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cell (const cell_path_type &path, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_specific_path (lay::CellView::specific_cell_path_type ()); - cellview_iter (index)->set_unspecific_path (path); - set_active_cellview_index (index); - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cell (cell_index_type cell_index, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && (! cellview_iter (index)->is_valid () || cellview_iter (index)->cell_index () != cell_index)) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_cell (cell_index); - set_active_cellview_index (index); - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -bool -LayoutView::is_cell_hidden (cell_index_type ci, int cellview_index) const -{ - if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { - return m_hidden_cells [cellview_index].find (ci) != m_hidden_cells [cellview_index].end (); - } else { - return false; - } -} - -const std::set & -LayoutView::hidden_cells (int cellview_index) const -{ - if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { - return m_hidden_cells[cellview_index]; - } else { - static std::set empty_set; - return empty_set; - } -} - -void -LayoutView::hide_cell (cell_index_type ci, int cellview_index) -{ - if (cellview_index < 0) { - return; - } - while (int (m_hidden_cells.size ()) <= cellview_index) { - m_hidden_cells.push_back (std::set ()); - } - if (m_hidden_cells [cellview_index].insert (ci).second) { - if (transacting ()) { - manager ()->queue (this, new OpHideShowCell (ci, cellview_index, false /*=hide*/)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - cell_visibility_changed_event (); - redraw (); // needs redraw - } -} - -void -LayoutView::show_cell (cell_index_type ci, int cellview_index) -{ - if (cellview_index < 0) { - return; - } - if (int (m_hidden_cells.size ()) > cellview_index) { - if (m_hidden_cells [cellview_index].erase (ci) > 0) { - if (transacting ()) { - manager ()->queue (this, new OpHideShowCell (ci, cellview_index, true /*=show*/)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - cell_visibility_changed_event (); - redraw (); // needs redraw - } - } -} - -void -LayoutView::show_all_cells (int cv_index) -{ - if (cv_index < 0 || cv_index >= int (m_hidden_cells.size ())) { - return; - } - - if (! m_hidden_cells [cv_index].empty ()) { - if (transacting ()) { - for (std::set::const_iterator ci = m_hidden_cells [cv_index].begin (); ci != m_hidden_cells [cv_index].end (); ++ci) { - manager ()->queue (this, new OpHideShowCell (*ci, cv_index, true /*=show*/)); - } - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - m_hidden_cells [cv_index].clear (); - cell_visibility_changed_event (); - redraw (); // needs redraw - } -} - -void -LayoutView::show_all_cells () -{ - bool any = false; - - for (unsigned int i = 0; i < m_hidden_cells.size (); ++i) { - if (! m_hidden_cells [i].empty ()) { - if (transacting ()) { - for (std::set::const_iterator ci = m_hidden_cells [i].begin (); ci != m_hidden_cells [i].end (); ++ci) { - manager ()->queue (this, new OpHideShowCell (*ci, i, true /*=show*/)); - } - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - m_hidden_cells [i].clear (); - any = true; - } - } - - if (any) { - cell_visibility_changed_event (); - redraw (); // needs redraw - return; - } -} - -void -LayoutView::min_inst_label_size (int px) -{ - if (m_min_size_for_label != px) { - m_min_size_for_label = px; - redraw (); - } -} - -void -LayoutView::text_visible (bool vis) -{ - if (m_text_visible != vis) { - m_text_visible = vis; - update_content (); - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::show_properties_as_text (bool sp) -{ - if (m_show_properties != sp) { - m_show_properties = sp; - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::bitmap_caching (bool l) -{ - if (m_bitmap_caching != l) { - m_bitmap_caching = l; - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::text_lazy_rendering (bool l) -{ - if (m_text_lazy_rendering != l) { - m_text_lazy_rendering = l; - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::cell_box_visible (bool vis) -{ - if (m_cell_box_visible != vis) { - m_cell_box_visible = vis; - update_content (); - } -} - -void -LayoutView::text_font (unsigned int f) -{ - if (m_text_font != f) { - m_text_font = f; - redraw (); - } -} - -void -LayoutView::default_text_size (double fs) -{ - if (m_default_text_size != fs) { - m_default_text_size = fs; - redraw (); - } -} - -void -LayoutView::clear_ruler_new_cell (bool f) -{ - m_clear_ruler_new_cell = f; -} - -void -LayoutView::full_hier_new_cell (bool f) -{ - m_full_hier_new_cell = f; -} - -double -LayoutView::pan_distance () const -{ - return m_pan_distance; -} - -void -LayoutView::pan_distance (double pd) -{ - m_pan_distance = pd; -} - -void -LayoutView::fit_new_cell (bool f) -{ - m_fit_new_cell = f; -} - -void -LayoutView::apply_text_trans (bool f) -{ - if (m_apply_text_trans != f) { - m_apply_text_trans = f; - redraw (); - } -} - -void -LayoutView::offset_stipples (bool f) -{ - if (m_stipple_offset != f) { - m_stipple_offset = f; - update_content (); - } -} - -void -LayoutView::no_stipples (bool f) -{ - if (m_no_stipples != f) { - m_no_stipples = f; - if (mp_control_panel) { - mp_control_panel->set_no_stipples (m_no_stipples); - } - update_content (); - } -} - -void -LayoutView::show_markers (bool f) -{ - if (m_show_markers != f) { - m_show_markers = f; - mp_canvas->update_image (); - } -} - -void -LayoutView::text_color (lay::Color c) -{ - if (m_text_color != c) { - m_text_color = c; - update_content (); - } -} - bool LayoutView::has_selection () { @@ -5283,67 +807,19 @@ LayoutView::has_selection () } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { return mp_hierarchy_panel->has_selection (); } else { - return lay::Editables::has_selection (); + return lay::LayoutViewBase::has_selection (); } } void -LayoutView::paste () +LayoutView::do_paste () { - clear_selection (); - - { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste"))); - - // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } - lay::Editables::paste (); + // let the receivers sort out who is pasting what .. + if (mp_hierarchy_panel) { + mp_hierarchy_panel->paste (); } - - // if we change the state, save it before - store_state (); - - db::DBox sel_bbox = selection_bbox (); - if (! sel_bbox.empty ()) { - if (m_paste_display_mode == 1) { - // just make selection visible, i.e. shift window somewhat - pan_center (sel_bbox.center ()); - } else if (m_paste_display_mode == 2) { - // or: make selection fit into the screen - zoom_fit_sel (); - } - } -} - -void -LayoutView::paste_interactive () -{ - clear_selection (); - - std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (QObject::tr ("Paste and move")))); - - { - // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } - lay::Editables::paste (); - } - - // temporarily close the transaction and pass to the move service for appending it's own - // operations. - trans->close (); - - if (mp_move_service->begin_move (trans.release (), false)) { - switch_mode (-1); // move mode + if (mp_control_panel) { + mp_control_panel->paste (); } } @@ -5355,14 +831,7 @@ LayoutView::copy () } else if (mp_control_panel && mp_control_panel->has_focus ()) { mp_control_panel->copy (); } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - lay::Editables::copy (); - + LayoutViewBase::copy (); } } @@ -5377,150 +846,10 @@ LayoutView::cut () db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); mp_control_panel->cut (); } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); - lay::Editables::cut (); - + LayoutViewBase::cut (); } } -void -LayoutView::add_missing_layers () -{ - std::set present; - LayerPropertiesConstIterator l = begin_layers (); - while (! l.at_end ()) { - if (! l->has_children ()) { - present.insert (l->source (true /*real*/)); - } - ++l; - } - - std::vector actual; - for (unsigned int cv = 0; cv < cellviews (); ++cv) { - const db::Layout &layout = cellview (cv)->layout (); - for (unsigned int l = 0; l < layout.layers (); ++l) { - if (layout.is_valid_layer (l)) { - actual.push_back (lay::ParsedLayerSource (layout.get_properties (l), cv)); - } - } - } - - std::sort (actual.begin (), actual.end ()); - - for (std::vector ::const_iterator a = actual.begin (); a != actual.end (); ++a) { - if (present.find (*a) == present.end ()) { - lay::LayerPropertiesNode node; - node.attach_view (this, current_layer_list ()); - node.set_source (*a); - init_layer_properties (node); - insert_layer (end_layers (), node); - } - } - - emit layer_order_changed (); -} - -LayerState -LayoutView::layer_snapshot () const -{ - LayerState state; - LayerPropertiesConstIterator l = begin_layers (); - while (! l.at_end ()) { - if (! l->has_children ()) { - state.present.insert (l->source (true /*real*/)); - } - ++l; - } - return state; -} - -void -LayoutView::current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) -{ - current_layer_changed_event (iter); -} - -void -LayoutView::add_new_layers (const LayerState &state) -{ - std::vector actual; - for (unsigned int cv = 0; cv < cellviews (); ++cv) { - const db::Layout &layout = cellview (cv)->layout (); - for (unsigned int l = 0; l < layout.layers (); ++l) { - if (layout.is_valid_layer (l)) { - actual.push_back (lay::ParsedLayerSource (layout.get_properties (l), cv)); - } - } - } - - std::sort (actual.begin (), actual.end ()); - - bool needs_update = false; - - for (std::vector ::const_iterator a = actual.begin (); a != actual.end (); ++a) { - if (state.present.find (*a) == state.present.end ()) { - needs_update = true; - lay::LayerPropertiesNode node; - node.attach_view (this, current_layer_list ()); - node.set_source (*a); - // HINT: in editable mode it is desireable to present all layers because otherwise they cannot be - // made visible to populate them. - if (is_editable () || ! node.bbox ().empty ()) { - init_layer_properties (node); - insert_layer (end_layers (), node); - } - } - } - - if (needs_update) { - emit layer_order_changed (); - } -} - -void -LayoutView::remove_unused_layers () -{ - if (mp_control_panel) { - mp_control_panel->cm_remove_unused (); - } -} - -void -LayoutView::prev_display_state () -{ - if (m_display_state_ptr > 0) { - m_display_state_ptr--; - goto_view (m_display_states [m_display_state_ptr]); - } -} - -bool -LayoutView::has_prev_display_state () -{ - return m_display_state_ptr > 0; -} - -void -LayoutView::next_display_state () -{ - if (m_display_state_ptr + 1 < m_display_states.size ()) { - m_display_state_ptr++; - goto_view (m_display_states [m_display_state_ptr]); - } -} - -bool -LayoutView::has_next_display_state () -{ - return m_display_state_ptr + 1 < m_display_states.size (); -} - const lay::CellView & LayoutView::active_cellview () const { @@ -5542,7 +871,7 @@ LayoutView::active_cellview_index () const void LayoutView::set_active_cellview_index (int index) { - if (index >= 0 && index < int (m_cellviews.size ())) { + if (index >= 0 && index < int (cellviews ())) { mp_hierarchy_panel->select_active (index); } } @@ -5569,7 +898,7 @@ void LayoutView::activate () { if (! m_activated) { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { if ((*p)->browser_interface () && (*p)->browser_interface ()->active ()) { (*p)->browser_interface ()->show (); } @@ -5583,14 +912,14 @@ LayoutView::activate () void LayoutView::deactivate () { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { if ((*p)->browser_interface ()) { (*p)->browser_interface ()->hide (); } } emit clear_current_pos (); - mp_canvas->free_resources (); + free_resources (); mp_timer->stop (); m_activated = false; } @@ -5598,7 +927,7 @@ LayoutView::deactivate () void LayoutView::deactivate_all_browsers () { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { if ((*p)->browser_interface ()) { (*p)->browser_interface ()->deactivate (); } @@ -5623,398 +952,21 @@ LayoutView::current_pos (double x, double y) } } -void -LayoutView::stop_redraw () -{ - mp_canvas->stop_redraw (); -} - -void -LayoutView::stop () -{ - stop_redraw (); - deactivate_all_browsers (); -} - -void -LayoutView::mode (int m) -{ - if (m != m_mode) { - - m_mode = m; - lay::Plugin *active_plugin = 0; - - if (m > 0) { - - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->plugin_declaration ()->id () == m) { - active_plugin = *p; - mp_canvas->activate ((*p)->view_service_interface ()); - break; - } - } - - } else if (m == 0 && mp_selection_service) { - mp_canvas->activate (mp_selection_service); - } else if (m == -1 && mp_move_service) { - mp_canvas->activate (mp_move_service); - } - - lay::EditorOptionsPages *eo_pages = editor_options_pages (); - if (eo_pages) { - - // TODO: this is very inefficient as each "activate" will regenerate the tabs - for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { - bool is_active = false; - if ((*op)->plugin_declaration () == 0) { - is_active = true; - } else if (active_plugin && active_plugin->plugin_declaration () == (*op)->plugin_declaration ()) { - is_active = true; - } - (*op)->activate (is_active); - } - - } - - } -} - -bool -LayoutView::is_move_mode () const -{ - return m_mode == -1; -} - -bool -LayoutView::is_selection_mode () const -{ - return m_mode == 0; -} - -unsigned int -LayoutView::intrinsic_mouse_modes (std::vector *descriptions) -{ - if (descriptions) { - descriptions->push_back ("select\t" + tl::to_string (QObject::tr ("Select")) + "<:select.png>"); - descriptions->push_back ("move\t" + tl::to_string (QObject::tr ("Move")) + "<:move.png>"); - } - return 2; -} - -int -LayoutView::default_mode () -{ - return 0; // TODO: any generic scheme? is select, should be ruler.. -} - -std::vector -LayoutView::menu_symbols () -{ - // TODO: currently these are all symbols from all plugins - return lay::PluginDeclaration::menu_symbols (); -} - -void -LayoutView::menu_activated (const std::string &symbol) -{ - // Try the plugin declarations if the view is the top-level dispatcher - if (dispatcher () == this) { - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - if (cls->menu_activated (symbol)) { - return; - } - } - } - - // distribute the menu item call on the plugins - one should take it. - for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { - (*p)->menu_activated (symbol); - } -} - -void -LayoutView::rename_cellview (const std::string &name, int cellview_index) -{ - if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ())) { - if ((*cellview_iter (cellview_index))->name () != name) { - (*cellview_iter (cellview_index))->rename (name); - mp_hierarchy_panel->do_update_content (cellview_index); - if (m_title.empty ()) { - emit title_changed (); - } - } - } -} - -std::vector -LayoutView::cv_transform_variants (int cv_index) const -{ - std::set trns_variants; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; - if (cv_index < int (cellviews ()) && cvi == cv_index) { - trns_variants.insert (l->trans ().begin (), l->trans ().end ()); - } - } - } - return std::vector (trns_variants.begin (), trns_variants.end ()); -} - -std::vector -LayoutView::cv_transform_variants (int cv_index, unsigned int layer) const -{ - if (cellview (cv_index)->layout ().is_valid_layer (layer)) { - std::set trns_variants; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children () && l->layer_index () == int (layer)) { - int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; - if (cv_index < int (cellviews ()) && cvi == cv_index) { - trns_variants.insert (l->trans ().begin (), l->trans ().end ()); - } - } - } - return std::vector (trns_variants.begin (), trns_variants.end ()); - } else { - // may happen if the layer is a guiding shape layer for example - return cv_transform_variants (cv_index); - } -} - -std::map > -LayoutView::cv_transform_variants_by_layer (int cv_index) const -{ - std::map > tv_map; - - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children () && l->layer_index () >= 0) { - int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; - if (cv_index < int (cellviews ()) && cvi == cv_index) { - std::vector &v = tv_map.insert (std::make_pair (l->layer_index (), std::vector ())).first->second; - v.insert (v.end (), l->trans ().begin (), l->trans ().end ()); - } - } - } - - for (std::map >::iterator m = tv_map.begin (); m != tv_map.end (); ++m) { - std::sort (m->second.begin (), m->second.end ()); - m->second.erase (std::unique (m->second.begin (), m->second.end ()), m->second.end ()); - } - - return tv_map; -} - -std::set< std::pair > -LayoutView::cv_transform_variants () const -{ - std::set< std::pair > box_variants; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - unsigned int cv_index = l->cellview_index () >= 0 ? (unsigned int) l->cellview_index () : 0; - if (cv_index < cellviews ()) { - for (std::vector::const_iterator t = l->trans ().begin (); t != l->trans ().end (); ++t) { - box_variants.insert (std::make_pair (*t, cv_index)); - } - } - } - } - return box_variants; -} - -db::InstElement -LayoutView::ascend (int index) -{ - tl_assert (int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()); - - cellview_about_to_change_event (index); - - lay::CellView::specific_cell_path_type spath (cellview_iter (index)->specific_path ()); - if (spath.empty ()) { - return db::InstElement (); - } else { - - cancel (); - db::InstElement ret = spath.back (); - spath.pop_back (); - cellview_iter (index)->set_specific_path (spath); - - store_state (); - redraw (); - - cellview_changed (index); - - update_content (); - - return ret; - - } -} - -void -LayoutView::descend (const std::vector &path, int index) -{ - if (! path.empty () && index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()) { - - cellview_about_to_change_event (index); - - cancel (); - - lay::CellView::specific_cell_path_type spath (cellview_iter (index)->specific_path ()); - spath.insert (spath.end (), path.begin (), path.end ()); - cellview_iter (index)->set_specific_path (spath); - - store_state (); - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -bool -LayoutView::is_editable () const -{ - return m_editable; -} - -unsigned int -LayoutView::search_range () -{ - return m_search_range; -} - -void -LayoutView::set_search_range (unsigned int sr) -{ - m_search_range = sr; -} - -unsigned int -LayoutView::search_range_box () -{ - return m_search_range_box; -} - -void -LayoutView::set_search_range_box (unsigned int sr) -{ - m_search_range_box = sr; -} - void LayoutView::message (const std::string &s, int timeout) { emit show_message (s, timeout * 1000); } -db::cell_index_type -LayoutView::new_cell (int cv_index, const std::string &cell_name) -{ - db::cell_index_type new_ci (0); - - if (cv_index >= 0 && int (m_cellviews.size ()) > cv_index) { - - db::Layout &layout = cellview (cv_index)->layout (); - if (! cell_name.empty () && layout.cell_by_name (cell_name.c_str ()).first) { - throw tl::Exception (tl::to_string (QObject::tr ("A cell with that name already exists: %s")), cell_name); - } - - transaction (tl::to_string (QObject::tr ("New cell"))); - new_ci = layout.add_cell (cell_name.empty () ? 0 : cell_name.c_str ()); - commit (); - - } - - return new_ci; -} - void LayoutView::switch_mode (int m) { - if (m_mode != m) { + if (mode () != m) { mode (m); emit mode_change (m); } } -template -static void make_unique_name (T *object, Iter from, Iter to) -{ - std::string n (object->name ()); - int nn = 0; - - do { - - bool found = n.empty (); - for (Iter i = from; i != to && !found; ++i) { - if ((*i)->name () == n) { - found = true; - } - } - - if (! found) { - break; - } - - n = object->name () + tl::sprintf ("[%d]", ++nn); - - } while (1); - - object->set_name (n); -} - -unsigned int -LayoutView::add_l2ndb (db::LayoutToNetlist *l2ndb) -{ - make_unique_name (l2ndb, m_l2ndbs.begin (), m_l2ndbs.end ()); - m_l2ndbs.push_back (l2ndb); - - // Mark this object as owned by us (for GSI) - l2ndb->keep (); - - l2ndb_list_changed_event (); - - return (unsigned int)(m_l2ndbs.size () - 1); -} - -unsigned int -LayoutView::replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb) -{ - tl_assert (l2ndb != 0); - - if (db_index < m_l2ndbs.size ()) { - - // keep the name as it is used for reference in the browser for example - std::string n = m_l2ndbs [db_index]->name (); - l2ndb->set_name (n); - - delete m_l2ndbs [db_index]; - m_l2ndbs [db_index] = l2ndb; - - // Mark this object as owned by us (for GSI) - l2ndb->keep (); - - l2ndb_list_changed_event (); - - return db_index; - - } else { - return add_l2ndb (l2ndb); - } -} - -db::LayoutToNetlist * -LayoutView::get_l2ndb (int index) -{ - if (index >= 0 && index < int (m_l2ndbs.size ())) { - return m_l2ndbs [index]; - } else { - return 0; - } -} - void LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index) { @@ -6024,76 +976,6 @@ LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index) } } -const db::LayoutToNetlist * -LayoutView::get_l2ndb (int index) const -{ - if (index >= 0 && index < int (m_l2ndbs.size ())) { - return m_l2ndbs [index]; - } else { - return 0; - } -} - -void -LayoutView::remove_l2ndb (unsigned int index) -{ - if (index < (unsigned int) (m_l2ndbs.size ())) { - delete m_l2ndbs [index]; - m_l2ndbs.erase (m_l2ndbs.begin () + index); - l2ndb_list_changed_event (); - } -} - -unsigned int -LayoutView::add_rdb (rdb::Database *rdb) -{ - make_unique_name (rdb, m_rdbs.begin (), m_rdbs.end ()); - m_rdbs.push_back (rdb); - - // Mark this object as owned by us (for GSI) - rdb->keep (); - - rdb_list_changed_event (); - - return (unsigned int)(m_rdbs.size () - 1); -} - -unsigned int -LayoutView::replace_rdb (unsigned int db_index, rdb::Database *rdb) -{ - tl_assert (rdb != 0); - - if (db_index < m_rdbs.size ()) { - - // keep name because it's used for reference in the browser for example - std::string n = m_rdbs [db_index]->name (); - rdb->set_name (n); - - delete m_rdbs [db_index]; - m_rdbs [db_index] = rdb; - - // Mark this object as owned by us (for GSI) - rdb->keep (); - - rdb_list_changed_event (); - - return db_index; - - } else { - return add_rdb (rdb); - } -} - -rdb::Database * -LayoutView::get_rdb (int index) -{ - if (index >= 0 && index < int (m_rdbs.size ())) { - return m_rdbs [index]; - } else { - return 0; - } -} - void LayoutView::open_rdb_browser (int rdb_index, int cv_index) { @@ -6103,32 +985,12 @@ LayoutView::open_rdb_browser (int rdb_index, int cv_index) } } -const rdb::Database * -LayoutView::get_rdb (int index) const -{ - if (index >= 0 && index < int (m_rdbs.size ())) { - return m_rdbs [index]; - } else { - return 0; - } -} - -void -LayoutView::remove_rdb (unsigned int index) -{ - if (index < (unsigned int) (m_rdbs.size ())) { - delete m_rdbs [index]; - m_rdbs.erase (m_rdbs.begin () + index); - rdb_list_changed_event (); - } -} - QSize LayoutView::sizeHint () const { - if ((m_options & LV_Naked) != 0) { + if ((options () & LV_Naked) != 0) { return QSize (200, 200); - } else if ((m_options & LV_NoLayers) != 0 || (m_options & LV_NoHierarchyPanel) != 0 || (m_options & LV_NoLibrariesView) != 0) { + } else if ((options () & LV_NoLayers) != 0 || (options () & LV_NoHierarchyPanel) != 0 || (options () & LV_NoLibrariesView) != 0) { return QSize (400, 200); } else { return QSize (600, 200); diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index a8ad43acf..06094a64e 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -94,7 +94,8 @@ class EditorOptionsPages; * It manages the layer display list, bookmark list etc. */ class LAYBASIC_PUBLIC LayoutView - : public LayoutViewBase + : public QFrame, + public LayoutViewBase { Q_OBJECT @@ -109,6 +110,11 @@ public: */ LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); + /** + * @brief Destructor + */ + ~LayoutView (); + /** * @brief Makes this view the current one */ @@ -119,12 +125,20 @@ public: * * The argument can be 0 which means there is no current view. */ - static void set_current (LayoutViewBase *); + static void set_current (LayoutView *); /** * @brief Gets the current view */ - static LayoutViewBase *current (); + static LayoutView *current (); + + /** + * @brief Determine if there is something to copy + * + * This reimplementation of the lay::Editables interface additionally + * looks for content providers in the tree views for example. + */ + virtual bool has_selection (); /** * @brief Gets the window title of the view @@ -141,6 +155,32 @@ public: */ void reset_title (); + /** + * @brief Display a status message + */ + void message (const std::string &s = "", int timeout = 10); + + /** + * @brief Switches the application's mode + * + * Switches the mode on application level. Use this method to initiate + * a mode switch from the view. + */ + void switch_mode (int m); + + /** + * @brief Updates the menu for the given view + * If the view is 0, the menu shall be updated to reflect "no view active" + */ + static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); + + /** + * @brief Create all plugins + * + * If plugins already exist, they are deleted and created again + */ + void create_plugins (const lay::PluginDeclaration *except_this = 0); + /** * @brief Sets the currently active layer by layer properties and cell view index * @@ -264,6 +304,11 @@ public: set_current_cell_path (active_cellview_index (), path); } + /** + * @brief Indicates the current position + */ + virtual void current_pos (double x, double y); + /** * @brief Bookmark the current view under the given name */ @@ -358,10 +403,26 @@ public: return mp_editor_options_frame; } + /** + * @brief Copies to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for copy providers in the tree views for example. + */ + virtual void copy (); + + /** + * @brief Cuts to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for cut & copy providers in the tree views for example. + */ + virtual void cut (); + /** * @brief Deliver a size hint (reimplementation of QWidget) */ - QSize sizeHint () const; + virtual QSize sizeHint () const; /** * @brief An event signalling that the view is going to close @@ -378,6 +439,19 @@ public: */ tl::Event hide_event; + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. + */ + tl::Event active_cellview_changed_event; + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. The integer parameter is the index of the + * new cellview. + */ + tl::event active_cellview_changed_with_index_event; + public slots: /** * @brief Store the current state on the "previous states" stack @@ -560,56 +634,22 @@ public slots: LayoutViewBase::redraw_cell_boxes (); } - void layer_tab_changed () - { - LayoutViewBase::layer_tab_changed (); - } - - void layer_order_changed () - { - LayoutViewBase::layer_order_changed (); - } + void layer_tab_changed (); + void layer_order_changed (); void timer () { LayoutViewBase::timer (); } - void min_hier_changed (int i) - { - LayoutViewBase::min_hier_changed (i); - } - - void max_hier_changed (int i) - { - LayoutViewBase::max_hier_changed (i); - } + void min_hier_changed (int i); + void max_hier_changed (int i); void deactivate_all_browsers (); -private: - // event handlers used to connect to the layout object's events - void signal_hier_changed (); - void signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index); - void signal_bboxes_changed (); - void signal_prop_ids_changed (); - void signal_layer_properties_changed (); - void signal_cell_name_changed (); - void signal_annotations_changed (); - void signal_plugin_enabled_changed (); - void signal_apply_technology (lay::LayoutHandle *layout_handle); - private slots: - void active_cellview_changed (int index) - { - LayoutViewBase::active_cellview_changed (index); - } - - void active_library_changed (int index) - { - LayoutViewBase::active_library_changed (index); - } - + void active_cellview_changed (int index); + void active_library_changed (int index); void side_panel_destroyed (); signals: @@ -660,6 +700,7 @@ signals: private: QTimer *mp_timer; + bool m_activated; QFrame *mp_left_frame; lay::LayerControlPanel *mp_control_panel; lay::HierarchyControlPanel *mp_hierarchy_panel; @@ -672,18 +713,27 @@ private: BookmarkList m_bookmarks; bool m_active_cellview_changed_event_enabled; - tl::DeferredMethod dm_prop_changed; tl::DeferredMethod dm_setup_editor_option_pages; - void init (db::Manager *mgr, QWidget *parent); + void init_ui (); void init_menu (); + lay::EditorOptionsPages *editor_options_pages (); void do_setup_editor_options_pages (); + +protected: void activate (); void deactivate (); - bool eventFilter(QObject *obj, QEvent *ev); - void showEvent (QShowEvent *); - void hideEvent (QHideEvent *); + virtual bool eventFilter(QObject *obj, QEvent *ev); + virtual void showEvent (QShowEvent *); + virtual void hideEvent (QHideEvent *); + + virtual bool configure (const std::string &name, const std::string &value); + virtual void config_finalize (); + + virtual lay::Color default_background_color (); + virtual void do_set_background_color (lay::Color color, lay::Color contrast); + virtual void do_paste (); }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index f5713323a..1c0ec0d6e 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -236,23 +236,17 @@ struct OpDeleteLayerProps // ------------------------------------------------------------- -const int timer_interval = 500; - -static LayoutViewBase *ms_current = 0; +const double animation_interval = 0.5; LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutViewBase::do_prop_changed) + m_annotation_shapes (manager) { // either it's us or the parent has a dispatcher tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present - tl::DeferredMethodScheduler::instance (); - init (manager); } @@ -260,15 +254,11 @@ LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manage : lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutViewBase::do_prop_changed) + m_annotation_shapes (manager) { // either it's us or the parent has a dispatcher tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present - tl::DeferredMethodScheduler::instance (); - m_annotation_shapes = source->m_annotation_shapes; init (manager); @@ -297,10 +287,6 @@ LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manage mp_canvas->set_dither_pattern (m_layer_properties_lists [0]->dither_pattern ()); } - bookmarks (source->bookmarks ()); - - set_active_cellview_index (source->active_cellview_index ()); - // copy the title m_title = source->m_title; @@ -361,7 +347,7 @@ LayoutViewBase::init (db::Manager *mgr) m_drop_small_cells_cond = DSC_Max; m_draw_array_border_instances = false; m_dirty = false; - m_activated = true; + m_prop_changed = false; m_animated = false; m_phase = 0; m_palette = lay::ColorPalette::default_palette (); @@ -423,10 +409,6 @@ LayoutViewBase::init (db::Manager *mgr) LayoutViewBase::~LayoutViewBase () { - if (ms_current == this) { - ms_current = 0; - } - // detach all observers // This is to prevent signals to partially destroyed observers that own a LayoutViewBase layer_list_changed_event.clear (); @@ -535,6 +517,14 @@ void LayoutViewBase::drop_url (const std::string &path_or_url) } } +void LayoutViewBase::clear_plugins () +{ + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + delete *p; + } + mp_plugins.clear (); +} + lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) { lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); @@ -557,39 +547,6 @@ lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) return p; } -void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - delete *p; - } - mp_plugins.clear (); - - // create the plugins - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - - if (&*cls != except_this) { - - // TODO: clean solution. The following is a HACK: - if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { - // ant and img are created always - create_plugin (&*cls); - } else if ((m_options & LV_NoPlugins) == 0) { - // others: only create unless LV_NoPlugins is set - create_plugin (&*cls); - } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { - // except grid net plugin which is created on request - create_plugin (&*cls); - } - - } - - } - - dm_setup_editor_option_pages (); - - mode (default_mode ()); -} - Plugin *LayoutViewBase::get_plugin_by_name (const std::string &name) const { lay::PluginDeclaration *decl = 0; @@ -670,82 +627,6 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) update_content (); return true; -/*@@@ - } else if (name == cfg_flat_cell_list) { - - bool f; - tl::from_string (value, f); - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_flat (f); - } - return true; - - } else if (name == cfg_split_cell_list) { - - bool f; - tl::from_string (value, f); - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_split_mode (f); - } - return true; - - } else if (name == cfg_split_lib_views) { - - bool f; - tl::from_string (value, f); - if (mp_libraries_view) { - mp_libraries_view->set_split_mode (f); - } - return true; - - } else if (name == cfg_bookmarks_follow_selection) { - - bool f; - tl::from_string (value, f); - if (mp_bookmarks_view) { - mp_bookmarks_view->follow_selection (f); - } - return true; - - } else if (name == cfg_current_lib_view) { - - if (mp_libraries_view) { - mp_libraries_view->select_active_lib_by_name (value); - } - return true; - - } else if (name == cfg_cell_list_sorting) { - - if (mp_hierarchy_panel) { - if (value == "by-name") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByName); - } else if (value == "by-area") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByArea); - } else if (value == "by-area-reverse") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByAreaReverse); - } - } - return true; - - } else if (name == cfg_hide_empty_layers) { - - bool f; - tl::from_string (value, f); - if (mp_control_panel) { - mp_control_panel->set_hide_empty_layers (f); - } - return true; - - } else if (name == cfg_test_shapes_in_view) { - - bool f; - tl::from_string (value, f); - if (mp_control_panel) { - mp_control_panel->set_test_shapes_in_view (f); - } - return true; - -@@@*/ } else if (name == cfg_background_color) { lay::Color color; @@ -1270,9 +1151,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) void LayoutViewBase::config_finalize () { - // It's important that the editor option pages are updated last - because the - // configuration change may trigger other configuration changes - dm_setup_editor_option_pages (); + // .. nothing yet .. } void @@ -1396,7 +1275,7 @@ LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &pr redraw (); - dm_prop_changed (); + m_prop_changed = true; } void @@ -1438,7 +1317,7 @@ LayoutViewBase::delete_layer_list (unsigned index) } layer_list_deleted_event (index); - dm_prop_changed (); + m_prop_changed = true; } void @@ -1551,7 +1430,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p redraw (); - dm_prop_changed (); + m_prop_changed = true; } } @@ -1615,7 +1494,7 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon // TODO: check, if redraw is actually necessary (this is complex!) redraw (); - dm_prop_changed (); + m_prop_changed = true; } } @@ -1658,7 +1537,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesConstIt // perform the callbacks asynchronously to collect the necessary calls instead // of executing them immediately. - dm_prop_changed (); + m_prop_changed = true; } } @@ -1685,7 +1564,7 @@ LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIter if (index == current_layer_list ()) { layer_list_changed_event (2); redraw (); - dm_prop_changed (); + m_prop_changed = true; } return ret; @@ -1717,7 +1596,7 @@ LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator & if (index == current_layer_list ()) { layer_list_changed_event (2); redraw (); - dm_prop_changed (); + m_prop_changed = true; } // invalidate the iterator so it can be used to refer to the next element @@ -3202,6 +3081,7 @@ LayoutViewBase::box () const return mp_canvas->viewport ().box (); } +// @@@ needs to be called "as often as possible" void LayoutViewBase::timer () { @@ -3215,26 +3095,23 @@ LayoutViewBase::timer () emit dirty_changed (); } - if (m_animated) { - set_view_ops (); - if (mp_control_panel) { - mp_control_panel->set_phase (int (m_phase)); - } - if (m_animated) { - ++m_phase; - } + if (m_prop_changed) { + do_prop_changed (); + m_prop_changed = false; } -} -bool -LayoutViewBase::layer_model_updated () -{ - // because check_updated is called in the initialization phase, we check if the pointers - // to the widgets are non-null: - if (mp_control_panel) { - return mp_control_panel->model_updated (); - } else { - return false; + tl::Clock current_time = tl::Clock::current (); + if ((current_time - m_last_checked).seconds () > animation_interval) { + m_last_checked = current_time; + if (m_animated) { + set_view_ops (); + if (mp_control_panel) { + mp_control_panel->set_phase (int (m_phase)); + } + if (m_animated) { + ++m_phase; + } + } } } @@ -3561,18 +3438,6 @@ LayoutViewBase::do_prop_changed () update_content (); } -void -LayoutViewBase::layer_tab_changed () -{ - update_content (); -} - -void -LayoutViewBase::layer_order_changed () -{ - update_content (); -} - void LayoutViewBase::set_view_ops () { @@ -4014,20 +3879,6 @@ LayoutViewBase::get_hier_levels () const return std::make_pair (m_from_level, m_to_level); } -void -LayoutViewBase::min_hier_changed (int i) -{ - mp_max_hier_spbx->setMinimum (i); - set_hier_levels (std::make_pair (i, m_to_level)); -} - -void -LayoutViewBase::max_hier_changed (int i) -{ - mp_min_hier_spbx->setMaximum (i); - set_hier_levels (std::make_pair (m_from_level, i)); -} - /** * @brief set the maximum hierarchy level to the number of levels available */ @@ -4173,6 +4024,18 @@ LayoutViewBase::abstract_mode_enabled (bool e) } } +lay::Color +LayoutViewBase::default_background_color () +{ + return lay::Color (0, 0, 0); // black. +} + +void +LayoutViewBase::do_set_background_color (lay::Color /*color*/, lay::Color /*contrast*/) +{ + // .. nothing yet .. +} + void LayoutViewBase::background_color (lay::Color c) { @@ -4182,7 +4045,7 @@ LayoutViewBase::background_color (lay::Color c) // replace by "real" background color if required if (! c.is_valid ()) { - c = lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); + c = default_background_color (); } lay::Color contrast; @@ -4192,25 +4055,7 @@ LayoutViewBase::background_color (lay::Color c) contrast = lay::Color (255, 255, 255); } - if (mp_control_panel) { - mp_control_panel->set_background_color (c); - mp_control_panel->set_text_color (contrast); - } - - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_background_color (c); - mp_hierarchy_panel->set_text_color (contrast); - } - - if (mp_libraries_view) { - mp_libraries_view->set_background_color (c); - mp_libraries_view->set_text_color (contrast); - } - - if (mp_bookmarks_view) { - mp_bookmarks_view->set_background_color (c); - mp_bookmarks_view->set_text_color (contrast); - } + do_set_background_color (c, contrast); if (mp_selection_service) { mp_selection_service->set_colors (c, contrast); @@ -4274,41 +4119,6 @@ LayoutViewBase::select_cellviews_fit (const std::list &cvs) } } -void -LayoutViewBase::active_cellview_changed (int index) -{ - if (m_active_cellview_changed_event_enabled) { - - // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) - cancel_esc (); - - // we need to setup the editor option pages because the technology may have changed - dm_setup_editor_option_pages (); - - active_cellview_changed_event (); - active_cellview_changed_with_index_event (index); - - // Because the title reflects the active one, emit a title changed event - if (m_title.empty ()) { - emit title_changed (); - } - - } -} - -void -LayoutViewBase::active_library_changed (int /*index*/) -{ - std::string lib_name; - if (mp_libraries_view->active_lib ()) { - lib_name = mp_libraries_view->active_lib ()->get_name (); - } - - // commit the new active library to the other views and persist this state - // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) - dispatcher ()->config_set (cfg_current_lib_view, lib_name); -} - void LayoutViewBase::cellview_changed (unsigned int index) { @@ -4741,13 +4551,13 @@ LayoutViewBase::text_color (lay::Color c) bool LayoutViewBase::has_selection () { - if (mp_control_panel && mp_control_panel->has_focus ()) { - return mp_control_panel->has_selection (); - } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - return mp_hierarchy_panel->has_selection (); - } else { - return lay::Editables::has_selection (); - } + return lay::Editables::has_selection (); +} + +void +LayoutViewBase::do_paste () +{ + // .. nothing yet .. } void @@ -4759,12 +4569,7 @@ LayoutViewBase::paste () db::Transaction trans (manager (), tl::to_string (tr ("Paste"))); // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } + do_paste (); lay::Editables::paste (); } @@ -4792,12 +4597,7 @@ LayoutViewBase::paste_interactive () { // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } + do_paste (); lay::Editables::paste (); } @@ -4985,21 +4785,9 @@ LayoutViewBase::has_next_display_state () } void -LayoutViewBase::current_pos (double x, double y) +LayoutViewBase::current_pos (double /*x*/, double /*y*/) { - if (m_activated) { - if (dbu_coordinates ()) { - double dx = 0.0, dy = 0.0; - if (active_cellview_index () >= 0) { - double dbu = cellview (active_cellview_index ())->layout ().dbu (); - dx = x / dbu; - dy = y / dbu; - } - emit current_pos_changed (dx, dy, true); - } else { - emit current_pos_changed (x, y, false); - } - } + // .. nothing yet .. } void @@ -5008,6 +4796,12 @@ LayoutViewBase::stop_redraw () mp_canvas->stop_redraw (); } +void +LayoutViewBase::free_resources () +{ + mp_canvas->free_resources (); +} + void LayoutViewBase::stop () { @@ -5015,6 +4809,12 @@ LayoutViewBase::stop () deactivate_all_browsers (); } +void +LayoutViewBase::switch_mode (int /*m*/) +{ + // .. nothing yet .. +} + void LayoutViewBase::mode (int m) { @@ -5282,12 +5082,6 @@ LayoutViewBase::set_search_range_box (unsigned int sr) m_search_range_box = sr; } -void -LayoutViewBase::message (const std::string &s, int timeout) -{ - emit show_message (s, timeout * 1000); -} - db::cell_index_type LayoutViewBase::new_cell (int cv_index, const std::string &cell_name) { @@ -5309,15 +5103,6 @@ LayoutViewBase::new_cell (int cv_index, const std::string &cell_name) return new_ci; } -void -LayoutViewBase::switch_mode (int m) -{ - if (m_mode != m) { - mode (m); - emit mode_change (m); - } -} - template static void make_unique_name (T *object, Iter from, Iter to) { diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 65e3af2b8..6a6254114 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -50,6 +50,7 @@ #include "gsi.h" #include "tlException.h" #include "tlEvents.h" +#include "tlTimer.h" #include "dbInstElement.h" namespace rdb { @@ -196,7 +197,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for content providers in the tree views for example. */ - bool has_selection (); + virtual bool has_selection (); /** * @brief Pastes from clipboard @@ -217,7 +218,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for copy providers in the tree views for example. */ - void copy (); + virtual void copy (); /** * @brief Cuts to clipboard @@ -225,7 +226,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for cut & copy providers in the tree views for example. */ - void cut (); + virtual void cut (); /** * @brief Gets the explicit title string of the view @@ -638,19 +639,6 @@ public: */ tl::Event cell_visibility_changed_event; - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. - */ - tl::Event active_cellview_changed_event; - - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. The integer parameter is the index of the - * new cellview. - */ - tl::event active_cellview_changed_with_index_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.). @@ -1294,9 +1282,9 @@ public: unsigned int add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers = true); /** - * @brief Pass the current position from the mouse tracker to the status bar + * @brief Indicates the current position */ - void current_pos (double x, double y); + virtual void current_pos (double x, double y); /** * @brief Obtain the number of cellviews @@ -1389,11 +1377,6 @@ public: */ db::DBox box () const; - /** - * @brief Display a status message - */ - void message (const std::string &s = "", int timeout = 10); - /** * @brief Create a new cell with the given in the given cellview * @@ -1411,14 +1394,6 @@ public: */ void mode (int m); - /** - * @brief Switches the application's mode - * - * Switches the mode on application level. Use this method to initiate - * a mode switch from the view. - */ - void switch_mode (int m); - /** * @brief Test, if the view is currently in move mode. */ @@ -1434,12 +1409,6 @@ public: */ static unsigned int intrinsic_mouse_modes (std::vector *descriptions); - /** - * @brief Updates the menu for the given view - * If the view is 0, the menu shall be updated to reflect "no view active" - */ - static void update_menu (lay::LayoutViewBase *view, lay::AbstractMenu &menu); - /** * @brief Query the default mode */ @@ -1925,16 +1894,6 @@ public: */ void merge_layer_props (const std::vector &props); - /** - * @brief Internal method: check, if the layer tree is and an consistent state. - * - * This method is used by the layer tree model to check, if the tree has been brought into - * a consistent state. - * HINT: for the layout this is solved more consistently with the "under construction" attribute - * of the layout. There is no equivalent object for the layer tree currently. - */ - bool layer_model_updated (); - /** * @brief Get the "select inside PCells" selection mode * @@ -2278,13 +2237,6 @@ public: lay::SelectionService *selection_service () const { return mp_selection_service; } lay::MoveService *move_service () const { return mp_move_service; } - /** - * @brief Create all plugins - * - * If plugins already exist, they are deleted and created again - */ - void create_plugins (const lay::PluginDeclaration *except_this = 0); - /** * @brief Gets the full field box * @@ -2385,11 +2337,7 @@ public: void redraw_layer (unsigned int index); void redraw_deco_layer (); void redraw_cell_boxes (); - void layer_tab_changed (); - void layer_order_changed (); void timer (); - void min_hier_changed (int i); - void max_hier_changed (int i); private: // event handlers used to connect to the layout object's events @@ -2403,10 +2351,6 @@ private: void signal_plugin_enabled_changed (); void signal_apply_technology (lay::LayoutHandle *layout_handle); - void active_cellview_changed (int index); - void active_library_changed (int index); - void side_panel_destroyed (); - private: bool m_editable; int m_disabled_edits; @@ -2492,7 +2436,7 @@ private: bool m_absolute_coordinates; bool m_dirty; - bool m_activated; + bool m_prop_changed; bool m_animated; unsigned int m_phase; @@ -2519,6 +2463,8 @@ private: bool m_visibility_changed; + tl::Clock m_clock, m_last_checked; + void init (db::Manager *mgr); void do_prop_changed (); @@ -2544,9 +2490,6 @@ private: void viewport_changed (); void cellview_changed (unsigned int index); - bool configure (const std::string &name, const std::string &value); - void config_finalize (); - void do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default); void finish_cellviews_changed (); void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; @@ -2555,10 +2498,32 @@ private: // overrides Editables method to display a message void signal_selection_changed (); - lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); +protected: + unsigned int options () const + { + return m_options; + } + + int mode () const + { + return m_mode; + } + + bool configure (const std::string &name, const std::string &value); + void config_finalize (); std::list::iterator cellview_iter (int cv_index); std::list::const_iterator cellview_iter (int cv_index) const; + + lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); + void clear_plugins (); + + void free_resources (); + + virtual lay::Color default_background_color (); + virtual void do_set_background_color (lay::Color color, lay::Color contrast); + virtual void do_paste (); + virtual void switch_mode (int m); }; } diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index 73caa324b..f84a48779 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -28,7 +28,7 @@ namespace lay { -MouseTracker::MouseTracker (lay::LayoutView *view) +MouseTracker::MouseTracker (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view) { widget ()->grab_mouse (this, false);