← Back

ofxPolysave

github.com/egradman/ofxPolysave · @egradman
OF 0.8 Geometry

Embeds a GUI editor for creating and editing named polylines, rectangles, and ellipses, saved and loaded via XML.

4 2 Last commit 11y ago Created 11y ago

Forks

Forks pushed to more recently than egradman/ofxPolysave itself, plus any admin-confirmed fork with commits of its own — worth checking if you're hitting issues with the original.

twobitcircus/ofxRectsave by @twobitcircus · ★ 1 · pushed 9y ago

README

The symptom



_"Can you move that a few pixels to the left?"_

_"Sure... I'll just exit, edit some constants in a header file, recompile, and restart the program."_

The cure



ofxPolysave is an addon that embeds a tiny geometric primitive editor in your application. With just two lines of code, you get a quick GUI for creating and editing polylines, rectangles, and ellipses. You can give each object a unique name. These objects are automatically saved and loaded in an XML file (polysave.xml). The polysave object provides two functions: getRectangleByName(string name) and getPolylineByName(string name).

If you ever find yourself hard coding screen coordinates into your program, consider using ofxPolysave instead. Use it to:

It's a GUI tool which is terribly useful during application development, because you can edit the geometry while your application is still running allowing you (and the person hovering over your shoulder) can see the outcome immediately. ofxPolysave generates a datafile which is consumed elsewhere in the program, and in that regard it's inspired by ofxTimeline.

Setup



1. Include "ofxPolysave.h" and create an ofxPolysave object in your ofApp:
    #include <ofxPolysave.h>
    
    class ofApp : public ofBaseApp{
      ...
      ofxPolysave polysave;
    }
    


2. Call polysave.setup() in the setup function of your application. The polysave object will automatically hook into ofEvents.

3. When the polysave editor is active, it will listen for mouse and keyboard events. If your application also responds to mouse and keyboard events, you may want to include the line if (polysave.active) return; at the beginning of your keyPressed method.

Use



The ofxPolysave editor is toggled by the | key. When active, it shows a list of keyboard commands, as well as the list of saved polys. Create a new ellipse :e, rectangle :r, or polyline :p. Unless you type the command character : you'll be editing the name of the currently selected poly. :w will save the data file (it's saved automatically when the program exits normally).

To fetch a saved poly, call polysave.getPolylineByName(string name) or polysave.getRectangleByName(string name) (which return ofPolyline and ofRectangle objects respectively). These methods are cheap, so do it in your draw routine.

Notes



TODO



Get this addon

HTTPS
SSH