Login  Register

Re: Adding scripting interface in librecad

Posted by R. van Twisk on Mar 11, 2012; 9:36pm
URL: https://forum.librecad.org/Adding-scripting-interface-in-librecad-tp5554389p5555950.html

Hey,

I did see your message on the LibreCAD forum regarding the plugin interface.

Rallaz wrote the current version of the interface, and I am wrapping my head
around some ideas about extending this and thinking about
what it should support for LibreCAD. 

I am trying to see if we can/should use the concept of mutable vs immutable objects towards all plugins.
That means that we only expose immutable objects towards plugins. This
way they can never modify entities without using some form of
a system. I can imagine we would create operations.  Ofcourse
a plugin should beable to operate on objects, but not in a way
taht let tany plugin call set functions on entities.

For example I don't like this style:

//(Pseudo code)
List entities= document.getAllSelectedEntities();
for each entities entity {
    entity.move(10,10); move the pbject 10 units X and 10 units Y.
}
graphics->redraw();



I rather have something like this:
Operation operation= new Operation();
operation.move(10,10);
operation.rotate(50,50,0.5); //Rotate around 50,50
document.doOperation(operation); // Operate on selected entities

A other style could be
Operation operation= new Operation();
operation.add(new OpMove(10,10));
operation.add(new OpRotate(50,50,0.5));
document.doOperation(operation); // Operate on selected entities


If a plugin needs to get all entities, it could do this:

List entities= document.getAllSelectedEntities();

However, entities would be a ¿copy? list of immutable objects.
This way a plugin can never operate change anything without
doing something through a operations/document.

Once we have a solid plugin interface, we can do a lot of fun stuff very reliable.

I think it also means we should take a close look at the current set of entities
and see if we can create a 2D kernel (Also on GSOC). From then
LibreCAD will be a kernel, gui + plugins. In fact, everything in LibreCAD
can then start becoming a plugin.


These are currently just random thoughts though.

Ries


On Mar 11, 2012, at 2:42 PM, davinder [via LibreCAD] wrote:

On 12 March 2012 01:18, R. van Twisk [via LibreCAD]
<<a href="x-msg://8/user/SendEmail.jtp?type=node&amp;node=5555740&amp;i=0" target="_top" rel="nofollow" link="external">[hidden email]> wrote:
> Hello,
>
> I think the most important portion we need to solve first prior to a
> scripting
> is work on the plugin interface. Once we have a solid plugin interface
> we can start working on the scripting interface.
OK. I am looking at the source code of librecad as well as plugin
code. I have modified some of the wiki page of librecad gsoc 2012.
According to you what is remaining in this plugin interface ?
>
> We have opened this for GSOC so with a little luck we can work on this
> in summer.
We will definitely do it, if not in gsoc then in some other way.


--
http://davinder.in
Dont hurt the web, use open standards



If you reply to this email, your message will be added to the discussion below:
http://forum.librecad.org/Adding-scripting-interface-in-librecad-tp5554389p5555740.html
To start a new topic under LibreCAD, email [hidden email]
To unsubscribe from LibreCAD, click here.
NAML