Generate draw.io map diagram from hierarchical JSON/XML - draw.io

I'd like to programmatically generate a draw.io map diagram from nested XML/JSON exported from Zotero (individual items nested in sub-collections and collections).
I already have the basic JSON/XML, which can be adapted to draw.io's format, but I'm not clear how. There seems to be no schema for the app's diagram format, and the source XML of existing diagrams includes a lot of style and layout information that I want to avoid having to calculate -- I am assuming, given that the Layout option in the app is automatic, that there must be a way to automatically render a diagram without having to include manually-specified style/layout info.
So I have three questions:
Is there a standard XML/JSON scheme for hierarchical draw.io map diagrams?
Is it possible to give draw.io just the relationship info between elements, and have it determine the layout automatically (akin to the automatic Arrange > Layout options within the app)?
Within a draw.io map, can a node be connected to more than one parent?

I've created a converter from json to drawio format. It does not work with nested collections now, but it may help anyway.
https://github.com/Voravomas/drawio_diagram_converter

How about this VS Code extension? https://github.com/hediet/vscode-drawio

Related

Seeking Qt5 WYSIGWG editor design advice

I am planning a new desktop application. It will provide a WYSIWYG editor for HL7
files (OSS Project). HL7 is a structured file format often used by hospitals for
exchanging data between systems.
The basic structure of the format comprises of records which are \r
delimited. A record can have N fields which are | delimited. A field itself
can be sub-devided into components ^ and sub-components & and
fields can be repeated ~ (similar to an array). Every message type has a
different number of fields/components and sub-components. Empty fields at the
end of a record can be omitted.
Example of a simple record:
OBX|14|NM|0050–5^Calcium||8.9|mg/dl|8.4–10.4||||F
I have already implemented an efficient parser which turns a whole file into a
hirarchial data structure in C. I want to implement an application that
allows editing these files like in a text editor. I want to keep the underlaying
hirarchial datastructure at any point, so it is easy to validate structure and
content of every field, upon user changes, quickly.
Also note worthy is, that I already implemented a viewer where the document
strcuture is displayed in a QTreeView. The structure is using a QAbstractItemModel.
Now to my actual question: how would I approach the problem of having a text editor
with a structured data model in Qt. I have done some research:
there is a QDomDocument, it seems to be made to work with xml data. I could convert my structure into XML but can the dom object be used with a text editor ?
Is there a way to bind a tree like document model to QTextEdit or QPlainTextEdit?
is it possible to bind a QAbstractItemModel to a document in QTextEdit or QPlainTextEdit?
What would be the best approach to tackle the problem of having a textual representation of a tree that gets updated once text and/or stricture is changed by editing in the text field?
Performance and cross platform capability is important, so this project will be implemented in C++.
Thanks for any advice and examples appreciated if you have any.
-S

Kentico 10 - Use a repeater to display multiple page types

We are currently use the oob page types for Blog, News and Event. We have one page for each of these types that includes a repeater to show a list of the pages of that type. We would also like to have a page that includes a repeater that shows all blog, news and event pages in one spot, sorted by their created date.
I have seen some old comments (here, here) on devnet saying that although a repeater can render multiple page types, the fields rendered must be identical across each of those page types. The workarounds suggested are either to create the same fields in each page type, or to create a custom SQL query and use a query repeater to render the data. I've done this and it works just fine, but it was pretty cumbersome to create and will be difficult to maintain. (If we want to add other page types, for example.) Can anyone suggest a more out-of-the-box method available in Kentico 10?
Update:
I'm trying to accomplish this as Brenden described, but am running into trouble.
My page structure is as follows:
Root
.RollupPage (CMS.MenuItem)
..BlogPosts (CMS.Blog)
...January 2017 (CMS.BlogMonth)
....blog post 1 (CMS.BlogPost)
...February 2017 (CMS.BlogMonth)
....blog post 2 (CMS.BlogPost)
..Events (CMS.MenuItem)
...Event1 (CMS.BookingEvent)
...Event2 (CMS.BookingEvent)
I've attempted to use a universal viewer, but failed to get it to return any data.
I configured it with:
Path: /RollupPage/%
Page types: CMS.BlogPost;CMS.BookingEvent
Hierarchical Transformation: CMS.MenuItem.HierTrans1
HierTrans1 has the following transformations:
CMS.BlogPost.Default (Item transformation for type CMS.BlogPost)
CMS.BookingEvent.EventCalendarItem (Item transformation for type CMS.BookingEvent)
These aren't customized at all; they are standard OOB transformations just so I can see it work.
When I view the RollupPage, the universal viewer displays nothing.
I attempted to use a Hierarchical Viewer with the same settings as I did with the Universal Viewer. It kind-of worked. It displayed my booking events but did not display any blog posts. Yet using the same blog post transformation (CMS.BlogPost.default) with hierarchical viewer whose Path was set to /RollupPage/BlogPosts/% displayed my blog posts correctly but, obviously, did not display my booking events.
The results I've gotten so far makes me think a) something about the way I've created my pages is stopping the universal viewer from traversing the whole tree and/or b) the hierarchical viewer either only goes a couple of levels deep, or maybe it is being blocked from traversing the tree too... No events are recorded when I edit or view these web parts.
Any idea what I may be doing wrong?
For this scenario use a universal viewer. Reason being is you can create a hierarchical transformation which will have different transformations for each of your unique page types. You most likely won't use the hierarchy at all but you can simply add 3 different item transformations for the different page types.
You can use the Hierarchical viewer or the Universal viewer, as Brenden Kehren mentioned, to achieve the goal you are describing.
When configuring the web part you must select all the Page types that are included in the hierarchy, in your case: CMS.MenuItem, CMS.Blog, CMS.BlogMonth, CMS.BlogPost and CMSBookingEvent.
Create a Hierarchical transformation to be used with your viewer and add an Item transformation for each of the items you wish to display. Also make sure the Level setting for each transformation is configured properly (-1 applies the transformation to all levels).
For Universal viewer it is necessary to check the property Load hierarchical data in the section Extended settings of the configuration.
As an additional note, you can leave the path property empty in case you are viewing the child documents of the current page.
For reference there is also an example on the Corporate Site example site in the content tree path Examples > Web Parts > Listings and viewers > Pages > Hierarchical viewer (or Universal viewer).
Hope this helps!
The other ways are this
Evaluate right fieldname by check object classname inside the transformation and assign appropriate value.
Dynamically assign transformation by checking the object classname

Generating class diagram from source code

I'm using Enterprise Architect and I wish to generate some class diagrams for a specific set of C++ objects within a massive project. By right clicking on a particular model and choosing Code Engineering from the context menu I can import the entire source directory for the project and generate class diagrams for all objects in the project.
I can also simply generate a class diagram for a single source file. However what I'd ideally like is to generate individual class diagrams for a particular set of files within the project (for example ones which only contain the text SNMP within their names). Can anyone help me apply this filter as the class diagram for the entire project is too large and unwieldy to manage in any capacity.
In Enterprise Architect once you have imported the entire model like you have already done you can create additional diagrams to show only the parts of the model you need. In fact I consider this normal practice.
First create a new diagram with Add->New View -> Class View & diagram.
Then drag only the classes you want from Model in the Project Browser onto the new Diagram.
If you comment your code using doxygen then you can generate these class diagrams automatically. Please look at our code at github/nvmecompliance/tnvme for example. I'm not sure if this directly applies to your case if the source code you are not going to modify..

Qt Editing Custom Data Structures

I am trying to utilize the Model/View architecture to accomplish my goal but I am unsure as to whether this is the proper tool to use for this task.
I have a Material System I have been using, which I more recently have created an editor for using Qt, it uses a QGraphicsView to display items which are interconnected to form a final fragment shader code, this works extremely well however, I am having difficulties finding a way to display these custom data structures without hand coding widgets for each type of item.
These custom data structures are simply classes with members which I wish to modify using an interface depending on each members type. For instance if the item is a Value which in my material system represents a single variable, like a texture, I would like to be able to have 2 editable areas, one for the texture's path on disk, and one for the name of the variable.
What is the best approach for interpreting custom structures like this and creating widgets based on their type, and then mapping those widgets to edit/display them. All the google searching I found led me to the Model/View architecture however it seems this is more made for things like SQL databases and XML files.
class Value
{
std::string m_strType, m_strName, m_strValue, m_strLocation;
};
It sounds like you're looking for something like the Property Browser Framework. In short, you'll make all of the members you want to edit properties, and then use the property browser framework to create a model that you can then attach a view to.

Using Qt Model/View with non-table like data and non-table/list UI?

I've been reading about Qt's Model/View framework. I find it really helpful on working with tabled data like tables from a database. My question is: will it be useful for non-table data like property list or just some bunch of data of various types? If so, how should I approach it?
The goal is to come up with an editor for some property list like data. The list is constructed at runtime and the elements are of various types (numbers, strings, booleans, and file paths, to name a few). Each element is basically a name-value pair. The name, type, and restrains (limits for example) for each element are defined at compile time. They will be assembled at runtime into different lists depending on user input. And the list of elements can change during the edit session.
The UI will most likely be combination of various pre-designed widgets assembled according to user input. They may not be list or table views.
Some pointer to design pattern or examples are also much appreciated. Thanks.
I don't see a problem with MVC framework in QT for doing that.
Basically the difference between a standard table display and this is that you create a list dynamically akin to a map of:
QMap<QString, QVariant> property_map;
You can do a:
QList<std::pair<QString, QVariant>> property_list;
which you can then use to display in a table the property. The best way would probably be:
struct {
QString prop_name;
int prop_type;
QVariant prop_value;
};
QVariant basically will provide you with a single abstraction class for data storage and it is actually what's being returned by the data() function inside the QAbstractItemModel which you might be reimplementing.
So basically you will take a property list and boil it down to the same table like data as the database.
AMENDED
If you have a Widget that you want to have this widget populated with other predefined widgets you are quite likely to have multiple problems unless widgets are of same or well defined size.
What you can do is in you Display widget define a layout like: QGridLayout or other possible layouts and then add your other widgets to it using some set of parameters, which could be done but can be somewhat of a pain.
The other approach that you may take is to place all property widgets up front on the display UI and simply turn the ones you need on and the rest off, but this only applicable if you have a well defined limited number of pre-designed widgets.
I've been using Model/View framework for quite some time now and I usually implement my own models with a backend based on Qt containers (vectors, list, etc). Even if data eventually comes from a database, working with (e.g.) a vector of database ids can dramatically improve performance (and sometimes is the only way you can do).
This trivial example from Qt docs (see "Creating a Custom Model) is the point where I started and shows how to use a QStringList as a backend for a custom model.
Once defined your model you can define your custom Views, which will draw arranged widgets based on the content of the model underneath.
When the model change, your view will change accordingly rearranging widgets when necessary.
Leveraging QVariant capabilities you should be able to render the proper widget for every datatype (e.g. a QSpinBox for a float a QComboBox for a QStringList, and so on...)