Skip to content

Commit b454d2a

Browse files
author
Matthias Koefferlein
committed
Fixed issue #2201 (trace path)
* you can zoom in now to select the end point. Problem was actually that zooming in was a problem when the start point went out of the viewport In addition: * Messages are sticky now ("Click on second point") * "Esc" will cancel path trace mode * The cursor switches back to normal after tracing
1 parent 564111a commit b454d2a

File tree

7 files changed

+101
-21
lines changed

7 files changed

+101
-21
lines changed

src/edt/edt/edtService.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,13 @@ static std::string path_to_string (const db::Layout &layout, const lay::ObjectIn
13271327
void
13281328
Service::display_status (bool transient)
13291329
{
1330+
if (transient && view ()->canvas ()->begin_mouse_receivers () != view ()->canvas ()->end_mouse_receivers ()
1331+
&& (*view ()->canvas ()->begin_mouse_receivers ())->claims_message_bar ()) {
1332+
// do not display transient if there is a plugin active that has captured the mouse and claims the message bar -
1333+
// this way we can use messages in active plugins and still get visual feedback by the transient selection.
1334+
return;
1335+
}
1336+
13301337
EditableSelectionIterator r = transient ? begin_transient_selection () : begin_selection ();
13311338
EditableSelectionIterator rr = r;
13321339

src/laybasic/laybasic/layFinder.cc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int inst_point_sel_tests = 10000;
6363

6464
Finder::Finder (bool point_mode, bool top_level_sel)
6565
: m_min_level (0), m_max_level (0),
66-
mp_layout (0), mp_view (0), m_cv_index (0), m_point_mode (point_mode), m_catch_all (false), m_top_level_sel (top_level_sel)
66+
mp_layout (0), mp_view (0), m_cv_index (0), m_point_mode (point_mode), m_catch_all (false), m_consider_viewport (true), m_top_level_sel (top_level_sel)
6767
{
6868
m_distance = std::numeric_limits<double>::max ();
6969
}
@@ -482,7 +482,10 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
482482
checkpoint ();
483483

484484
// Viewport in current cell coordinate space (DBU)
485-
db::Box viewport_box = (vp * db::CplxTrans (layout ().dbu ()) * t).inverted () * db::DBox (0, 0, view ()->viewport ().width (), view ()->viewport ().height ());
485+
db::Box viewport_box;
486+
if (consider_viewport ()) {
487+
viewport_box = (vp * db::CplxTrans (layout ().dbu ()) * t).inverted () * db::DBox (0, 0, view ()->viewport ().width (), view ()->viewport ().height ());
488+
}
486489

487490
if (! m_context_layers.empty ()) {
488491

@@ -583,7 +586,7 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
583586

584587
bool any_valid_edge = m_capture_all_shapes;
585588
for (db::Shape::polygon_edge_iterator e = shape->begin_edge (); ! e.at_end (); ++e) {
586-
if ((*e).clipped (viewport_box).first) {
589+
if (viewport_box.empty () || (*e).clipped (viewport_box).first) {
587590
any_valid_edge = true;
588591
test_edge (t, *e, d, match);
589592
}
@@ -606,7 +609,7 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
606609
++pt;
607610
for (; pt != shape->end_point (); ++pt) {
608611
db::Edge e (p, *pt);
609-
if (e.clipped (viewport_box).first) {
612+
if (viewport_box.empty () || e.clipped (viewport_box).first) {
610613
any_valid_edge = true;
611614
test_edge (t, e, d, match);
612615
}
@@ -618,7 +621,7 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
618621
db::Polygon poly;
619622
shape->polygon (poly);
620623
for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) {
621-
if ((*e).clipped (viewport_box).first) {
624+
if (viewport_box.empty () || (*e).clipped (viewport_box).first) {
622625
any_valid_edge = true;
623626
test_edge (t, *e, d, match);
624627
}
@@ -651,7 +654,7 @@ ShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, const db:
651654
// convert to polygon and test those edges
652655
db::Polygon poly (box);
653656
for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) {
654-
if ((*e).clipped (viewport_box).first) {
657+
if (viewport_box.empty () || (*e).clipped (viewport_box).first) {
655658
any_valid_edge = true;
656659
test_edge (t, *e, d, match);
657660
}
@@ -819,7 +822,10 @@ InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const d
819822
checkpoint ();
820823

821824
// Viewport in current cell coordinate space (DBU)
822-
db::Box viewport_box = (vp * db::CplxTrans (layout ().dbu ()) * t).inverted () * db::DBox (0, 0, view ()->viewport ().width (), view ()->viewport ().height ());
825+
db::Box viewport_box;
826+
if (consider_viewport ()) {
827+
viewport_box = (vp * db::CplxTrans (layout ().dbu ()) * t).inverted () * db::DBox (0, 0, view ()->viewport ().width (), view ()->viewport ().height ());
828+
}
823829

824830
if (! point_mode ()) {
825831

@@ -952,7 +958,7 @@ InstFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, const d
952958
bool any_valid_edge = false;
953959
for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); ! e.at_end (); ++e) {
954960
// only consider edges that cut through the viewport
955-
if ((*e).clipped (viewport_box).first) {
961+
if (viewport_box.empty () || (*e).clipped (viewport_box).first) {
956962
any_valid_edge = true;
957963
test_edge (t, *e, d, match);
958964
}

src/laybasic/laybasic/layFinder.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ class LAYBASIC_PUBLIC Finder
9696
m_catch_all = f;
9797
}
9898

99+
/**
100+
* @brief Gets a flag indicating that the viewport will be considered
101+
*/
102+
bool consider_viewport () const
103+
{
104+
return m_consider_viewport;
105+
}
106+
107+
/**
108+
* @brief Sets a flag indicating that the viewport will be considered
109+
* If this flag is true (the default), only shapes and instances will be considered
110+
* if edges (or polygons) or boundary edges (for instances) are visible in the
111+
* viewport. If this flag is false, shapes or instances are considered always.
112+
*/
113+
void set_consider_viewport (bool f)
114+
{
115+
m_consider_viewport = f;
116+
}
117+
99118
/**
100119
* @brief Destructor (just provided to please the compiler)
101120
*/
@@ -217,6 +236,7 @@ class LAYBASIC_PUBLIC Finder
217236
double m_distance;
218237
bool m_point_mode;
219238
bool m_catch_all;
239+
bool m_consider_viewport;
220240
bool m_top_level_sel;
221241
db::box_convert <db::CellInst, false> m_box_convert;
222242
db::box_convert <db::Cell, false> m_cell_box_convert;

src/laybasic/laybasic/layViewObject.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -621,23 +621,18 @@ END_PROTECTED
621621
void
622622
ViewObjectUI::set_cursor (lay::Cursor::cursor_shape cursor)
623623
{
624-
m_cursor = cursor;
624+
if (m_cursor != cursor) {
625+
m_cursor = cursor;
626+
realize_cursor ();
627+
}
625628
}
626629

627630
void
628631
ViewObjectUI::set_default_cursor (lay::Cursor::cursor_shape cursor)
629632
{
630633
if (cursor != m_default_cursor) {
631634
m_default_cursor = cursor;
632-
#if defined(HAVE_QT)
633-
if (m_cursor == lay::Cursor::none && mp_widget) {
634-
if (m_default_cursor == lay::Cursor::none) {
635-
mp_widget->unsetCursor ();
636-
} else {
637-
mp_widget->setCursor (lay::Cursor::qcursor (m_default_cursor));
638-
}
639-
}
640-
#endif
635+
realize_cursor ();
641636
}
642637
}
643638

@@ -652,11 +647,17 @@ ViewObjectUI::ensure_entered ()
652647
void
653648
ViewObjectUI::begin_mouse_event (lay::Cursor::cursor_shape cursor)
654649
{
655-
m_cursor = cursor;
650+
set_cursor (cursor);
656651
}
657652

658653
void
659654
ViewObjectUI::end_mouse_event ()
655+
{
656+
realize_cursor ();
657+
}
658+
659+
void
660+
ViewObjectUI::realize_cursor ()
660661
{
661662
#if defined(HAVE_QT)
662663
if (mp_widget) {

src/laybasic/laybasic/layViewObject.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ class LAYBASIC_PUBLIC ViewService
285285
*/
286286
virtual void drag_cancel () { }
287287

288+
/**
289+
* @brief Gets a value indicating whether the mouse receiver claims the view message bar
290+
*
291+
* If this method returns true, other services are not supposed to emit transient
292+
* messages.
293+
*/
294+
virtual bool claims_message_bar () const { return false; }
295+
288296
/**
289297
* @brief Gets a value indicating whether a cursor position it set
290298
*/
@@ -1121,6 +1129,7 @@ class LAYBASIC_PUBLIC ViewObjectUI :
11211129
void objects_changed ();
11221130
int widget_height () const;
11231131
int widget_width () const;
1132+
void realize_cursor ();
11241133

11251134
/**
11261135
* @brief Register a service

src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,32 @@ NetTracerDialog::item_double_clicked (QListWidgetItem *item)
202202
}
203203
}
204204

205+
void
206+
NetTracerDialog::drag_cancel ()
207+
{
208+
if (m_mouse_state > 0) {
209+
210+
view ()->message ();
211+
ui ()->ungrab_mouse (this);
212+
set_cursor (lay::Cursor::none);
213+
214+
m_mouse_state = 0;
215+
216+
}
217+
}
218+
219+
bool
220+
NetTracerDialog::claims_message_bar () const
221+
{
222+
return true;
223+
}
224+
205225
bool
206226
NetTracerDialog::mouse_move_event (const db::DPoint & /*p*/, unsigned int /*buttons*/, bool prio)
207227
{
208228
if (prio && m_mouse_state != 0) {
209229
set_cursor (lay::Cursor::cross);
210230
}
211-
212231
return false;
213232
}
214233

@@ -397,11 +416,13 @@ NetTracerDialog::do_trace (const db::DBox &start_search_box, const db::DBox &sto
397416
{
398417
unsigned int start_layer = 0;
399418
db::Point start_point;
419+
db::Shape start_shape;
400420

401421
// locate the seed
402422
{
403423

404424
lay::ShapeFinder finder (true /*point mode*/, false /*all levels*/, db::ShapeIterator::All);
425+
finder.set_consider_viewport (false);
405426

406427
// go through all visible layers of all cellviews and find a seed shape
407428
for (lay::LayerPropertiesConstIterator lprop = view ()->begin_layers (); ! lprop.at_end (); ++lprop) {
@@ -417,7 +438,7 @@ NetTracerDialog::do_trace (const db::DBox &start_search_box, const db::DBox &sto
417438
}
418439

419440
m_cv_index = r->cv_index ();
420-
441+
start_shape = r->shape ();
421442
start_layer = r->layer ();
422443

423444
}
@@ -440,6 +461,12 @@ NetTracerDialog::do_trace (const db::DBox &start_search_box, const db::DBox &sto
440461

441462
start_point = tt.inverted ().trans (start_search_box.center ());
442463

464+
// stop if the center start point is not inside the start polygon
465+
db::Polygon poly;
466+
if (start_shape.polygon (poly) && db::inside_poly (poly.begin_edge (), start_point) < 0) {
467+
return 0;
468+
}
469+
443470
}
444471

445472
// Set up the net tracer environment
@@ -455,6 +482,7 @@ NetTracerDialog::do_trace (const db::DBox &start_search_box, const db::DBox &sto
455482
if (trace_path) {
456483

457484
lay::ShapeFinder finder (true /*point mode*/, false /*all levels*/, db::ShapeIterator::All);
485+
finder.set_consider_viewport (false);
458486

459487
// go through all visible layers of all cellviews and find a seed shape
460488
for (lay::LayerPropertiesConstIterator lprop = view ()->begin_layers (); ! lprop.at_end (); ++lprop) {
@@ -483,6 +511,12 @@ NetTracerDialog::do_trace (const db::DBox &start_search_box, const db::DBox &sto
483511
stop_point = tt.inverted ().trans (stop_search_box.center ());
484512
stop_layer = r->layer ();
485513

514+
// stop if the center stop point is not inside the stop polygon
515+
db::Polygon poly;
516+
if (r->shape ().polygon (poly) && db::inside_poly (poly.begin_edge (), stop_point) < 0) {
517+
return 0;
518+
}
519+
486520
}
487521

488522
db::NetTracer net_tracer;
@@ -1261,6 +1295,7 @@ NetTracerDialog::release_mouse ()
12611295
m_mouse_state = 0;
12621296
view ()->message ();
12631297
ui ()->ungrab_mouse (this);
1298+
set_cursor (lay::Cursor::none);
12641299
}
12651300

12661301
void

src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Q_OBJECT
6060
NetTracerDialog (lay::Dispatcher *root, lay::LayoutViewBase *view);
6161
virtual ~NetTracerDialog ();
6262

63+
virtual void drag_cancel ();
64+
virtual bool claims_message_bar () const;
6365
virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio);
6466
virtual bool mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio);
6567
virtual void menu_activated (const std::string &symbol);

0 commit comments

Comments
 (0)