利用者:Kilon/Ephestos

提供: wiki
移動先: 案内検索

Summary

What Ephestos is

  • Ephestos both an addon and a library currently divided into two parts "Morpheas" and "Proteas"
  • "Morpheas" is a GUI API using bgl and modal operators. BGL itself is a standard library distributed with blender and not with Ephestos. BGL is a very thin wrapper around opengl 1.1 as the time of writting this wiki. The advantage here is that with bgl Morpheas can design GUIs that are inside the blender windows in any part, viewports, animation windows, panels and any other parts. The power of Morpheas compared to existing blender GUI is that it allows you to design complex and very flexible guis while the API itself is simple to use and understand, well commented and pure python so there is no need to know C to understan its internals. The limitation is that it can be quite slow and can consume a lot of CPU.
  • Proteas is a primitive bridge between 2 diffirent blender's. Essentially it allows one blender to control another blender via blender python. The bridge can be used also between Blender and another cpython 3 application. With minor modification can works for cpython 2 and even pypy and it has been tested with both of those. The benefits are that its possible to create a network of blender users exchanging information and controlling one another or even a completer blender community all inside the comforts of your blender application. The limitation of the bridge is that it remains blocking , so when the bridge expects a command from another blender , blender cannot be used by the user until the connection is terminated.
  • Its pure python , no C included
  • it works already as an add-on , the test files in main directory show different usages
  • it works as a library for creating Bgl GUIs so you can import Ephestos to your add-on and start creating those GUIs via code

What Ephestos the library currently offers

  • Morph class as the basic for creating graphical elements
  • Hand morph that can handle moving morph around and triggering appropriate morph events
  • A list of widgets that are ready to use

Morph Class

The morph class already implements the basis for visualizing code and creating guy elements in particular

  • Node class, its the class responsible for the parenting in morph. Like a Blender object and Morph object can have a parent and children thus making possible to group morphs together. The World is the top morph and responsible for triggering the draw functions of all moprhs. Adding a morph inside another moprh is as simple as morph.add(newmorph) . Asking for parents as simple as morph.parent while children as simple as moprh.children
  • Morph events. Each morph can handle its own events. What really happens is this . Blender modal passes events to Hand morph . Then the hand morph check to see if there is a morph underneath the mouse cursor, if there is then it checks to see if morph cares about the specific event if either of the above is not true then the event is passed back to blender and blender use it normally as if Ephestos never existed. Its up to the user to inherit from Morph class and override those event that are nothing more than morph methods.
  • Morph has its own draw function where all bgl code is located, nowhere else bgl code exists making sure the code is clean and simple. Textures currently are support but its buggy and you have to use blender images data .
  • Morph uses the Rect and Point class, both classes are very easy to read and understand what they do, they offer a huge array of functions to make your life easier finding out where morph intersect for example , how to extend one morph by another, how to scale, move etc.
  • There is an array of other functions like a developer's menu that is partially implementing for right clicking on a morph and offering designing options

Hand Morph

The hand morph represent the mouse cursor but handle all events both mouse and keyboard events. Generally speaking you don't have to worry about hand morph it does all the job for you , unless you want to implement some new interaction that is not easy to implement as a morph events. Already the hand morph can move morph around, and trigger morph events. Those events can be either mouse or keyboard. The hand morph is attached to the World morph as a child.

Widgets

We have managed to implement an array of widgets you can use which are the following

a) Text Widget. A morph that displays text. Its possible to chose font and size of the letter and also change color. Scrolling is not implemented

b) Menu widget. A morph that displays a menu . Each menu item is a morph itself and each also contains a morph trigger which is a morph that when click it performs an action in this case executes the menu time action.

c) String input. A string field that accepts input from the user, it has the ability to edit text, select text and relocated cursor according to user needs.

d) Repl. A a very basic repl , similar to blender python console with one huge difference. The Repl morph has direct access to yours add-on objects.

e) A yesnomenu. Another morph imitating the usual windows dialog , where you can choose yes or not as options to a request.

Of course because all the above widgets are made from morph you can heavily modify them in real time even if you don't understand exactly how Ephestos works.

Proteas

At proteas side , inside the proteas folder you will find a small primitive bridge that allow you to make 2 blenders communicate with each other as serve and client , where the client can issue command that the server executes. The bridge does not depend on morphemes so it can be used separately if you are interested in this kind of stuff.

So as you can see Ephestos already packs loads of power in it.

Speed Concerns

Speedwise , Ephestos is not slow, actually we can move around moprh pretty fast but it does consume loads of CPU. Thats a problem with most likely the event handling of modal operator and not so much a Ephestos problem, but I may be wrong. For simple GUIs the speed is not a concern.



Various links