mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-02 19:28:37 +02:00
WIP: introducing MacroController
The MacroController is the central facility for managing macros and their views. The plugin framework has been extended to support such a design. In addition, some small bugs have been fixed related to macro interpreters (specifically the DRC).
This commit is contained in:
@@ -664,6 +664,26 @@ void LayoutView::viewport_changed ()
|
||||
viewport_changed_event ();
|
||||
}
|
||||
|
||||
bool LayoutView::accepts_drop (const std::string &path_or_url) const
|
||||
{
|
||||
for (std::vector<lay::Plugin *>::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) {
|
||||
if ((*p)->accepts_drop (path_or_url)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void LayoutView::drop_url (const std::string &path_or_url)
|
||||
{
|
||||
for (std::vector<lay::Plugin *>::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) {
|
||||
if ((*p)->accepts_drop (path_or_url)) {
|
||||
(*p)->drop_url (path_or_url);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lay::Plugin *LayoutView::create_plugin (lay::PluginRoot *root, const lay::PluginDeclaration *cls)
|
||||
{
|
||||
lay::Plugin *p = cls->create_plugin (manager (), root, this);
|
||||
@@ -2584,7 +2604,7 @@ LayoutView::get_screenshot ()
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot")));
|
||||
|
||||
// Execute all deferred methods - ensure there are no pending tasks
|
||||
tl::DeferredMethodScheduler::instance ()->execute ();
|
||||
tl::DeferredMethodScheduler::execute ();
|
||||
|
||||
return mp_canvas->screenshot ();
|
||||
}
|
||||
@@ -2614,7 +2634,7 @@ LayoutView::save_screenshot (const std::string &fn)
|
||||
writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (desc));
|
||||
|
||||
// Execute all deferred methods - ensure there are no pending tasks
|
||||
tl::DeferredMethodScheduler::instance ()->execute ();
|
||||
tl::DeferredMethodScheduler::execute ();
|
||||
|
||||
if (! writer.write (mp_canvas->screenshot ())) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
|
||||
@@ -2629,7 +2649,7 @@ LayoutView::get_image (unsigned int width, unsigned int height)
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image")));
|
||||
|
||||
// Execute all deferred methods - ensure there are no pending tasks
|
||||
tl::DeferredMethodScheduler::instance ()->execute ();
|
||||
tl::DeferredMethodScheduler::execute ();
|
||||
|
||||
return mp_canvas->image (width, height);
|
||||
}
|
||||
@@ -2641,7 +2661,7 @@ LayoutView::get_image_with_options (unsigned int width, unsigned int height, int
|
||||
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image")));
|
||||
|
||||
// Execute all deferred methods - ensure there are no pending tasks
|
||||
tl::DeferredMethodScheduler::instance ()->execute ();
|
||||
tl::DeferredMethodScheduler::execute ();
|
||||
|
||||
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome);
|
||||
}
|
||||
@@ -2667,7 +2687,7 @@ LayoutView::save_image (const std::string &fn, unsigned int width, unsigned int
|
||||
writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ()));
|
||||
|
||||
// Execute all deferred methods - ensure there are no pending tasks
|
||||
tl::DeferredMethodScheduler::instance ()->execute ();
|
||||
tl::DeferredMethodScheduler::execute ();
|
||||
|
||||
if (! writer.write (mp_canvas->image (width, height))) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
|
||||
@@ -2699,7 +2719,7 @@ LayoutView::save_image_with_options (const std::string &fn,
|
||||
writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ()));
|
||||
|
||||
// Execute all deferred methods - ensure there are no pending tasks
|
||||
tl::DeferredMethodScheduler::instance ()->execute ();
|
||||
tl::DeferredMethodScheduler::execute ();
|
||||
|
||||
if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome))) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ()));
|
||||
|
||||
@@ -1878,7 +1878,17 @@ public:
|
||||
return m_drawing_workers;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @brief Gets a value indicating whether the view will accept a dropped file with the given URL or path
|
||||
*/
|
||||
virtual bool accepts_drop (const std::string &path_or_url) const;
|
||||
|
||||
/**
|
||||
* @brief Gets called when a file or URL is dropped on the view
|
||||
*/
|
||||
virtual void drop_url (const std::string &path_or_url);
|
||||
|
||||
/**
|
||||
* @brief Localize a plugin by name
|
||||
*
|
||||
* This method will return 0, if no such plugin is registered
|
||||
|
||||
@@ -264,6 +264,17 @@ public:
|
||||
// .. the default implementation does nothing ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the plugin can exit
|
||||
*
|
||||
* If the plugin wants to prevent the application from closing, it may return false
|
||||
* in this method.
|
||||
*/
|
||||
virtual bool can_exit (lay::PluginRoot * /*root*/) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Fetch the menu objects for this plugin
|
||||
*
|
||||
@@ -369,6 +380,22 @@ public:
|
||||
return m_editable_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the plugin will accept a dropped file with the given URL or path
|
||||
*/
|
||||
virtual bool accepts_drop (const std::string & /*path_or_url*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets called when a file or URL is dropped on the plugin
|
||||
*/
|
||||
virtual void drop_url (const std::string & /*path_or_url*/)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Notifies that plugin root that a new plugin was registered
|
||||
*
|
||||
@@ -661,6 +688,22 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether the plugin will accept a dropped file with the given URL or path
|
||||
*/
|
||||
virtual bool accepts_drop (const std::string & /*path_or_url*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets called when a file or URL is dropped on the plugin
|
||||
*/
|
||||
virtual void drop_url (const std::string & /*path_or_url*/)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Associate a plugin with the plugin declaration for that service (getter)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user