evilnose / pyrkviewer Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Update the plugin readthedocs information it is currently out of date.
Add save and load models in JSON format
Should a plugin have access to the canvas so that it can add additional visual aspects to the canvas? eg a plugin might draw a bar graph next to a node to indicate the concentration of the node.
Nodes should have a lock flag. If a node is locked it cannot be moved by the user using the mouse.
Update the plugin API to give access to the lock flag, set or get.
Allow a plugin to change/access all properties of a compartment
There currently isn't a way to delete a reaction. Add delete functions to menu and add allow the leyboard delete key to be used to delete a selected (s) reaction.
The current centroid should be movable by the user using the mouse. Currently, this is called the centroid but should be renamed to something like arcCenter, reactionCenter etc,
When a reaction is first crated, tits arcCenter should be set to the centroid. Ater that a user can move this point.
Add a Help menu with an entry called About, this should bring up a dialog box showing the current version.
Provide plugin API to allow bezier handles etc to be moved
Allow a plugin to change/access all properties of a reaction
wxPython offers the function refreshRect
to use in place of refresh
for updating only a rectangular region of a window, for performance.
This could boost performance in most situations, but to implement this correctly would take a good amount of time (considering how when a node is moved, the reaction(s) that it is in may also improve, increasing the size of the rectangle). It is also hard to say whether the work done finding bounding boxes would outweigh the drawing work saved.
It is also unclear whether we're already benefitting from ScrolledWindow's own optimizations, i.e. not drawing items out of the scrolled area.
Therefore we should investigate the potential gains from this optimizations using profilers and plan out the necessary architecture before starting to implement it. Possibly one may keep track of a list of CanvasElements that were moved, and in Canvas::OnPaint
retrieve the bounding rectangles for all of them.
Add right-click popup menu, allow plugins to add themselves there. The plugin should get information on whatever object (or selection) is below the popup menu: node, reaction etc (2)
Currently the event manager (rkviewer.canvas.events
) has no garbage collector, meaning bound handlers could not be removed from the list of handlers once added. This is restrictive, since the programmer would not be able to bind handlers inside CanvasElement
s, which are transient (deleted every controller update).
To achieve this, need to refactor bind_handler()
to accept an additional target
parameter of type CanvasElement
. Supposedly this is the "target" of the event, and the handler should be valid only as long as target
lives.
Now Python does not have destructor methods, and the closest thing one has is the context manager. So the solution is to add a close
method (or equivalent) to the CanvasElement
base class and call that manually in Canvas. The close method should be manually patched by the event manager to trigger the handler to be deleted, when it is called.
When the user positions and sizes the main window, if the program exits it should remember this size and position so that when the user loads the app again they will see the main window with the same size and position.
Is it possible to move selected objects using the cursor keys on the keyboard? If appears that the keyboard focus on the canvas is the zoom slider.
The autolayout plugin doesn't work for complex reactions. In particular, the arc centers aren't positioned correctly
It would be nice to have a method that can translate a network by a given amount to another position. This would require all components to be translated, reaction handles and reaction center, nodes, and compartments.
This would allow for example someone to center a network in a given bounding box, eg the viewable canvas.
Provide plugin API to get access to model details such as the number of nodes, reactions, compartments
In addition, provide access to reaction details such as the number of reactants/products and stoichiometric.
Does a reaction current;y have a rate law? If so allow plugin access to rate law to change it.
Looks like there is a bug in the arrow tracking the bezier curve. Take two nodes with a reaction between them. Move the bezier handle on the arc center and notice that even though the bezier slope changes at the node, the arrow does not respond by following. See the image below, where the bezier handle is to the left or to the right (circled) has changed but the arrow hasn't changed orientation at all. Need to update arrow position when inner bezier handles are changed.
Provide plugin API to change positions and size of nodes
Allow users to add and delete compartments. These are just rounded rectangle boxes with stroke and fill colors as well as edge (stroke) thickness. Other properties include an Id and a volume (double value, default to 1.0). Compartments can be resized. Compartments may overlap or even appear to be inside another compartment, however this is just a visual effect, in the object model, compartment won't be allowed to be inside compartments
Compartments can be moved. Nodes that are moved into a compartment become part of the compartment and vice versa. A compartment can be moved over nodes and nodes become part of the compartment. When I compartment is moved, any nodes and reactions in the compartment will also move with the compartments. Compartments will have their own property sheet.
Add the ability for a user to select straight lines in addition to the current bezier curves
Add a drop-down in the reaction panel to allow a user to make the selection
The add reaction plugin won't close
Allow a plugin to change/access all properties of a node
Save a network to file as png, svg, or pdf if possible. Allow the user to select the image type.
Don't save the entire canvas but locate the extremities of the current network and save that portion.
I just built the following model, however the two reactinos are competely separate uniuni reactions. It only appears to be bibi. This is beause the centroid is the same for each reaction. We will need to allow the user to move the 'centroid'. Obviously the centroid itself can't be moved but so you'll have to have a variable that stores the value where the edges meet. By default this value would be assigned the centroid but a user should be able to move the meeting point using the mouse.
Add some nodes
Select a bunch
Copy (Ctrl-C)
Paste (Ctrl.V)
Crash:
PS D:\Documents\Tellurium\GitHubProjects\PyRKViewer> python main.py
Initializing RKViewer...
Traceback (most recent call last):
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\view.py", line 393, in
lambda : canvas.Paste(), entries, key=(wx.ACCEL_CTRL, ord('V')))
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\canvas\canvas.py", line 1273, in Paste
for id in pasted_ids})
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\canvas\utils.py", line 129, in set_item
self.notify()
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\canvas\utils.py", line 107, in notify
observer.update(self._item)
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\canvas\canvas.py", line 204, in
selection_obs = Observer(lambda _: self._SelectionChanged())
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\canvas\canvas.py", line 1101, in _SelectionChanged
compartment_indices=comp_idx))
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\events.py", line 364, in post_event
callback(evt)
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\view.py", line 102, in OnSelectionDidUpdate
self.node_form.UpdateSelection(evt.node_indices, comps_selected=should_show_comps)
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\forms.py", line 497, in UpdateSelection
self.UpdateAllFields()
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\forms.py", line 738, in UpdateAllFields
nodes = get_nodes_by_idx(self._nodes, self._selected_idx)
File "D:\Documents\Tellurium\GitHubProjects\PyRKViewer\rkviewer\canvas\utils.py", line 17, in get_nodes_by_idx
assert len(ret) == len(indices)
AssertionError
The CanvasElement system is used in Canvas to emulate the widget system used in many GUI frameworks. It handles mouse events, draw events, layers, etc.
However it does not currently handle cursors, which are handled in a haphazard way. Add cursor support for CanvasElement, including functions that set the cursor for a specific CanvasElement.
Remember that a CanvasElement could vanish after a deletion or undo event. To deal with that, need to refresh the cursor (as well as mouse-in/out events) in the Reset
method
The following settings have not been implemented:
For the node fonts, we also want to decide if we want to use the wxPython built-in fontStyles, which are more compatible, easier to implement, but offers significantly less variety. Another option is to let the user specify the faceName directly.
While using the latest version I think I'm seeing a slight slowdown in performance. I noticed a slight delay between clicking the node and the mode moving. Keep an eye on any inefficiencies in the code as you develop it.
We need a new model option in the File menu. In general, the file menu also needs:
Exit
A plugin should be able to detect when there are changes to the model, eg reactions deleted, new model etc.
Change id_ to id
Add a blunt end option to a modifier line. Use a drop-down list to allow a user to select the style because later one we could add other styles.
Docs need updating, eg move_node is not in the current docs
I noticed that if I try to change the color of a selected reaction using the color selection plugin, rkviewer crashes, see the crash report which I think explains the issue.
2020-09-11 15:38:33,120 root INFO MainProcess Initializing RKViewer...
2020-09-11 15:53:44,376 root ERROR MainProcess Traceback (most recent call last):
File "plugins\color_selected.py", line 58, in color_callback
api.set_reaction_fill(api.cur_net_index(), index, color)
AttributeError: module 'rkplugin.api' has no attribute 'set_reaction_fill'
Right now event handlers are called as soon as events are posted. This is undesirable for two reasons
Lazy event handling may mitigate these issues. To implement that, when post_event()
is called, the event is pushed into a queue. The queue is popped in some time interval (e.g. in OnIdle()
) and events are handled then. I'm not sure yet whether the queue should be emptied each time, or perhaps events should stop being popped once a certain time limit has been reached.
This is not urgent since right now the app seems to run smoothly enough. Also, implementing this well may be difficult.
Need the following features:
For example, if add_node()
fails because there is a duplicate ID and the error is caught, a node is still added with partially initialized attributes, since controller.add_node_g()
is not atomic.
This is not very urgent since plugins are not likely to need to catch add_node
exceptions, but still probably useful to have.
Since Bezier handles now move with its associated node, it is possible for them to go out of bounds. Fix this bug by clipping their positions.
I got into a state where I couldn't remove the green dotted line around a node. After I pressed all the buttons I found the hitting products removed it. However, there should be an easier way to unselect this, for example:
At the moment it's difficult to get out of this mode unless you know what you're doing.
Need to have unit tests for the plugin API, even though mostly it just invokes iodine functions.
One related issue: we probably want to modify update_node
so that it does not allow for duplicate ID. We likely don't want to expose iodine exceptions to the client.
Add a new flag to nodes: floating or boundary. Update plugin API if need be.
The two different nodes should be visually distinguishable. eg thicked border for boundary nodes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.