mirror of https://github.com/KLayout/klayout.git
Material list, visibility
This commit is contained in:
parent
dda18e6f53
commit
1da12970ab
|
|
@ -424,7 +424,23 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="widget" native="true"/>
|
||||
<widget class="QListWidget" name="material_list">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
@ -566,6 +582,36 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="select_all_action">
|
||||
<property name="text">
|
||||
<string>Select All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="unselect_all_action">
|
||||
<property name="text">
|
||||
<string>Unselect All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="show_all_action">
|
||||
<property name="text">
|
||||
<string>Show All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="hide_all_action">
|
||||
<property name="text">
|
||||
<string>Hide All</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="show_selected_action">
|
||||
<property name="text">
|
||||
<string>Show Selected</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="hide_selected_action">
|
||||
<property name="text">
|
||||
<string>Hide Selected</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
@ -594,5 +640,37 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>select_all_action</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>material_list</receiver>
|
||||
<slot>selectAll()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>716</x>
|
||||
<y>336</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>unselect_all_action</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>material_list</receiver>
|
||||
<slot>clearSelection()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>716</x>
|
||||
<y>336</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <QFontMetrics>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
|
|
@ -61,6 +63,10 @@ D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view)
|
|||
connect (mp_ui->d25_view, SIGNAL (vscale_factor_changed(double)), this, SLOT (vscale_factor_changed(double)));
|
||||
connect (mp_ui->d25_view, SIGNAL (init_failed()), this, SLOT (init_failed()));
|
||||
connect (mp_ui->rerun_button, SIGNAL (clicked()), this, SLOT (rerun_button_pressed()));
|
||||
connect (mp_ui->hide_all_action, SIGNAL (triggered()), this, SLOT (hide_all_triggered()));
|
||||
connect (mp_ui->hide_selected_action, SIGNAL (triggered()), this, SLOT (hide_selected_triggered()));
|
||||
connect (mp_ui->show_all_action, SIGNAL (triggered()), this, SLOT (show_all_triggered()));
|
||||
connect (mp_ui->show_selected_action, SIGNAL (triggered()), this, SLOT (show_selected_triggered()));
|
||||
|
||||
mp_ui->rerun_button->setEnabled (false);
|
||||
|
||||
|
|
@ -71,6 +77,25 @@ D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view)
|
|||
|
||||
view->cellviews_changed_event.add (this, &D25View::cellviews_changed);
|
||||
view->layer_list_changed_event.add (this, &D25View::layer_properties_changed);
|
||||
|
||||
QPalette palette = mp_ui->material_list->palette ();
|
||||
palette.setColor (QPalette::Base, Qt::black);
|
||||
palette.setColor (QPalette::Text, Qt::white);
|
||||
mp_ui->material_list->setPalette (palette);
|
||||
|
||||
QFont font = mp_ui->material_list->font ();
|
||||
font.setWeight (QFont::Bold);
|
||||
mp_ui->material_list->setFont (font);
|
||||
|
||||
mp_ui->material_list->addAction (mp_ui->select_all_action);
|
||||
mp_ui->material_list->addAction (mp_ui->unselect_all_action);
|
||||
mp_ui->material_list->addAction (mp_ui->show_all_action);
|
||||
mp_ui->material_list->addAction (mp_ui->show_selected_action);
|
||||
mp_ui->material_list->addAction (mp_ui->hide_all_action);
|
||||
mp_ui->material_list->addAction (mp_ui->hide_selected_action);
|
||||
mp_ui->material_list->setContextMenuPolicy (Qt::ActionsContextMenu);
|
||||
|
||||
connect (mp_ui->material_list, SIGNAL (itemChanged (QListWidgetItem *)), this, SLOT (material_item_changed (QListWidgetItem *)));
|
||||
}
|
||||
|
||||
D25View::~D25View ()
|
||||
|
|
@ -92,7 +117,7 @@ D25View::cellviews_changed ()
|
|||
void
|
||||
D25View::layer_properties_changed (int)
|
||||
{
|
||||
// @@@ mp_ui->d25_view->refresh_view ();
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -196,6 +221,35 @@ D25View::entry (const db::Region &data, double dbu, double zstart, double zstop)
|
|||
}
|
||||
}
|
||||
|
||||
static void layer_info_to_item (const lay::D25ViewWidget::LayerInfo &info, QListWidgetItem *item, size_t index, QSize icon_size)
|
||||
{
|
||||
if (info.has_name) {
|
||||
item->setText (tl::to_qstring (info.name));
|
||||
} else {
|
||||
item->setText (tl::to_qstring ("#" + tl::to_string (index + 1)));
|
||||
}
|
||||
|
||||
QImage img (icon_size, QImage::Format_ARGB32);
|
||||
img.fill (QColor (floor (info.fill_color [0] * 255 + 0.5), floor (info.fill_color [1] * 255 + 0.5), floor (info.fill_color [2] * 255 + 0.5), floor (info.fill_color [3] * 255 + 0.5)));
|
||||
|
||||
QColor fc (floor (info.frame_color [0] * 255 + 0.5), floor (info.frame_color [1] * 255 + 0.5), floor (info.frame_color [2] * 255 + 0.5), floor (info.frame_color [3] * 255 + 0.5));
|
||||
if (fc.alpha () > 0) {
|
||||
QRgb fc_rgb = fc.rgba ();
|
||||
for (int x = 0; x < icon_size.width (); ++x) {
|
||||
img.setPixel (x, 0, fc_rgb);
|
||||
img.setPixel (x, icon_size.height () - 1, fc_rgb);
|
||||
}
|
||||
for (int y = 0; y < icon_size.height (); ++y) {
|
||||
img.setPixel (0, y, fc_rgb);
|
||||
img.setPixel (icon_size.width () - 1, y, fc_rgb);
|
||||
}
|
||||
}
|
||||
|
||||
QIcon icon;
|
||||
icon.addPixmap (QPixmap::fromImage (img));
|
||||
item->setIcon (icon);
|
||||
}
|
||||
|
||||
void
|
||||
D25View::finish ()
|
||||
{
|
||||
|
|
@ -203,7 +257,19 @@ D25View::finish ()
|
|||
|
||||
mp_ui->d25_view->finish ();
|
||||
|
||||
// @@@ install layer properties widget
|
||||
QFontMetrics fm (mp_ui->material_list->font ());
|
||||
QSize icon_size = fm.size (Qt::TextSingleLine, "WW");
|
||||
icon_size.setHeight (icon_size.height () - 2);
|
||||
mp_ui->material_list->setIconSize (icon_size);
|
||||
|
||||
mp_ui->material_list->clear ();
|
||||
const std::vector<lay::D25ViewWidget::LayerInfo> &layers = mp_ui->d25_view->layers ();
|
||||
for (auto l = layers.begin (); l != layers.end (); ++l) {
|
||||
QListWidgetItem *item = new QListWidgetItem (mp_ui->material_list);
|
||||
item->setFlags (item->flags () | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState (Qt::Checked);
|
||||
layer_info_to_item (*l, item, l - layers.begin (), icon_size);
|
||||
}
|
||||
|
||||
mp_ui->d25_view->reset ();
|
||||
mp_ui->d25_view->set_cam_azimuth (0.0);
|
||||
|
|
@ -298,6 +364,15 @@ D25View::vscale_factor_changed (double f)
|
|||
mp_ui->vzoom_slider->blockSignals (false);
|
||||
}
|
||||
|
||||
void
|
||||
D25View::material_item_changed (QListWidgetItem *item)
|
||||
{
|
||||
int index = mp_ui->material_list->row (item);
|
||||
if (index >= 0) {
|
||||
mp_ui->d25_view->set_material_visible (size_t (index), item->checkState () == Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::deactivated ()
|
||||
{
|
||||
|
|
@ -366,6 +441,42 @@ D25View::fit_button_clicked ()
|
|||
mp_ui->d25_view->fit ();
|
||||
}
|
||||
|
||||
void
|
||||
D25View::hide_all_triggered ()
|
||||
{
|
||||
for (int i = 0; i < mp_ui->material_list->count (); ++i) {
|
||||
mp_ui->material_list->item (i)->setCheckState (Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::hide_selected_triggered ()
|
||||
{
|
||||
for (int i = 0; i < mp_ui->material_list->count (); ++i) {
|
||||
if (mp_ui->material_list->item (i)->isSelected ()) {
|
||||
mp_ui->material_list->item (i)->setCheckState (Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::show_all_triggered ()
|
||||
{
|
||||
for (int i = 0; i < mp_ui->material_list->count (); ++i) {
|
||||
mp_ui->material_list->item (i)->setCheckState (Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::show_selected_triggered ()
|
||||
{
|
||||
for (int i = 0; i < mp_ui->material_list->count (); ++i) {
|
||||
if (mp_ui->material_list->item (i)->isSelected ()) {
|
||||
mp_ui->material_list->item (i)->setCheckState (Qt::Checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::accept ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#define HDR_layD25View
|
||||
|
||||
#include <QDialog>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
#include "tlObject.h"
|
||||
#include "layBrowser.h"
|
||||
|
|
@ -84,6 +85,11 @@ private slots:
|
|||
void vscale_value_edited ();
|
||||
void init_failed ();
|
||||
void rerun_button_pressed ();
|
||||
void material_item_changed (QListWidgetItem *);
|
||||
void hide_all_triggered ();
|
||||
void hide_selected_triggered ();
|
||||
void show_all_triggered ();
|
||||
void show_selected_triggered ();
|
||||
|
||||
private:
|
||||
Ui::D25View *mp_ui;
|
||||
|
|
|
|||
|
|
@ -481,6 +481,15 @@ D25ViewWidget::refresh ()
|
|||
update ();
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::set_material_visible (size_t index, bool visible)
|
||||
{
|
||||
if (index < m_layers.size () && m_layers [index].visible != visible) {
|
||||
m_layers [index].visible = visible;
|
||||
update ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::showEvent (QShowEvent *)
|
||||
{
|
||||
|
|
@ -551,7 +560,7 @@ static void lp_to_info (const lay::LayerPropertiesNode &lp, D25ViewWidget::Layer
|
|||
info.frame_color [3] = 0.0f;
|
||||
}
|
||||
|
||||
info.visible = lp.visible (true);
|
||||
info.visible = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -149,6 +149,13 @@ public:
|
|||
return m_has_error;
|
||||
}
|
||||
|
||||
const std::vector<LayerInfo> &layers () const
|
||||
{
|
||||
return m_layers;
|
||||
}
|
||||
|
||||
void set_material_visible (size_t index, bool visible);
|
||||
|
||||
void clear ();
|
||||
void open_display (const color_t *frame_color, const color_t *fill_color, const db::LayerProperties *like, const std::string *name);
|
||||
void close_display ();
|
||||
|
|
|
|||
Loading…
Reference in New Issue