diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 4b01a130a..d40814b05 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -2525,21 +2525,30 @@ MainWindow::cm_new_layout () std::string technology = m_initial_technology; static std::string s_new_cell_cell_name ("TOP"); static double s_new_cell_window_size = 2.0; + static std::vector s_layers; double dbu = 0.0; lay::NewLayoutPropertiesDialog dialog (this); - if (dialog.exec_dialog (technology, s_new_cell_cell_name, dbu, s_new_cell_window_size, m_new_layout_current_panel)) { + if (dialog.exec_dialog (technology, s_new_cell_cell_name, dbu, s_new_cell_window_size, s_layers, m_new_layout_current_panel)) { - lay::CellViewRef cellview = create_or_load_layout (0, 0, technology, m_new_layout_current_panel ? 2 : 1 /*= new view*/); + std::unique_ptr handle (new lay::LayoutHandle (new db::Layout (& manager ()), std::string ())); + handle->rename ("new"); if (dbu > 1e-10) { - cellview->layout ().dbu (dbu); + handle->layout ().dbu (dbu); } - db::cell_index_type new_ci = cellview->layout ().add_cell (s_new_cell_cell_name.empty () ? 0 : s_new_cell_cell_name.c_str ()); - cellview.set_cell (new_ci); + db::cell_index_type new_ci = handle->layout ().add_cell (s_new_cell_cell_name.empty () ? 0 : s_new_cell_cell_name.c_str ()); - current_view ()->zoom_box_and_set_hier_levels (db::DBox (-0.5 * s_new_cell_window_size, -0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size), std::make_pair (0, 1)); + for (std::vector::const_iterator l = s_layers.begin (); l != s_layers.end (); ++l) { + handle->layout ().insert_layer (*l); + } + + lay::LayoutView *mp_view = (m_new_layout_current_panel && current_view ()) ? current_view () : view (create_view ()); + + unsigned int ci = mp_view->add_layout (handle.release (), true); + mp_view->cellview_ref (ci).set_cell (new_ci); + mp_view->zoom_box_and_set_hier_levels (db::DBox (-0.5 * s_new_cell_window_size, -0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size), std::make_pair (0, 1)); } } diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index 0c5f5b321..4f8196e64 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -1040,7 +1040,7 @@ BEGIN_PROTECTED query_to_model (model, lq, iq, std::numeric_limits::max (), true); model.end_changes (); - std::unique_ptr handle (new lay::LayoutHandle (new db::Layout (), std::string ())); + std::unique_ptr handle (new lay::LayoutHandle (new db::Layout (mp_view->manager ()), std::string ())); handle->rename ("query_results"); model.export_layout (handle->layout ()); mp_view->add_layout (handle.release (), true); diff --git a/src/laybasic/laybasic/NewLayoutPropertiesDialog.ui b/src/laybasic/laybasic/NewLayoutPropertiesDialog.ui index 200666491..588a93c4f 100644 --- a/src/laybasic/laybasic/NewLayoutPropertiesDialog.ui +++ b/src/laybasic/laybasic/NewLayoutPropertiesDialog.ui @@ -6,8 +6,8 @@ 0 0 - 563 - 234 + 594 + 401 @@ -50,7 +50,7 @@ 6 - + @@ -60,13 +60,6 @@ - - - - Database unit - - - @@ -80,13 +73,80 @@ - + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Qt::Horizontal + + + + 141 + 20 + + + + + µm + + + + µm + + + + + + + Top cell + + + + + + + Database unit + + + + + + + Technology + + + @@ -100,74 +160,34 @@ - - - - - 0 - 0 - - - - - - - - - + + - Top cell + (empty for default) - - - - - 0 - 0 - - - - - - - - Technology - - - - + Initial window size - - + + - µm + Initial layer(s) - - - - Qt::Horizontal - - - - 141 - 20 - - - - - - + + - (empty for default) + <html><head/><body>Specify a comma or blank separated list of layers to create in the usual layer notation, e.g. "1/0 2/0 3/0", "metal1 via1 metal2" or "metal1 (1/0) via1 (2/0) metal2 (3/0)"</body></html> + + + true @@ -214,10 +234,12 @@ + tech_cbx topcell_le dbu_le window_le - buttonBox + layers_le + current_panel_cb diff --git a/src/laybasic/laybasic/layDialogs.cc b/src/laybasic/laybasic/layDialogs.cc index 3eb6e7156..886684442 100644 --- a/src/laybasic/laybasic/layDialogs.cc +++ b/src/laybasic/laybasic/layDialogs.cc @@ -129,7 +129,7 @@ NewLayoutPropertiesDialog::tech_changed () } bool -NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &cell_name, double &dbu, double &size, bool ¤t_panel) +NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &cell_name, double &dbu, double &size, std::vector &layers, bool ¤t_panel) { mp_ui->tech_cbx->clear (); unsigned int technology_index = 0; @@ -151,6 +151,15 @@ NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &ce mp_ui->topcell_le->setText (tl::to_qstring (cell_name)); mp_ui->current_panel_cb->setChecked (current_panel); + std::string layer_string; + for (std::vector::const_iterator l = layers.begin (); l != layers.end (); ++l) { + if (l != layers.begin ()) { + layer_string += ", "; + } + layer_string += l->to_string (); + } + mp_ui->layers_le->setText (tl::to_qstring (layer_string)); + if (QDialog::exec ()) { // get the selected technology name @@ -167,8 +176,24 @@ NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &ce } else { dbu = 0.0; } + cell_name = tl::to_string (mp_ui->topcell_le->text ()); current_panel = mp_ui->current_panel_cb->isChecked (); + + layers.clear (); + layer_string = tl::to_string (mp_ui->layers_le->text ()); + tl::Extractor ex (layer_string.c_str ()); + while (! ex.at_end ()) { + db::LayerProperties lp; + try { + lp.read (ex); + } catch (...) { + break; + } + layers.push_back (lp); + ex.test (","); + } + return true; } else { diff --git a/src/laybasic/laybasic/layDialogs.h b/src/laybasic/laybasic/layDialogs.h index 8a12966ea..cb926c3c8 100644 --- a/src/laybasic/laybasic/layDialogs.h +++ b/src/laybasic/laybasic/layDialogs.h @@ -328,7 +328,7 @@ public: NewLayoutPropertiesDialog (QWidget *parent); virtual ~NewLayoutPropertiesDialog (); - bool exec_dialog (std::string &tech_name, std::string &cell_name, double &dbu, double &window_size, bool ¤t_panel); + bool exec_dialog (std::string &tech_name, std::string &cell_name, double &dbu, double &window_size, std::vector &layers, bool ¤t_panel); private slots: void tech_changed (); diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 1a4531ac1..c3bd6fc2a 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -2859,6 +2859,8 @@ LayoutView::add_new_layers (const std::vector &layer_ids, int cv_ // 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; @@ -2890,6 +2892,10 @@ LayoutView::add_new_layers (const std::vector &layer_ids, int cv_ set_properties (new_props); + if (was_empty) { + set_current_layer (new_props.begin_const_recursive ()); + } + } } @@ -3291,6 +3297,18 @@ LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, boo } + // 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 (); @@ -3456,6 +3474,18 @@ LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOption // 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 ();