Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph editor #38

Closed
5k3105 opened this issue Jun 3, 2016 · 4 comments
Closed

graph editor #38

5k3105 opened this issue Jun 3, 2016 · 4 comments

Comments

@5k3105
Copy link
Contributor

5k3105 commented Jun 3, 2016

https://github.com/5k3105/AM

I uploaded the graph editor I've been working on. It's very incomplete but I need to stop here because the screen updates just don't work.

Left click on screen to plot rectangle

If you have two rectangles you can click on one and click on the other and it will draw a connecting line.

Right click to delete rectangle. This should also delete the lines connected to it.

Left clicking the top right of rectangle switches into Move mode. Clicking again will drop the rectangle where you moved it to.

All this appears to work.

However if you play around you can see:

Sometimes the line to draw the connections will stay on the screen even though there's already been a RemoveItem call.

If you move the rectangle and drop it then right click to remove, the node will disappear from the list on the left panel but the image will persist on the screen. So will it's edges. And if it's connected to another rectangle and you move that rectangle, the edge will follow as if it hasn't been deleted but it has.

I will try to strip this project down to the bare minimum so as to be a good example program for others but at the moment the scene updates don't work right.

@therecipe
Copy link
Owner

Hey

This looks awesome :)
I send you a small pull request 5k3105/AM#1

I just made the items invisible (QGraphicsItem.SetVisible(false)), before removing them.

And because sometimes I got those warnings: QGraphicsScene::removeItem: item 0x55217150's scene (0x0) is different from this scene (0xa5aa230), I added a simple check to make sure the QGraphicsItem.Scene() is not nil.
IIRC you are developing on windows and therefore won't see these warnings, because you got no visible command-line/shell/terminal?

Also as stated here http://doc.qt.io/qt-5/qgraphicsscene.html#removeItem, you are responsible to destroy the QGraphicsItems with DestroyQGraphicsItem() if you don't need them any longer. (But unfortunately it always crashed after I added those calls, so I kept them out of the pull request)

Btw, I'm curious what are you planning to use the graph editor for?

@5k3105
Copy link
Contributor Author

5k3105 commented Jun 3, 2016

Oh wow! Thanks again therecipe!

Yes, I'm on windows.

Graph editor will be used as a front end to generate an xml file for a python multiprocessing pipeline someone else wrote here at work. So current plan is to only generate xml. I hope to use it for a lot of other things though. I tried to make the node/graph separate from the figures drawn on the canvas but I'm not sure I've got the abstractions right for Go. I spent so much time thinking about it I ended up reinventing a feature for Go someone else proposed 2 years ago (https://groups.google.com/forum/#!searchin/golang-nuts/why$20do$20interfaces$20not$20describe$20properties%7Csort:date/golang-nuts/ZJ5DEv_36S8/ZgADJo061JkJ). It was never implemented though ;/

I think I might have over-abstracted.

Open to any and all suggestions.

@therecipe
Copy link
Owner

Hey

I'm busy for the next few days, but I will look into it asap.
And based on what I saw it looks good.

@5k3105 5k3105 closed this as completed Jun 13, 2016
@therecipe
Copy link
Owner

Hey

I looked into it again and concerning the separation of the node from the figures, you probably meant this part?

type Figure interface {
    GetX() float64
    SetX(x float64)
    GetY() float64
    SetY(y float64)
    GetNode() *graph.Node
    AddEdgeIncoming(l Link)
    AddEdgeOutgoing(l Link)
    //  RemoveEdge()
}

Its unfortunately necessary to write own getter/setter functions, so there is nothing wrong with that.
And overall it looks good.

Btw, if you update to a6a0643 or later you will get this error:

controlbox/moc.go:56: NewControlbox redeclared in this block
    previous declaration at controlbox/controlbox.go:20

Because qtmoc is now invoked on all sub-dirs (and there will be a lot of new moc* files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants