Getting coordinate / shape data from pydot for layout in PyQt4 - pyqt4

I would like to use the QGraphicsView control and QGraphicsScene to layout GraphViz generated graphs using pydot. Is there a way to generate the graph in pydot, have GraphViz do the layout, and then extract the layout information (such as is included in the various output formats generated by pydot.write_xyz)? So far in my testing the get_pos() functions for Nodes, etc. return None.

As you already said, you have to first output the graph with create_dot to a string, then generate the graph layout by passing that string to graph_from_dot_data:
graphWithPositions = pydot.graph_from_dot_data(graph.create_dot())

Related

How to draw custom shapes with draw2d?

I am using draw2d javascript library for drawing predefined shapes and custom shapes in it's canvas.
As I don't have any example made yet, I am trying to copy from it's documentation but doesn't seem to find a good way to research it as it contains a whole lot of it.
Here is the circle example.
http://www.draw2d.org/draw2d_touch/jsdoc_6/#!/api/draw2d.shape.basic.Circle
and here are some more documentation with examples.
http://www.draw2d.org/draw2d_touch/jsdoc_6/
I have premade shapes with html and css and I am trying to drag and drop and render them on canvas like these in this image. Also when dropped, they should have input and output ports too.
Is it possible to convert this html/css to draw2d shapes?
So here this is made possible via extending draw2d's SVGFigure and thus we have ability to provide custom svg to render it as a custom shape.
Below links were useful in this context.
http://www.draw2d.org/draw2d_touch/jsdoc/#!/guide/extending_svg_figure-section-live-example
https://github.com/freegroup/draw2d/tree/master/examples/shape_custom_svg
http://www.draw2d.org/draw2d_touch/jsdoc_6/#!/api/draw2d.SetFigure
https://github.com/freegroup/draw2d/tree/master/examples/shape_labeld
https://github.com/freegroup/draw2d/tree/master/examples/shape_custom_markdown

Using vtkImageActor for adding mask to vtkImageViewer2

I am developing on an application based on VTK and GDCM for viewing medical (DICOM) images.
The application has three windows that respectively show XY, YZ and XZ orientations (axial, coronal and sagittal). This is similar to the 2D views here. I use vtkImageViewer2 for this. The voxel values of the DICOM images are passed on to an instance of vtkImageData. The instance of the vtkImageData is the passed on the to three instances of vtkImageViewer2 (let's use imageViewerXY, imageViewerYZ and imageViewerXZ). The orientation of each instance of vtkImageViewer2 is then set using SetSliceOrientationToXY(), SetSliceOrientationToYZ() and SetSliceOrientationToXZ(). Without the mask, I can see the slices, couple the windows and scroll through the images perfectly fine.
To add the mask so that it is shown in the three views, I use vtkImageActor. For the XY view, which is the default view, this works fine. I update the instance of vtkImageActor, which I call maskActorXY based on the mouse events of XY window as follows:
int extent[6];
imageViewerXY->GetImageActor->GetDisplayExtent(extent);
maskActorXY->SetDisplayExtent(extent);
maskActorXY->Update();
imageViewerXY->GetRenerer->Render();
Now, when I do the same for the other two windows so that I can see the 3D mask in the other two orientations, for example for the YZ orientation,
imageViewerYZ->GetImageActor->GetDisplayExtent(extent);
maskActorYZ->SetDisplayExtent(extent);
maskActorYZ->Update();
imageViewerYZ->GetRenerer->Render();
I get an error message that traces to vtkImageData and accessing pixel values outside of the extent set for the mask actor.
I have a limited familiarity with VTK, but looking at the source code of vtkImageViewer2 (see UpdateDisplayExtent() on line 341), I don't understand why pixel values out side of the specified display extent are requested from my instances of vtkImageActor that represent the mask.
I found a solution. Since I am not familiar with VTK, I may not be able to provide a clear explanation. All that I needed were the following two lines for each mask to force its mappers to face the camera:
maskActorYZ->GetMapper()->SetAtFocalPointOn();
maskActorYZ->GetMapper()->SliceFacesCameraOn();
(see [vtkImageMapper3D][1] class.)

Triangulate unstructured grid in vtk

I work with UnstructuredGrid and I want to triangulate it like in Paraview (when I clicked for model).
How I can do it?
I tried vtkDelaunay3D, vtkDelaunay2D and vtkTriangleFilter.
vtkDelaunay3D :
I've transformed UnstructuredGrid to vtkPolyData, after used vtkCleanPolyData and vtkDelaunay3D. It's not worked. It's crushed with this warning :
vtkMath.cxx: Unable to factor linear system
vtkDelaunay2D :
Similarly I used vtkDelaunay2D, but result is not good for me.
Also I use vtkTriangleFilter, it's result not good for me too.
When you click (or interact) in ParaView, ParaView is rendering a simplified geometry -- not simply a triangulated geometry. The filter it uses to do that is vtkQuadricClustering. Apply the vtkGeometryFilter first to your unstructured grid to convert your vtkUnstructuredGrid to a vtkPolyData. Then connect it to vtkQuadricClustering. You can play with parameters in vtkQuadricClustering to control the simplification.

Generating Static HTML Dashboard Using Plotly Python API - Controlling Element Layout

I'm looking at the gorgeous and powerful Plotly Python API with the goal of generating a static html dashboard.
This raises two questions:
For generating html, I see the following example. It appears the charts are embedded via a URL. Does this URL embedding implementation still apply since plotly has gone open source? Are there now other methods for sending plotly plots to static html?
How does one control the layout of the plots/dashboard elements? In Bokeh, for example we could do something like:
bar = Bar(<define bar plot>)
line = Line(<define line plot>)
donut = Donut(<define donut chart>)
bar_line_panel = hplot(bar, line)
final_layout = vplot(bar_line_panel, donut)
output_file('foo.html')
show(final_layout)
The rendered html file would contain the line and bar plots next to each other above the donut chart. Is there similar functionality in plotly, or are templates and html/css wrangling required to specify layout for plot elements like in this example?
Thank you for your time, very much looking forward to creating some interactive visualizations in Plotly!

Cross-Platform Vector Format

Does there exist a data (file?) format representing a resizable vector graphic that can be exported to iOS CoreGraphics AND be rendered on a Linux server? I've been considering SVG with this library, but I need support for text and element constraints (i.e. pinning elements to edges).
I am not aware of a file format that provides the functionality that you are looking for out of the box.
But you may want to consider using SVG in combination with Paper.js. In Paper.js you can add custom data to any item (http://paperjs.org/reference/item/#data). Using Javascript you can then interpret the data and use it for applying your constraints prior to rendering.
Please note that while Paper.js is quite good for doing layout of elements (applying your constraints should be easy) and it has SVG import and export, but it does not support the full SVG spec (especially filters are missing).

Resources