mirror of https://github.com/KLayout/klayout.git
Refined solution
This commit is contained in:
parent
f9899efea3
commit
b92c7bf225
|
|
@ -28,6 +28,7 @@
|
|||
#include "layLayoutViewBase.h"
|
||||
#include "layDitherPattern.h"
|
||||
#include "layLineStyles.h"
|
||||
#include "layMarker.h"
|
||||
#include "dbSaveLayoutOptions.h"
|
||||
#include "dbLayoutToNetlist.h"
|
||||
#include "dbLayoutVsSchematic.h"
|
||||
|
|
@ -469,15 +470,16 @@ static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutViewBase *vie
|
|||
return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index));
|
||||
}
|
||||
|
||||
static void add_object (lay::LayoutViewBase *view, lay::ViewObject *object)
|
||||
static void add_marker (lay::LayoutViewBase *view, lay::ManagedDMarker *object)
|
||||
{
|
||||
if (view->canvas ()) {
|
||||
view->canvas ()->add_object (object);
|
||||
}
|
||||
}
|
||||
|
||||
static void clear_objects (lay::LayoutViewBase *view)
|
||||
static void clear_markers (lay::LayoutViewBase *view)
|
||||
{
|
||||
// NOTE: this will clear *all* persistent objects, not just our markers
|
||||
if (view->canvas ()) {
|
||||
view->canvas ()->clear_objects ();
|
||||
}
|
||||
|
|
@ -693,7 +695,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase ("lay", "LayoutVi
|
|||
"\n"
|
||||
"In 0.25, this method has been moved from MainWindow to LayoutView.\n"
|
||||
) +
|
||||
gsi::method_ext ("add_marker", &add_object, gsi::arg ("marker"),
|
||||
gsi::method_ext ("add_marker", &add_marker, gsi::arg ("marker"),
|
||||
"@brief Adds a persistent marker to the view (transferring ownership)\n"
|
||||
"\n"
|
||||
"This method allows creating markers and transferring ownership to the view, hence making them persistent. "
|
||||
|
|
@ -711,7 +713,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase ("lay", "LayoutVi
|
|||
"\n"
|
||||
"Persistent markers have been introduced in version 0.29.3\n"
|
||||
) +
|
||||
gsi::method_ext ("clear_markers", &clear_objects,
|
||||
gsi::method_ext ("clear_markers", &clear_markers,
|
||||
"@brief Clears all persistent markers from the view\n"
|
||||
"See \\add_marker for details about persistent markers.\n"
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -28,56 +28,44 @@
|
|||
namespace gsi
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A managed version of the marker class
|
||||
*/
|
||||
class ManagedDMarker
|
||||
: public lay::DMarker, public gsi::ObjectBase
|
||||
{
|
||||
public:
|
||||
ManagedDMarker (lay::LayoutViewBase *view)
|
||||
: lay::DMarker (view)
|
||||
{ }
|
||||
};
|
||||
|
||||
static
|
||||
lay::DMarker *create_marker (lay::LayoutViewBase *view)
|
||||
lay::ManagedDMarker *create_marker (lay::LayoutViewBase *view)
|
||||
{
|
||||
return new ManagedDMarker (view);
|
||||
return new lay::ManagedDMarker (view);
|
||||
}
|
||||
|
||||
static
|
||||
void reset_frame_color (ManagedDMarker *marker)
|
||||
void reset_frame_color (lay::ManagedDMarker *marker)
|
||||
{
|
||||
marker->set_frame_color (tl::Color ());
|
||||
}
|
||||
|
||||
static
|
||||
void set_frame_color (ManagedDMarker *marker, unsigned int color)
|
||||
void set_frame_color (lay::ManagedDMarker *marker, unsigned int color)
|
||||
{
|
||||
marker->set_frame_color (tl::Color (color));
|
||||
}
|
||||
|
||||
static
|
||||
unsigned int get_frame_color (const ManagedDMarker *marker)
|
||||
unsigned int get_frame_color (const lay::ManagedDMarker *marker)
|
||||
{
|
||||
return marker->get_frame_color ().rgb ();
|
||||
}
|
||||
|
||||
static
|
||||
bool has_frame_color (const ManagedDMarker *marker)
|
||||
bool has_frame_color (const lay::ManagedDMarker *marker)
|
||||
{
|
||||
return marker->get_frame_color ().is_valid ();
|
||||
}
|
||||
|
||||
static
|
||||
void reset_color (ManagedDMarker *marker)
|
||||
void reset_color (lay::ManagedDMarker *marker)
|
||||
{
|
||||
marker->set_color (tl::Color ());
|
||||
}
|
||||
|
||||
static
|
||||
void set_color (ManagedDMarker *marker, unsigned int color)
|
||||
void set_color (lay::ManagedDMarker *marker, unsigned int color)
|
||||
{
|
||||
marker->set_color (tl::Color (color));
|
||||
}
|
||||
|
|
@ -89,12 +77,12 @@ unsigned int get_color (const lay::DMarker *marker)
|
|||
}
|
||||
|
||||
static
|
||||
bool has_color (const ManagedDMarker *marker)
|
||||
bool has_color (const lay::ManagedDMarker *marker)
|
||||
{
|
||||
return marker->get_color ().is_valid ();
|
||||
}
|
||||
|
||||
Class<ManagedDMarker> decl_Marker ("lay", "Marker",
|
||||
Class<lay::ManagedDMarker> decl_Marker ("lay", "Marker",
|
||||
gsi::constructor ("new", &create_marker, gsi::arg ("view", (lay::LayoutViewBase *) 0, "nil"),
|
||||
"@brief Creates a marker\n"
|
||||
"\n"
|
||||
|
|
@ -105,32 +93,32 @@ Class<ManagedDMarker> decl_Marker ("lay", "Marker",
|
|||
"\n"
|
||||
"The 'view' argument is optional since version 0.29.3."
|
||||
) +
|
||||
gsi::method ("set|set_box", (void (ManagedDMarker::*) (const db::DBox &)) &ManagedDMarker::set, gsi::arg ("box"),
|
||||
gsi::method ("set|set_box", (void (lay::ManagedDMarker::*) (const db::DBox &)) &lay::ManagedDMarker::set, gsi::arg ("box"),
|
||||
"@brief Sets the box the marker is to display\n"
|
||||
"\n"
|
||||
"Makes the marker show a box. The box must be given in micron units.\n"
|
||||
"If the box is empty, no marker is drawn.\n"
|
||||
"The set method has been added in version 0.20.\n"
|
||||
) +
|
||||
gsi::method ("set|set_text", (void (ManagedDMarker::*) (const db::DText &)) &ManagedDMarker::set, gsi::arg ("text"),
|
||||
gsi::method ("set|set_text", (void (lay::ManagedDMarker::*) (const db::DText &)) &lay::ManagedDMarker::set, gsi::arg ("text"),
|
||||
"@brief Sets the text the marker is to display\n"
|
||||
"\n"
|
||||
"Makes the marker show a text. The text must be given in micron units.\n"
|
||||
"The set method has been added in version 0.20.\n"
|
||||
) +
|
||||
gsi::method ("set|set_edge", (void (ManagedDMarker::*) (const db::DEdge &)) &ManagedDMarker::set, gsi::arg ("edge"),
|
||||
gsi::method ("set|set_edge", (void (lay::ManagedDMarker::*) (const db::DEdge &)) &lay::ManagedDMarker::set, gsi::arg ("edge"),
|
||||
"@brief Sets the edge the marker is to display\n"
|
||||
"\n"
|
||||
"Makes the marker show a edge. The edge must be given in micron units.\n"
|
||||
"The set method has been added in version 0.20.\n"
|
||||
) +
|
||||
gsi::method ("set|set_path", (void (ManagedDMarker::*) (const db::DPath &)) &ManagedDMarker::set, gsi::arg ("path"),
|
||||
gsi::method ("set|set_path", (void (lay::ManagedDMarker::*) (const db::DPath &)) &lay::ManagedDMarker::set, gsi::arg ("path"),
|
||||
"@brief Sets the path the marker is to display\n"
|
||||
"\n"
|
||||
"Makes the marker show a path. The path must be given in micron units.\n"
|
||||
"The set method has been added in version 0.20.\n"
|
||||
) +
|
||||
gsi::method ("set|set_polygon", (void (ManagedDMarker::*) (const db::DPolygon &)) &ManagedDMarker::set, gsi::arg ("polygon"),
|
||||
gsi::method ("set|set_polygon", (void (lay::ManagedDMarker::*) (const db::DPolygon &)) &lay::ManagedDMarker::set, gsi::arg ("polygon"),
|
||||
"@brief Sets the polygon the marker is to display\n"
|
||||
"\n"
|
||||
"Makes the marker show a polygon. The polygon must be given in micron units.\n"
|
||||
|
|
@ -172,59 +160,59 @@ Class<ManagedDMarker> decl_Marker ("lay", "Marker",
|
|||
"@brief Returns a value indicating whether the marker has a specific frame color\n"
|
||||
"The set method has been added in version 0.20.\n"
|
||||
) +
|
||||
gsi::method ("dismissable=", (void (ManagedDMarker::*) (bool)) &ManagedDMarker::set_dismissable, gsi::arg ("flag"),
|
||||
gsi::method ("dismissable=", (void (lay::ManagedDMarker::*) (bool)) &lay::ManagedDMarker::set_dismissable, gsi::arg ("flag"),
|
||||
"@brief Sets a value indicating whether the marker can be hidden\n"
|
||||
"Dismissable markers can be hidden setting \"View/Show Markers\" to \"off\". "
|
||||
"The default setting is \"false\" meaning the marker can't be hidden.\n"
|
||||
"\n"
|
||||
"This attribute has been introduced in version 0.25.4."
|
||||
) +
|
||||
gsi::method ("dismissable?", (bool (ManagedDMarker::*) () const) &ManagedDMarker::get_dismissable,
|
||||
gsi::method ("dismissable?", (bool (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::get_dismissable,
|
||||
"@brief Gets a value indicating whether the marker can be hidden\n"
|
||||
"See \\dismissable= for a description of this predicate."
|
||||
) +
|
||||
gsi::method ("line_width=", (void (ManagedDMarker::*) (int)) &ManagedDMarker::set_line_width, gsi::arg ("width"),
|
||||
gsi::method ("line_width=", (void (lay::ManagedDMarker::*) (int)) &lay::ManagedDMarker::set_line_width, gsi::arg ("width"),
|
||||
"@brief Sets the line width of the marker\n"
|
||||
"This is the width of the line drawn for the outline of the marker."
|
||||
) +
|
||||
gsi::method ("line_width", (int (ManagedDMarker::*) () const) &ManagedDMarker::get_line_width,
|
||||
gsi::method ("line_width", (int (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::get_line_width,
|
||||
"@brief Gets the line width of the marker\n"
|
||||
"See \\line_width= for a description of the line width."
|
||||
) +
|
||||
gsi::method ("vertex_size=", (void (ManagedDMarker::*) (int)) &ManagedDMarker::set_vertex_size, gsi::arg ("size"),
|
||||
gsi::method ("vertex_size=", (void (lay::ManagedDMarker::*) (int)) &lay::ManagedDMarker::set_vertex_size, gsi::arg ("size"),
|
||||
"@brief Sets the vertex size of the marker\n"
|
||||
"This is the size of the rectangles drawn for the vertices object."
|
||||
) +
|
||||
gsi::method ("vertex_size", (int (ManagedDMarker::*) () const) &ManagedDMarker::get_vertex_size,
|
||||
gsi::method ("vertex_size", (int (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::get_vertex_size,
|
||||
"@brief Gets the vertex size of the marker\n"
|
||||
"See \\vertex_size= for a description."
|
||||
) +
|
||||
gsi::method ("halo=", (void (ManagedDMarker::*) (int)) &ManagedDMarker::set_halo, gsi::arg ("halo"),
|
||||
gsi::method ("halo=", (void (lay::ManagedDMarker::*) (int)) &lay::ManagedDMarker::set_halo, gsi::arg ("halo"),
|
||||
"@brief Sets the halo flag\n"
|
||||
"The halo flag is either -1 (for taking the default), 0 to disable the halo or 1 to enable it. "
|
||||
"If the halo is enabled, a pixel border with the background color is drawn around the marker, the "
|
||||
"vertices and texts."
|
||||
) +
|
||||
gsi::method ("halo", (int (ManagedDMarker::*) () const) &ManagedDMarker::get_halo,
|
||||
gsi::method ("halo", (int (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::get_halo,
|
||||
"@brief Gets the halo flag\n"
|
||||
"See \\halo= for a description of the halo flag."
|
||||
) +
|
||||
gsi::method ("dither_pattern=", (void (ManagedDMarker::*) (int)) &ManagedDMarker::set_dither_pattern, gsi::arg ("index"),
|
||||
gsi::method ("dither_pattern=", (void (lay::ManagedDMarker::*) (int)) &lay::ManagedDMarker::set_dither_pattern, gsi::arg ("index"),
|
||||
"@brief Sets the stipple pattern index\n"
|
||||
"A value of -1 or less than zero indicates that the marker is not filled. Otherwise, the "
|
||||
"value indicates which pattern to use for filling the marker."
|
||||
) +
|
||||
gsi::method ("dither_pattern", (int (ManagedDMarker::*) () const) &ManagedDMarker::get_dither_pattern,
|
||||
gsi::method ("dither_pattern", (int (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::get_dither_pattern,
|
||||
"@brief Gets the stipple pattern index\n"
|
||||
"See \\dither_pattern= for a description of the stipple pattern index."
|
||||
) +
|
||||
gsi::method ("line_style=", (void (ManagedDMarker::*) (int)) &ManagedDMarker::set_line_style, gsi::arg ("index"),
|
||||
gsi::method ("line_style=", (void (lay::ManagedDMarker::*) (int)) &lay::ManagedDMarker::set_line_style, gsi::arg ("index"),
|
||||
"@brief Sets the line style\n"
|
||||
"The line style is given by an index. 0 is solid, 1 is dashed and so forth.\n"
|
||||
"\n"
|
||||
"This method has been introduced in version 0.25."
|
||||
) +
|
||||
gsi::method ("line_style", (int (ManagedDMarker::*) () const) &ManagedDMarker::get_line_style,
|
||||
gsi::method ("line_style", (int (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::get_line_style,
|
||||
"@brief Get the line style\n"
|
||||
"See \\line_style= for a description of the line style index."
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include "dbEdgePair.h"
|
||||
#include "dbArray.h"
|
||||
#include "gsi.h"
|
||||
#include "gsiObject.h"
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
|
@ -831,6 +832,21 @@ private:
|
|||
lay::LayoutViewBase *mp_view;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A managed version of the marker class
|
||||
*
|
||||
* It uses gsi::ObjectBase as a base class and serves as
|
||||
* proxy for GSI binding.
|
||||
*/
|
||||
class ManagedDMarker
|
||||
: public lay::DMarker, public gsi::ObjectBase
|
||||
{
|
||||
public:
|
||||
ManagedDMarker (lay::LayoutViewBase *view)
|
||||
: lay::DMarker (view)
|
||||
{ }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -77,6 +77,29 @@ class LAYMarkers_TestClass < TestBase
|
|||
|
||||
end
|
||||
|
||||
# persistent markers
|
||||
def test_2
|
||||
|
||||
if !RBA.constants.member?(:Application)
|
||||
return
|
||||
end
|
||||
|
||||
app = RBA::Application.instance
|
||||
mw = app.main_window
|
||||
mw.create_layout(0)
|
||||
cv = mw.current_view
|
||||
|
||||
m = RBA::Marker.new
|
||||
m.set(RBA::DBox.new(1, 2, 3, 4))
|
||||
m.vertex_size = 3
|
||||
cv.add_marker(m)
|
||||
|
||||
cv.clear_markers
|
||||
|
||||
assert_equal(m.destroyed?, true)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
load("test_epilogue.rb")
|
||||
|
|
|
|||
Loading…
Reference in New Issue