[Clam-devel] Copy & Paste processings on canvas patch

Natanael Olaiz nolaiz at gmail.com
Thu Jun 12 16:02:49 PDT 2008


El 06/11/2008 06:03 PM, David García Garzón escribió:
> About the position/size question. If we have a solution let's implement it. 
> But if not, meanwhile, to have the cut&paste working properly without 
> breaking the format we could just use the positions when cutting or pasting 
> and ignore or set them empty on loading and storing.
>
> Related to the patch but unrelated to the discussion. I did some enhancements 
> on the qaction handling. Mainly i used the canvas member actions you added as 
> the actions in the context menu. (Not with the remove action which have 
> different semantics with the context menu one, by now). This way we are 
> getting the shortcuts whenever we see the menu. I also enabled the 
> translation of menu options text by using tr("text"), changed the 'Copy 
> Processing(s)' and so on to a bare standard 'Copy' and added some icons from 
> kde 3.5 standard set.
>
>   

Very nice. I like it, and the icons :)

> By having persistent actions, in the future, but not an urgent need, the 
> MainWindow could ask the canvas for actions to insert at the edit menu and 
> the canvas could enable or disable them according to the selection or the 
> clipboard. :-)
>   

I agree.


Well, sorry for the late patch. I was quite busy with other things, and 
in the middle thinking and testing different types and ways to pass the 
data between classes.
Here is my actual solution (which I don't know if it's so good): I made 
a subclass of network: ProcessingGeometry[1]. I think maybe it would be 
simpler with just a structure, or putting it on other place 
(Processing?). Any critic is welcome.

On MainWindow I added a line to load the geometries from the XML, and if 
it fails try with the .pos file.
I would need to add a checkbox when saving, to select what format do you 
want. By now, it write only the traditional .pos file (for development 
testings you can paste the clipboard after copy / paste to a file, and 
load it).


Regards,
Natanael.

[1] The CLAM::Network::ProcessingGeometry class:

    class ProcessingGeometry //TODO: maybe just define a struct?
    {
    public:
        void getPosition(int & x,int & y) const
            { x =_x; y =_y; }
        const std::string getPosition() const
            { return IntsToString(_x,_y); }
        void getSize (int & w,int & h) const
            { w =_w; h =_h; }
        const std::string getSize() const
            { return IntsToString(_w,_h); }
        void setPosition (int x, int y)
            {_x=x;_y=y;}
        void setPosition(const std::string & positionString) { 
StringPairToInts(positionString,_x,_y);}
        void setSize (int w, int h)
            {_w=w;_h=h;}
        void setSize(const std::string & sizeString) { 
StringPairToInts(sizeString,_w,_h);}
    private:
        int _x,_y,_w,_h;
        void StringPairToInts(const std::string & geometryInString, int 
& a, int & b)
        {
            
a=atoi(geometryInString.substr(0,geometryInString.find(",")).c_str());
            
b=atoi(geometryInString.substr(geometryInString.find(",")+1,geometryInString.length()).c_str());
        }
        const std::string IntsToString (const int & a, const int & b) const
        {
            std::ostringstream stream;
            stream<<a<<","<<b;
            return stream.str();
        }
    };
    typedef std::map <std::string, ProcessingGeometry> 
ProcessingsGeometryMap;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CopyAndPaste_WithGeometries.patch
Type: text/x-patch
Size: 13616 bytes
Desc: not available
URL: <http://lists.clam-project.org/pipermail/clam-devel-clam-project.org/attachments/20080612/f383d734/attachment-0005.bin>


More information about the clam-devel mailing list