mirror of https://github.com/KLayout/klayout.git
'tap' now changes the current layer while editing and also initiates polygons, paths and boxes.
This commit is contained in:
parent
1887fd715a
commit
5bd73bb8bf
|
|
@ -1997,9 +1997,16 @@ MainService::cm_tap ()
|
|||
|
||||
QAction *action = menu->exec (mp);
|
||||
if (action) {
|
||||
|
||||
int index = action->data ().toInt ();
|
||||
lay::LayerPropertiesConstIterator iter = tapped_layers [index];
|
||||
view ()->set_current_layer (iter);
|
||||
|
||||
edt::Service *es = dynamic_cast<edt::Service *> (view ()->view_object_widget ()->active_service ());
|
||||
if (es) {
|
||||
es->tap (pt);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -710,8 +710,7 @@ Service::mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio)
|
|||
// in this mode, ignore exceptions here since it is rather annoying to have messages popping
|
||||
// up then.
|
||||
try {
|
||||
do_begin_edit (p);
|
||||
m_editing = true;
|
||||
begin_edit (p);
|
||||
} catch (...) {
|
||||
set_edit_marker (0);
|
||||
}
|
||||
|
|
@ -744,8 +743,7 @@ Service::mouse_press_event (const db::DPoint &p, unsigned int buttons, bool prio
|
|||
|
||||
view ()->cancel (); // cancel any pending edit operations and clear the selection
|
||||
set_edit_marker (0);
|
||||
do_begin_edit (p);
|
||||
m_editing = true;
|
||||
begin_edit (p);
|
||||
|
||||
} else {
|
||||
if (do_mouse_click (p)) {
|
||||
|
|
@ -1432,6 +1430,19 @@ Service::move_markers (const db::DTrans &t)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Service::begin_edit (const db::DPoint &p)
|
||||
{
|
||||
do_begin_edit (p);
|
||||
m_editing = true;
|
||||
}
|
||||
|
||||
void
|
||||
Service::tap (const db::DPoint & /*initial*/)
|
||||
{
|
||||
// .. nothing here ..
|
||||
}
|
||||
|
||||
void
|
||||
Service::selection_to_view ()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,6 +44,10 @@
|
|||
#include <vector>
|
||||
#include <QColor>
|
||||
|
||||
namespace lay {
|
||||
class LayerPropertiesConstIterator;
|
||||
}
|
||||
|
||||
namespace edt {
|
||||
|
||||
class Service;
|
||||
|
|
@ -344,6 +348,11 @@ public:
|
|||
*/
|
||||
virtual void edit_cancel ();
|
||||
|
||||
/**
|
||||
* @brief Triggered by tap - gives the new layer and if required the initial point
|
||||
*/
|
||||
virtual void tap (const db::DPoint &initial);
|
||||
|
||||
/**
|
||||
* @brief Delete the selected rulers
|
||||
*
|
||||
|
|
@ -383,6 +392,11 @@ protected:
|
|||
*/
|
||||
void selection_to_view ();
|
||||
|
||||
/**
|
||||
* @brief starts editing at the given point.
|
||||
*/
|
||||
void begin_edit (const db::DPoint &p);
|
||||
|
||||
/**
|
||||
* @brief Reimplemented by the specific implementation of the shape editors
|
||||
*
|
||||
|
|
@ -528,6 +542,11 @@ protected:
|
|||
return m_max_shapes_of_instances;
|
||||
}
|
||||
|
||||
bool editing () const
|
||||
{
|
||||
return m_editing;
|
||||
}
|
||||
|
||||
private:
|
||||
// The layout view that the editor service is attached to
|
||||
lay::LayoutView *mp_view;
|
||||
|
|
|
|||
|
|
@ -69,17 +69,18 @@ void
|
|||
ShapeEditService::get_edit_layer ()
|
||||
{
|
||||
lay::LayerPropertiesConstIterator cl = view ()->current_layer ();
|
||||
|
||||
if (cl.is_null ()) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Please select a layer first")));
|
||||
}
|
||||
|
||||
if (! cl->visible (true)) {
|
||||
lay::TipDialog td (QApplication::activeWindow (),
|
||||
tl::to_string (QObject::tr ("You are about to draw on a hidden layer. The result won't be visible.")),
|
||||
tl::to_string (QObject::tr ("You are about to draw on a hidden layer. The result won't be visible.")),
|
||||
"drawing-on-invisible-layer");
|
||||
td.exec_dialog ();
|
||||
}
|
||||
|
||||
|
||||
int cv_index = cl->cellview_index ();
|
||||
const lay::CellView &cv = view ()->cellview (cv_index);
|
||||
int layer = cl->layer_index ();
|
||||
|
|
@ -128,6 +129,16 @@ ShapeEditService::get_edit_layer ()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
ShapeEditService::tap (const db::DPoint &initial)
|
||||
{
|
||||
if (editing ()) {
|
||||
get_edit_layer ();
|
||||
} else {
|
||||
begin_edit (initial);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deliver a good interpolation between two points m and p
|
||||
*
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
namespace lay
|
||||
{
|
||||
class CellView;
|
||||
class LayerPropertiesConstIterator;
|
||||
}
|
||||
|
||||
namespace edt
|
||||
|
|
@ -57,10 +58,11 @@ protected:
|
|||
db::Cell &cell () const { return *mp_cell; }
|
||||
db::Layout &layout () const { return *mp_layout; }
|
||||
|
||||
void do_mouse_move_inactive (const db::DPoint &p);
|
||||
virtual void do_mouse_move_inactive (const db::DPoint &p);
|
||||
virtual void tap (const db::DPoint &initial);
|
||||
|
||||
virtual bool configure (const std::string &name, const std::string &value);
|
||||
|
||||
bool configure (const std::string &name, const std::string &value);
|
||||
|
||||
protected:
|
||||
std::pair <bool, db::DPoint> interpolate (const db::DPoint &m, const db::DPoint &o, const db::DPoint &p) const;
|
||||
void deliver_shape (const db::Polygon &poly);
|
||||
|
|
|
|||
Loading…
Reference in New Issue