mirror of https://github.com/KLayout/klayout.git
Live updates of layer properties
This commit is contained in:
parent
df4e6ce262
commit
464bb75626
|
|
@ -60,12 +60,31 @@ D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view)
|
||||||
mp_ui->gl_stack->setCurrentIndex (0);
|
mp_ui->gl_stack->setCurrentIndex (0);
|
||||||
|
|
||||||
lay::activate_help_links (mp_ui->doc_label);
|
lay::activate_help_links (mp_ui->doc_label);
|
||||||
|
|
||||||
|
view->cellviews_changed_event.add (this, &D25View::cellviews_changed);
|
||||||
|
view->layer_list_changed_event.add (this, &D25View::layer_properties_changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
D25View::~D25View ()
|
D25View::~D25View ()
|
||||||
{
|
{
|
||||||
delete mp_ui;
|
delete mp_ui;
|
||||||
mp_ui = 0;
|
mp_ui = 0;
|
||||||
|
|
||||||
|
if (view ()) {
|
||||||
|
view ()->cellviews_changed_event.remove (this, &D25View::cellviews_changed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
D25View::cellviews_changed ()
|
||||||
|
{
|
||||||
|
deactivate ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
D25View::layer_properties_changed (int)
|
||||||
|
{
|
||||||
|
mp_ui->d25_view->refresh_view ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,9 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::D25View *mp_ui;
|
Ui::D25View *mp_ui;
|
||||||
|
|
||||||
|
void cellviews_changed ();
|
||||||
|
void layer_properties_changed (int);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -571,10 +571,19 @@ namespace {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void color_to_gl (color_t color, GLfloat (&gl_color) [4])
|
||||||
|
{
|
||||||
|
gl_color[0] = ((color >> 16) & 0xff) / 255.0f;
|
||||||
|
gl_color[1] = ((color >> 8) & 0xff) / 255.0f;
|
||||||
|
gl_color[2] = (color & 0xff) / 255.0f;
|
||||||
|
gl_color[3] = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
D25ViewWidget::prepare_view ()
|
D25ViewWidget::prepare_view ()
|
||||||
{
|
{
|
||||||
m_layers.clear ();
|
m_layers.clear ();
|
||||||
|
m_layer_to_info.clear ();
|
||||||
m_vertex_chunks.clear ();
|
m_vertex_chunks.clear ();
|
||||||
|
|
||||||
bool zset = false;
|
bool zset = false;
|
||||||
|
|
@ -594,7 +603,7 @@ D25ViewWidget::prepare_view ()
|
||||||
for (lay::LayerPropertiesConstIterator lp = mp_view->begin_layers (); ! lp.at_end (); ++lp) {
|
for (lay::LayerPropertiesConstIterator lp = mp_view->begin_layers (); ! lp.at_end (); ++lp) {
|
||||||
|
|
||||||
std::vector<db::D25LayerInfo> zinfo;
|
std::vector<db::D25LayerInfo> zinfo;
|
||||||
if (! lp->has_children () && lp->visible (true)) {
|
if (! lp->has_children ()) {
|
||||||
zinfo = zdata (mp_view, lp->cellview_index (), lp->layer_index ());
|
zinfo = zdata (mp_view, lp->cellview_index (), lp->layer_index ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -617,7 +626,7 @@ D25ViewWidget::prepare_view ()
|
||||||
for (lay::LayerPropertiesConstIterator lp = mp_view->begin_layers (); ! lp.at_end (); ++lp) {
|
for (lay::LayerPropertiesConstIterator lp = mp_view->begin_layers (); ! lp.at_end (); ++lp) {
|
||||||
|
|
||||||
std::vector<db::D25LayerInfo> zinfo;
|
std::vector<db::D25LayerInfo> zinfo;
|
||||||
if (! lp->has_children () && lp->visible (true)) {
|
if (! lp->has_children ()) {
|
||||||
zinfo = zdata (mp_view, lp->cellview_index (), lp->layer_index ());
|
zinfo = zdata (mp_view, lp->cellview_index (), lp->layer_index ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -633,11 +642,11 @@ D25ViewWidget::prepare_view ()
|
||||||
m_vertex_chunks.push_back (chunks_type ());
|
m_vertex_chunks.push_back (chunks_type ());
|
||||||
|
|
||||||
LayerInfo info;
|
LayerInfo info;
|
||||||
info.color[0] = ((color >> 16) & 0xff) / 255.0f;
|
color_to_gl (color, info.color);
|
||||||
info.color[1] = ((color >> 8) & 0xff) / 255.0f;
|
|
||||||
info.color[2] = (color & 0xff) / 255.0f;
|
|
||||||
info.vertex_chunk = &m_vertex_chunks.back ();
|
info.vertex_chunk = &m_vertex_chunks.back ();
|
||||||
|
info.visible = lp->visible (true);
|
||||||
|
|
||||||
|
m_layer_to_info [std::make_pair (lp->cellview_index (), lp->layer_index ())] = m_layers.size ();
|
||||||
m_layers.push_back (info);
|
m_layers.push_back (info);
|
||||||
|
|
||||||
const lay::CellView &cv = mp_view->cellview ((unsigned int) lp->cellview_index ());
|
const lay::CellView &cv = mp_view->cellview ((unsigned int) lp->cellview_index ());
|
||||||
|
|
@ -660,6 +669,34 @@ D25ViewWidget::prepare_view ()
|
||||||
return any;
|
return any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
D25ViewWidget::refresh_view ()
|
||||||
|
{
|
||||||
|
if (! mp_view) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (lay::LayerPropertiesConstIterator lp = mp_view->begin_layers (); ! lp.at_end (); ++lp) {
|
||||||
|
|
||||||
|
std::map<std::pair<size_t, size_t>, size_t>::const_iterator l = m_layer_to_info.find (std::make_pair (lp->cellview_index (), lp->layer_index ()));
|
||||||
|
if (l != m_layer_to_info.end ()) {
|
||||||
|
|
||||||
|
if (l->second < m_layers.size ()) {
|
||||||
|
|
||||||
|
LayerInfo &info = m_layers [l->second];
|
||||||
|
|
||||||
|
color_to_gl (lp->fill_color (true), info.color);
|
||||||
|
info.visible = lp->visible (true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
D25ViewWidget::render_polygon (D25ViewWidget::chunks_type &chunks, const db::Polygon &poly, double dbu, double zstart, double zstop)
|
D25ViewWidget::render_polygon (D25ViewWidget::chunks_type &chunks, const db::Polygon &poly, double dbu, double zstart, double zstop)
|
||||||
{
|
{
|
||||||
|
|
@ -986,9 +1023,11 @@ D25ViewWidget::paintGL ()
|
||||||
glEnable (GL_DEPTH_TEST);
|
glEnable (GL_DEPTH_TEST);
|
||||||
glEnableVertexAttribArray (positions);
|
glEnableVertexAttribArray (positions);
|
||||||
|
|
||||||
for (std::list<LayerInfo>::const_iterator l = m_layers.begin (); l != m_layers.end (); ++l) {
|
for (std::vector<LayerInfo>::const_iterator l = m_layers.begin (); l != m_layers.end (); ++l) {
|
||||||
m_shapes_program->setUniformValue ("color", l->color [0], l->color [1], l->color [2], l->color [3]);
|
if (l->visible) {
|
||||||
l->vertex_chunk->draw_to (this, positions, GL_TRIANGLES);
|
m_shapes_program->setUniformValue ("color", l->color [0], l->color [1], l->color [2], l->color [3]);
|
||||||
|
l->vertex_chunk->draw_to (this, positions, GL_TRIANGLES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisableVertexAttribArray (positions);
|
glDisableVertexAttribArray (positions);
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ public:
|
||||||
void mouseMoveEvent (QMouseEvent *event);
|
void mouseMoveEvent (QMouseEvent *event);
|
||||||
|
|
||||||
bool attach_view(lay::LayoutView *view);
|
bool attach_view(lay::LayoutView *view);
|
||||||
|
void refresh_view ();
|
||||||
|
|
||||||
QVector3D hit_point_with_scene(const QVector3D &line_dir);
|
QVector3D hit_point_with_scene(const QVector3D &line_dir);
|
||||||
void refresh ();
|
void refresh ();
|
||||||
|
|
@ -158,9 +159,11 @@ private:
|
||||||
struct LayerInfo {
|
struct LayerInfo {
|
||||||
const chunks_type *vertex_chunk;
|
const chunks_type *vertex_chunk;
|
||||||
GLfloat color [4];
|
GLfloat color [4];
|
||||||
|
bool visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::list<LayerInfo> m_layers;
|
std::vector<LayerInfo> m_layers;
|
||||||
|
std::map<std::pair<size_t, size_t>, size_t> m_layer_to_info;
|
||||||
|
|
||||||
void initializeGL ();
|
void initializeGL ();
|
||||||
void paintGL ();
|
void paintGL ();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue