Discussion:
qmodel2svg
(too old to reply)
Christian Gagneraud
2018-12-10 04:49:40 UTC
Permalink
Hi Christian,
yes, writing a tool that loads a qmodel file and exports an svg diagram
Hi Jochen,

Thanks a lot for all the details, got a quick prototype working in 30 minutes!?!
Less than 60 SLOC...

Need to polish the code, add command line argument, ...

Chris
1. Create an instance of qmt::DocumentController
2. Load a qmodel file with qmt::DocumentController::loadProject().
Handle some exceptions for file-not-found etc. You must look into the
implementation of loadProject() to find out which exceptions are thrown
during loading.
3. Implement a visitor derived from qmt::MVoidConstVisitor that
searches for a diagram by name. Look into qmt::MChildrenVisitor on how
to visit the whole model tree (you could also derive from
qmt::MChildrenVisitor but that is not a const visitor). You get the
root element on which you accept the visitor from
qmt::ModelController::rootPackage(). The ModelController is available
from your DocumentController instance.
4. From your DocumentController instance get the qmt::DiagramsManager.
Bind your qmt::MDiagram* that you got from the visitor with
DiagramsManager::bindDiagramSceneModel().
5. Use the returned qmt::DiagramSceneModel to exportImage(),
exportPdf() or exportSvg().
That's all. Should be a single file program with less than 500 lines
including the visitor.
Please submit the tool as part of the tools of the QtCreator project.
Regards, Jochen
Hi there,
Every now and then I use QtCreator's ModelEditor plugin.
I like to write documentation in MD, and i usually manage the sources
with a Makefile to automate various stages for the final off-line
production.
A missing tool in my workflow is one that could convert a qmodel file
into SVG, from the command line.
Is it possible to use qtcreator in command line mode to ask the
ModelEditor plugin to do an SVG export?
If not, I do think that it shouldn't be that hard to write such a
- link to modellib and find a way to do the export
Is that simple?
- link against corelib, and initialise it with defaults
- link against extentionsystem, and initialise it with defaults
- ask the extension system to load modeleditor plugin
- call directly into this plugin and ask for the conversion
Like 2, but given that Core contains the editor manager and the
document manager, i should be able to open a document with an editor
and automate the export (if i don't want to see any UI, i could use
the Linux offscreen QPA to hide it)
Chris
_______________________________________________
Qt-creator mailing list
https://lists.qt-project.org/listinfo/qt-creator
Loading...