mirror of https://github.com/KLayout/klayout.git
Implementing "spaced array" option
The "make array" dialog now has a tab where you can select "spaced mode". In spaced mode, the bounding box of the selection is used to compute the array pitch. You can add a space between the columns and rows and decide whether to use all layers for the instance bounding boxes or only the visible ones.
This commit is contained in:
parent
415650bb3a
commit
222c08a73a
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>561</width>
|
||||
<height>323</height>
|
||||
<width>586</width>
|
||||
<height>431</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -20,32 +20,6 @@
|
|||
<property name="margin" stdset="0">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>The selection will be copied row * columns times. Each copy will be displaced by a vector given by the row vector times the row index and the column vector times the column index.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="array_grp">
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -61,144 +35,248 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin" stdset="0">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLineEdit" name="row_x_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="3" column="0" colspan="5">
|
||||
<widget class="QTabWidget" name="mode_tab">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Array with pitch vectors</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string> Each copy will be displaced by a vector given by the row vector times the row index and the column vector times the column index.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>y =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="column_x_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string> Column vector (x,y)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>x =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLineEdit" name="column_y_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLineEdit" name="row_x_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>x =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>y =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QLineEdit" name="row_y_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string> Row vector (x,y)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Grid with space</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Space</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLineEdit" name="space_x_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLineEdit" name="space_y_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>horizonal =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>vertical =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="6">
|
||||
<widget class="QCheckBox" name="vis_only_cbx">
|
||||
<property name="text">
|
||||
<string>Use visible layers only for bounding boxes of instances</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="6">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>The selection is placed in a rectangular array, with the bounding box defining the pitch. Additional space can be added between columns and rows.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<item row="0" column="0" colspan="5">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>x =</string>
|
||||
<string>The selection will be copied row * columns times.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="5">
|
||||
<widget class="QLineEdit" name="column_y_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Columns =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Rows =</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="columns_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string> Row vector (x,y)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string> Column vector (x,y)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="5">
|
||||
<widget class="QLineEdit" name="row_y_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>x =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLineEdit" name="column_x_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<widget class="QLineEdit" name="rows_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>y =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>y =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="6">
|
||||
<item row="2" column="0" colspan="5">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
|
@ -214,6 +292,59 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Columns =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="columns_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Rows =</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="rows_le">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -271,10 +402,14 @@
|
|||
<tabstops>
|
||||
<tabstop>columns_le</tabstop>
|
||||
<tabstop>rows_le</tabstop>
|
||||
<tabstop>mode_tab</tabstop>
|
||||
<tabstop>column_x_le</tabstop>
|
||||
<tabstop>column_y_le</tabstop>
|
||||
<tabstop>row_x_le</tabstop>
|
||||
<tabstop>row_y_le</tabstop>
|
||||
<tabstop>space_x_le</tabstop>
|
||||
<tabstop>space_y_le</tabstop>
|
||||
<tabstop>vis_only_cbx</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "dbLayout.h"
|
||||
|
||||
#include "edtDialogs.h"
|
||||
#include "edtMainService.h"
|
||||
#include "layEditorUtils.h"
|
||||
#include "layObjectInstPath.h"
|
||||
#include "layCellView.h"
|
||||
|
|
@ -646,29 +647,41 @@ MakeArrayOptionsDialog::MakeArrayOptionsDialog (QWidget *parent)
|
|||
}
|
||||
|
||||
bool
|
||||
MakeArrayOptionsDialog::exec_dialog (db::DVector &a, unsigned int &na, db::DVector &b, unsigned int &nb)
|
||||
MakeArrayOptionsDialog::exec_dialog (ArrayOptions &options)
|
||||
{
|
||||
rows_le->setText (tl::to_qstring (tl::to_string (na)));
|
||||
columns_le->setText (tl::to_qstring (tl::to_string (nb)));
|
||||
row_x_le->setText (tl::to_qstring (tl::micron_to_string (a.x ())));
|
||||
row_y_le->setText (tl::to_qstring (tl::micron_to_string (a.y ())));
|
||||
column_x_le->setText (tl::to_qstring (tl::micron_to_string (b.x ())));
|
||||
column_y_le->setText (tl::to_qstring (tl::micron_to_string (b.y ())));
|
||||
rows_le->setText (tl::to_qstring (tl::to_string (options.na)));
|
||||
columns_le->setText (tl::to_qstring (tl::to_string (options.nb)));
|
||||
row_x_le->setText (tl::to_qstring (tl::micron_to_string (options.a.x ())));
|
||||
row_y_le->setText (tl::to_qstring (tl::micron_to_string (options.a.y ())));
|
||||
column_x_le->setText (tl::to_qstring (tl::micron_to_string (options.b.x ())));
|
||||
column_y_le->setText (tl::to_qstring (tl::micron_to_string (options.b.y ())));
|
||||
space_x_le->setText (tl::to_qstring (tl::micron_to_string (options.space.x ())));
|
||||
space_y_le->setText (tl::to_qstring (tl::micron_to_string (options.space.y ())));
|
||||
|
||||
mode_tab->setCurrentIndex (options.mode == ArrayOptions::PitchVectors ? 0 : 1);
|
||||
vis_only_cbx->setChecked (options.use_visible_layers);
|
||||
|
||||
if (QDialog::exec ()) {
|
||||
|
||||
options.mode = mode_tab->currentIndex () == 0 ? ArrayOptions::PitchVectors : ArrayOptions::Spaced;
|
||||
options.use_visible_layers = vis_only_cbx->isChecked ();
|
||||
|
||||
double bx = 0.0, by = 0.0;
|
||||
double ax = 0.0, ay = 0.0;
|
||||
double sx = 0.0, sy = 0.0;
|
||||
|
||||
tl::from_string_ext (tl::to_string (column_x_le->text ()), bx);
|
||||
tl::from_string_ext (tl::to_string (column_y_le->text ()), by);
|
||||
tl::from_string_ext (tl::to_string (columns_le->text ()), nb);
|
||||
tl::from_string_ext (tl::to_string (columns_le->text ()), options.nb);
|
||||
tl::from_string_ext (tl::to_string (row_x_le->text ()), ax);
|
||||
tl::from_string_ext (tl::to_string (row_y_le->text ()), ay);
|
||||
tl::from_string_ext (tl::to_string (rows_le->text ()), na);
|
||||
tl::from_string_ext (tl::to_string (rows_le->text ()), options.na);
|
||||
tl::from_string_ext (tl::to_string (space_x_le->text ()), sx);
|
||||
tl::from_string_ext (tl::to_string (space_y_le->text ()), sy);
|
||||
|
||||
a = db::DVector (ax, ay);
|
||||
b = db::DVector (bx, by);
|
||||
options.a = db::DVector (ax, ay);
|
||||
options.b = db::DVector (bx, by);
|
||||
options.space = db::DVector (sx, sy);
|
||||
|
||||
return true;
|
||||
|
||||
|
|
@ -758,7 +771,7 @@ popup_tap_layer_menu (lay::LayoutViewBase *view, const std::set<db::LayerPropert
|
|||
std::set<std::pair<unsigned int, unsigned int> > layers_in_selection;
|
||||
|
||||
for (lay::ShapeFinder::iterator f = finder.begin (); f != finder.end (); ++f) {
|
||||
if (cv_index < 0 || f->cv_index () == cv_index) {
|
||||
if (cv_index < 0 || int (f->cv_index ()) == cv_index) {
|
||||
const db::Layout &ly = view->cellview (f->cv_index ())->layout ();
|
||||
// ignore guiding shapes and only provide layers from the filter
|
||||
if (f->layer () != ly.guiding_shape_layer ()
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ namespace lay
|
|||
|
||||
namespace edt {
|
||||
|
||||
class ArrayOptions;
|
||||
|
||||
/**
|
||||
* @brief The copy mode dialog
|
||||
*/
|
||||
|
|
@ -173,10 +175,10 @@ class MakeArrayOptionsDialog
|
|||
private Ui::MakeArrayOptionsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
MakeArrayOptionsDialog (QWidget *parent);
|
||||
bool exec_dialog (db::DVector &a, unsigned int &na, db::DVector &b, unsigned int &nb);
|
||||
bool exec_dialog (ArrayOptions &options);
|
||||
|
||||
virtual void accept ();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,8 +81,6 @@ MainService::MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::
|
|||
m_distribute_vmode (1), m_distribute_vpitch (0.0), m_distribute_vspace (0.0),
|
||||
m_distribute_visible_layers (false),
|
||||
m_origin_mode_x (-1), m_origin_mode_y (-1), m_origin_visible_layers_for_bbox (false),
|
||||
m_array_a (0.0, 1.0), m_array_b (1.0, 0.0),
|
||||
m_array_na (1), m_array_nb (1),
|
||||
m_router (0.0), m_rinner (0.0), m_npoints (64), m_undo_before_apply (true)
|
||||
{
|
||||
#if defined(HAVE_QT)
|
||||
|
|
@ -2251,32 +2249,66 @@ MainService::cm_make_array ()
|
|||
tl_assert (false); // see TODO
|
||||
#endif
|
||||
|
||||
size_t n = 0;
|
||||
check_no_guiding_shapes ();
|
||||
|
||||
std::vector<edt::Service *> edt_services = view ()->get_plugins <edt::Service> ();
|
||||
|
||||
for (std::vector<edt::Service *>::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) {
|
||||
for (EditableSelectionIterator s = (*es)->begin_selection (); ! s.at_end (); ++s) {
|
||||
++n;
|
||||
}
|
||||
bool any = false;
|
||||
for (std::vector<edt::Service *>::const_iterator es = edt_services.begin (); es != edt_services.end () && ! any; ++es) {
|
||||
any = ! (*es)->begin_selection ().at_end ();
|
||||
}
|
||||
|
||||
if (n == 0) {
|
||||
if (! any) {
|
||||
throw tl::Exception (tl::to_string (tr ("Nothing selected to make arrays of")));
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
// TODO: make parameters persistent so we can set them externally
|
||||
if (! make_array_options_dialog ()->exec_dialog (m_array_a, m_array_na, m_array_b, m_array_nb)) {
|
||||
if (! make_array_options_dialog ()->exec_dialog (m_array_options)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int na = m_array_options.na;
|
||||
unsigned int nb = m_array_options.nb;
|
||||
db::DVector a = m_array_options.a;
|
||||
db::DVector b = m_array_options.b;
|
||||
|
||||
if (m_array_options.mode == ArrayOptions::Spaced) {
|
||||
|
||||
db::DBox bbox;
|
||||
|
||||
// get the selection bbox
|
||||
for (std::vector<edt::Service *>::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) {
|
||||
for (EditableSelectionIterator s = (*es)->begin_selection (); ! s.at_end (); ++s) {
|
||||
|
||||
const db::Layout &layout = view ()->cellview (s->cv_index ())->layout ();
|
||||
db::CplxTrans tr = db::CplxTrans (layout.dbu ()) * s->trans ();
|
||||
|
||||
if (! s->is_cell_inst ()) {
|
||||
bbox += tr * s->shape ().bbox ();
|
||||
} else {
|
||||
bbox += inst_bbox (tr, view (), s->cv_index (), s->back (), m_array_options.use_visible_layers);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// compute pitch vectors
|
||||
a = db::DVector (0.0, m_array_options.space.y () + bbox.height ()); // row-pitch
|
||||
b = db::DVector (m_array_options.space.x () + bbox.width (), 0.0); // column-pitch
|
||||
|
||||
}
|
||||
|
||||
make_array (na, nb, a, b);
|
||||
}
|
||||
|
||||
void
|
||||
MainService::make_array (unsigned int na, unsigned int nb, const db::DVector &a, const db::DVector &b)
|
||||
{
|
||||
view ()->cancel_edits ();
|
||||
|
||||
// undo support for small arrays only
|
||||
bool has_undo = (m_array_na * m_array_nb < 1000);
|
||||
bool has_undo = (na * nb < 1000);
|
||||
|
||||
// No undo support currently - the undo buffering is pretty inefficient right now.
|
||||
if (manager ()) {
|
||||
|
|
@ -2287,7 +2319,17 @@ MainService::cm_make_array ()
|
|||
}
|
||||
}
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Make array")), (size_t (m_array_na) * size_t (m_array_nb) - 1) * n, 1000);
|
||||
std::vector<edt::Service *> edt_services = view ()->get_plugins <edt::Service> ();
|
||||
|
||||
// count selected items for progress
|
||||
size_t n = 0;
|
||||
for (std::vector<edt::Service *>::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) {
|
||||
for (EditableSelectionIterator s = (*es)->begin_selection (); ! s.at_end (); ++s) {
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
||||
tl::RelativeProgress progress (tl::to_string (tr ("Make array")), (size_t (na) * size_t (nb) - 1) * n, 1000);
|
||||
|
||||
for (std::vector<edt::Service *>::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) {
|
||||
|
||||
|
|
@ -2302,15 +2344,15 @@ MainService::cm_make_array ()
|
|||
|
||||
if (s->is_cell_inst ()) {
|
||||
|
||||
for (unsigned int ia = 0; ia < m_array_na; ++ia) {
|
||||
for (unsigned int ib = 0; ib < m_array_nb; ++ib) {
|
||||
for (unsigned int ia = 0; ia < na; ++ia) {
|
||||
for (unsigned int ib = 0; ib < nb; ++ib) {
|
||||
|
||||
// don't create a copy
|
||||
if (ia == 0 && ib == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib));
|
||||
db::DCplxTrans dtrans (a * double (ia) + b * double (ib));
|
||||
db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ()));
|
||||
|
||||
db::Instance new_inst = target_cell.insert (s->back ().inst_ptr);
|
||||
|
|
@ -2326,15 +2368,15 @@ MainService::cm_make_array ()
|
|||
|
||||
db::Shapes &target_shapes = target_cell.shapes (s->layer ());
|
||||
|
||||
for (unsigned int ia = 0; ia < m_array_na; ++ia) {
|
||||
for (unsigned int ib = 0; ib < m_array_nb; ++ib) {
|
||||
for (unsigned int ia = 0; ia < na; ++ia) {
|
||||
for (unsigned int ib = 0; ib < nb; ++ib) {
|
||||
|
||||
// don't create a copy
|
||||
if (ia == 0 && ib == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib));
|
||||
db::DCplxTrans dtrans (a * double (ia) + b * double (ib));
|
||||
db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ()));
|
||||
|
||||
db::Shape new_shape = target_shapes.insert (s->shape ());
|
||||
|
|
|
|||
|
|
@ -56,6 +56,21 @@ class DistributeOptionsDialog;
|
|||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
struct ArrayOptions
|
||||
{
|
||||
enum mode_type { PitchVectors, Spaced };
|
||||
|
||||
ArrayOptions () : mode (PitchVectors), a (0.0, 1.0), b (1.0, 0.0), na (1), nb (1) { }
|
||||
|
||||
mode_type mode;
|
||||
db::DVector a, b;
|
||||
unsigned int na, nb;
|
||||
db::DVector space;
|
||||
bool use_visible_layers;
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
class MainService
|
||||
: public lay::Plugin,
|
||||
public lay::Editable,
|
||||
|
|
@ -155,6 +170,11 @@ public:
|
|||
*/
|
||||
void cm_make_array ();
|
||||
|
||||
/**
|
||||
* @brief The parameterized function for making arrays
|
||||
*/
|
||||
void make_array (unsigned na, unsigned nb, const db::DVector &a, const db::DVector &b);
|
||||
|
||||
/**
|
||||
* @brief Align the selected shapes and instances
|
||||
*/
|
||||
|
|
@ -242,11 +262,11 @@ private:
|
|||
std::string m_make_cell_name;
|
||||
int m_origin_mode_x, m_origin_mode_y;
|
||||
bool m_origin_visible_layers_for_bbox;
|
||||
db::DVector m_array_a, m_array_b;
|
||||
unsigned int m_array_na, m_array_nb;
|
||||
double m_router, m_rinner;
|
||||
unsigned int m_npoints;
|
||||
bool m_undo_before_apply;
|
||||
ArrayOptions m_array_options;
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
edt::RoundCornerOptionsDialog *mp_round_corners_dialog;
|
||||
edt::AreaAndPerimeterDialog *mp_area_and_perimeter_dialog;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<height>349</height>
|
||||
<width>449</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -405,6 +405,13 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
|
|
@ -429,44 +436,12 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>209</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>pushButton</tabstop>
|
||||
<tabstop>pushButton_2</tabstop>
|
||||
<tabstop>lt</tabstop>
|
||||
<tabstop>ct</tabstop>
|
||||
<tabstop>rt</tabstop>
|
||||
|
|
@ -486,34 +461,34 @@
|
|||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AlignCellOptionsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>237</x>
|
||||
<y>203</y>
|
||||
<x>224</x>
|
||||
<y>295</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>147</x>
|
||||
<y>81</y>
|
||||
<x>224</x>
|
||||
<y>176</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AlignCellOptionsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>325</x>
|
||||
<y>202</y>
|
||||
<x>224</x>
|
||||
<y>295</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>325</x>
|
||||
<y>57</y>
|
||||
<x>224</x>
|
||||
<y>176</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
|
|
|||
Loading…
Reference in New Issue