Com\’è dura la professione!

5 aprile 2013

Springs and forces in QXmlEdit 0.8.5

Filed under: Open Source,QT,xml,qxmledit — lbell @ 20:45
Tags: , ,

A force directed layout graph (http://en.wikipedia.org/wiki/Force-directed_graph_drawing) is is well suited for hierarchical structures or directed graph, perfect to visualize the relationships existent between the elements of a XML structure.

QXmlEdit 0.8.5 lets you view the content of the current data or another file of your choice creating a graphic scene of the current screen dimensions, inserts the graphical representation of the elements in random positions inside it. The nodes migrate into an equilibrium configuration automatically under the application of a force similar to the binding of the electric particles, to reach an optimal distribution in the general case. A damping factor is applied to avoid a long stabilization time of the configuration.

The panel can be reached with one of these methods depending on the data to show:

  • The current file open in the editor

Edit a file and select the menu item “Relations” from the “View” menu.

  • A file on the file system

Choose the “Relations…” item from the”Tools” menu and use the browse button to load a file or drop in a file.

  • The map panel

From the Tools menu, choose the View Map item, before loading any file, check the the “Analyze relations” option; after loading the file, operate the “View Relations…” button.

When the panel is open it is possible to

  • View the structure

The panel shows the relations between elements. Each circle represent an XML element. The lines show a relationship between element types. To evenly distribute the elements on the view area, each element is repelling the others, the nodes are connected by simulated springs.

strcture

  • Move the items

The elements can be dragged with the mouse causing the movement of the other elements until reaching a new equilibrium point. Zoom controls can modify the view.

Each time the “Reset” button is pressed, a new initial casual combination is generated and the elements move themselves to reach a new equilibrium point.

img_06

  • Isolate a single element

Checking the “Center Selected” option, hides all the elements that are not diretcly connected with the selected one. By clicking on one node, you can filter the display of nodes showing only the data related to the selected element.

img_08

The data can be shown also in tabluar format

Each element on the rows show its absolute and relative count and the references made to any other element.

img_09

The settings can be tuned.

 The intensity of the replusive force can be changed using the “Force” slider. The effective distance that the force can act can be set using the “Radius” slider. The lenght of the lines connecting elements can be regulated using the “Spring” slider.

31 agosto 2012

Visual comparison between XML Schema files in QXmlEdit

Filed under: Open Source,QT,xml,qxmledit,xsd — lbell @ 21:31
Tags: , , ,

Visualizing a comparison between files is first of all a semantic operation. The comparison of source code of programs usually is done at level of source lines, and the level of concepts, classes and methods in this case, is entirely left to the user. There is no doubt that any line of source code is important, but while in the programming world the abstraction level is always raising, using protocols, interfaces and as last resource, languages better suited for the job, the comparison of variations of different versions is always done at character level.

The comparison of XML files is similar to a source code comparison, given that the information carried by a file are not related to the XML syntax, but to the meaning associated with the particular XML structure.

XML Schema files can be compared at XML elements level, the analogue of the source code comparison, but understanding the difference of the information carried by of the different XSD files is not easy.

The future 8.3 QXmlEdit, now on development trunk, follows another approach, transforming the data into concepts, element, types, and so on, then comparing the concepts. Given that the XML Schema follows a strictly hierarchical model, the reference and the target schema are scanned in parallel for inner contents. Where an element in the reference schema has an equivalent on the target schema, is compared for equality on the basis of the element type and name. If the two values are equals, the element are posed in correlation and any other difference ends in modified items. The comparison continue recursively.

The schema is then presented, using colors that show at a glance only the reference schema, highlighting the changes, showing the information in their context. The key is shift the focus from the comparison as operation, to the variation of the information in the schema context.

Image

19 marzo 2012

Visualizing XML trees with QXmlEdit

Filed under: xml,qxmledit — lbell @ 22:36

Why to view XML using letters only?

Exploring big XML files trying to understand how the data are distributed in the file is difficult when the size of the files is relevant respect to the available memory.

Basically there are three points that are interesting in dimensions and distribution:

  • Data size.
  • Number of children.
  • Tree deep.

Given that the XML structure is a hierarchical one, in principle there is no difference between visualization and exploration of a XML structure and exploration of datasets used in other fields from the physics to the biology; there are already a lot of well known methods to handle this type of data, from data handling to image processing.

What is missing in a typical XML editor are visualization modes to give an idea of how the data are distributed at a bird’s eye view. The textual or tree map representation are often or too detailed, or not detailed enough.
QXmlEdit under development will show the data graphically giving the possibility to the user to use its eyes to evaluate the data, losing the details in a zoom out or delving deeper to investigate data structure.

To form the map the following data transformations are done:

The tree is converted in a grid, de-normalizing it.

Let’s suppose to have these start data, the following transformation is applied.

After that, the rows with the same logical data can be regrouped as in a tree map. The color of each cell can be the value of the observed quantity.

The map can be zoomed and navigated, selecting an area or descending in hierarchical mode.

23 ottobre 2011

QXmlEdit 0.5.3 released

Filed under: Open Source,QT,qxmledit,xml — lbell @ 15:14

QXmlEdit, a simple XML editor, is born to explore Qt libraries and then gradually added features becoming a sort of swiss army knife.

In its latest release, 0.5.3, there is a tool to split XML files of any size in smaller fragments. It is also possible to examine a fragment at time in the user interface, without loading it completely in memory.

You can download QXmlEdit at the following link: http://code.google.com/p/qxmledit/downloads

This little tutorial, extracted from the manual, shows how to use the file splitter in details:

When starting, the program will open a welcome dialog leading to the most common operations. Choose “Split a file”. If you choose to hide the dialog next time the program restart and change your mind, you can reactivate it in the configuration panel. You can access this feature also from the menu Tools.

(more…)

3 ottobre 2011

Se ne va il bello del computer

Filed under: cosi' va il mondo,Mac,Vaneggiamenti — lbell @ 20:43

Steve Jobs si è dimesso da CEO di Apple.

Il cambio di un dirigente di una ditta non ha solitamente grosse ricadute sugli utenti ed in certi casi neppure sulla vita della ditta stessa, ed il fatto che le ditte sopravvivano ai propri amministratori ne è una prova.

Steve Jobs è stato un’eccezione e con lui rischia di scomparire un parte di quello che ha reso il personal computer affascinante, almeno per chi è appassionato di tecnologia.

Chi ha iniziato ad usare i personal computer da piccolo, ha vissuto l’epoca degli 8 e dei 16 bit, con macchine che pur differenziandosi per potenza, dal mondo dell’hobbistico al professionale, si assomigliavano tutte nel modello di utilizzo e di programmazione. La differenza la facevano le periferiche disponibili ed il software per gestirle (chiamarli driver sarebbe forse troppo). Un hard disk ed un buon alimentatore differenziava le macchine di fascia alta da quelle di uso casalingo.

Era possibile scrivere simulazioni, risoluzioni di problemi matematici, piccoli database in Assembler, Basic o Pascal. All’uscita di un nuovo modello ci si procurava i manuali del relativo microporcessore e dell’immancabile versione di Basic per poter programmare, come quando dovendosi recare in un Paese straniero, ci si premura di procurarsi un dizionario ed un manuale di conversazione.

L’avvento dei sistemi ideati da Jobs ha cambiato tutto.

All’uscita del Macintosh in Italia, cercando i manuali del suo Basic, per capire come fosse possibile realizzare un programma come Mac Paint, restai allibito davanti ai volumi di Inside Macintosh.

Non si trattava solo di un sistema con un’interfaccia utente mai vista prima, di una grafica che sembrava uscita da una tipografia, ma anche dell’organizzazione della documentazione, finalmente fuori dai binari di una raccolta di trucchetti, e di come veniva teorizzata la via per scrivere i programmi, del primo tentativo di programmazione object oriented diffusa al di fuori dell’accademia.

Si trattava di tutto quanto assieme, un salto di una decina di anni avanti a tutto quello che era apparso fino a quel momento, quasi in ogni particolare della macchina, ahimè anche nel prezzo, decisamente fuori portata per le tasche di molti, me compreso.

Più tardi appresi che la macchina era curata anche al suo interno, in luoghi che l’utente non avrebbe mai raggiunto (si veda la storia su http://folklore.org/StoryView.py?project=Macintosh&story=PC_Board_Esthetics.txt).

Qualche tempo più tardi, al mio primo lavoro, parlando dell’argomento, un ingegnere mi disse letteralmente “real programmers don’t use icons”. Oggi tutti i sistemi sono essenzialmente dei Macintosh, perfino i telefoni.

Quando uscì il NeXT, forse il capolavoro di Jobs, abituato ai sistemi che le altre ditte comunemente costruivano per il mercato professionale, mi chiesi come fosse possibile avere pensato così in grande nel produrre qualcosa che comunque era soggetto alle regole di mercato e come mai nessun altro lo avesse fatto.

Il NeXT era esagerato in tutto e, come al solito, anni avanti agli altri sistemi, soprattutto nel software. Il Macintosh di oggi non è che la sua evoluzione adattata ai tempi.

I sistemi progettati da Jobs sono sempre stati innovativi e curati con perfezione maniacale. Se pure Jobs non ha scritto una riga di codice, la sua mano si vede in ogni prodotto che è sempre un piccolo gioiello.

Jobs è stato non solo geniale, ma ha segnato il proprio tempo con visioni che andavano al di là del presente. Come lui, nel suo campo sono stati, ognuno a modo suo ed in misura diversa, pochi altri: Clive Sinclair, Richard Stallman, Linus Torvalds, Alan Kay, Jay Miner fra quelli che conosco.

Quello che Jobs ci ha insegnato è che anche nel mondo del lavoro, a volte così concreto da sfiorare la grettezza, è possibile realizzare qualcosa di solido e di elegante, che va al di là di quello che sembra possibile quando ci si accontenta di fare quello che si è sempre fatto, perché si è sempre fatto così.

A proposito di Jobs mi sembra giusto chiudere con una citazione da “Cena ad Audoghast” di B. Sterling:

 “Non mi fiderei di nessun indovino del commercio. Per conoscere il mercato bisogna conoscere il cuore della gente, e per questo occorre un buon poeta.”

4 settembre 2011

QXmlEdit gains a brand new navigator

Filed under: Open Source,QT,qxmledit,Uncategorized,xml — lbell @ 19:52

The 0.5.1 release of QXmlEdit brings a XSD types navigator. An index panel with the recap of types and root elements and attributes and navigation items is a great helper when browsing complex schema.

The navigation is possible in two ways:

  • Double clicking an item on the types list centers the relative item in the graphics view.

  • Selecting an item with a reference to a type in the graphics view and using the context menu.

While jumping from a type to another one, the previous item is remembered and it possible to return to it as is usual with Internet browsers.

A bonus of the navigator is the possibility to export the graphical view in SVG or PDF format.

The types and elements can be searched and the navigation panel can be hidden to leave all the available space to the schema representation.

The navigator is now accessible directly from the main window if the content declares itself as a XML Schema type file.

XSD viewer screenshot

25 luglio 2011

QXmlEdit 0.5.0: YAXV (Yet Another XSD Viewer)

Filed under: Open Source,QT,qxmledit,xml — lbell @ 20:24

If it is true that a complex idea can be examined under different prospectives, then a XML Schema viewer can be useful. XML Schema concepts can be modeled with a plain text editor, but QXmlEdit in the 0.5 version can help with a new graphical plugin.

What’s really difficult in such a program is to establish a mapping between the images that the program provides and the concepts that the user has in mind when interacting with them. This mapping is even more difficult if the viewer will be transformed in an editor in some future.

The program needs a cut, it is important to determine which are the main concepts to show and what needs to be removed from the scene. If all the objects defined by the language have the same importance, the scene will be filled with a lot of informations, hiding the basic concepts that the user is trying to model, making the visual editor almost useless compared to a text-based editor.

To achieve this goal, some information, especially those relating to the elements and the types must be automatically and silently changed as the user decides to change the relationship graphically.

A small change in terms of visual representation, such as adding an attribute to an element, has great implications in terms of XSD syntax. When the user decides that an element can have an attribute, the semantic change is very small, but for the scheme it may involve the transformation of a simple type in a complex one.

To access the XSD Viewer in QXmlEdit, load a XSD Schema file in the editor, then use the Tools > Plugins > XSD Viewer menu.

11 aprile 2011

Delegate a delegate in a Qt View

Filed under: QT — lbell @ 20:59

The data presentation in a Qt Item View like a TreeView or a TableView is made by means of components that implement a QAbstractItemDelegate interface.

Write a custom delegate to gain full control on how the data are rendered forces us to face all the subtle details and intricacy of the measuring and styling of graphics items with the risk of producing a component that does not fit well with the style used in the host system. Moreover, speaking in a C++ term, we don’t know what is the base class that a particular view is using, so we can’t subclassing it to alter its behavior.

If our needs are limited, for example, to display a decoration over a read only standard item, a simple solution can be to use the existing view delegate to do the hard work, then render the decoration over the painted surface.

We can create a delegate deriving from QAbstractItemDelegate class, inquire the view that we want to manipulate about its actual delegate and store it as an internal variable of the new delegate. Our class can act as a bridge, implementing all the interface functions and the slots of a delegate and redirect incoming calls to the old delegate.

Our class will look like this (some code omitted for clarity)

class ElementItemDelegate : public QAbstractItemDelegate
{
    Q_OBJECT
    QAbstractItemDelegate *baseDelegate;
public:
    explicit ElementItemDelegate(QAbstractItemDelegate *newBaseDelegate, QObject *parent = 0);
    virtual ~ElementItemDelegate();
    virtual QWidget * createEditor () const;
    virtual bool editorEvent ( );
    virtual void paint ( ... ) const;
...
};

At the window creation we can retrieve the actual delegate from e. g. a tree widget and pass it to our delegate:

void MainWindow::setUpDelegates()
{
    QAbstractItemDelegate *oldDelegate = treeWidget->itemDelegate();
    ...
    ElementItemDelegate *newDelegate = new ElementItemDelegate( oldDelegate, this );
    ...
    treeWidget->setItemDelegateForColumn(0, newDelegate);
}

Each incoming call to our delegate is then redirected to the existing delegate.
The only method we are interested about is the paint() one. We let the old delegate do the hard work, then we paint:

void ElementItemDelegate::paint ( QPainter *painter, const QStyleOptionViewItem & option, 
   const QModelIndex & index ) const
{
    QStyleOptionViewItemV4 option4(option);
    // call the default delegate
    baseDelegate->paint(painter, option, index );
    Element * element = Element::fromModelIndex(index);
    if( NULL != element ) {
        QRect markRect = option.rect;
        if( option4.viewItemPosition == QStyleOptionViewItemV4::Beginning ) {
            markRect.setLeft(0);
        }
        markRect.setWidth(WIDTH_BAND);
        if( element->saved() ) {
            painter->fillRect(markRect, savedBrush);
        } else if ( element->edited() ) {
            painter->fillRect(markRect, editedBrush);
        } else {
            painter->fillRect(markRect, normalBrush);
        }
    }
}

13 marzo 2011

In difesa della scuola pubblica italiana

Filed under: Uncategorized — lbell @ 22:00

Un politico influente, attualmente in crisi, ha cercato di ingraziarsi i propri sostenitori attaccando la scuola pubblica italiana.

Non si può tacere di fronte ad una cosa del genere; la convinzione che la scuola pubblica appartenga ad una parte politica e come tale vada combattuta, è preoccupante.

Per fortuna sabato si è tenuta una manifestazione in favore della scuola pubblica in diverse città italiane

Alla manifestazione cui ho assistito ho visto solo presone che sembravano appartenere alla categoria dei docenti e mi sono chiesto dove fossero gli altri e perché la cosa non interessasse tutti.

La vista dei professori che indossavano sulle spalle la bandiera italiana mi ha fatto ricordare di quando da piccolo vedevo i lavoratori vestire nello stesso modo la bandiera rossa, ed ho realizzato quanto abbiamo perso in questi anni se la bandiera nazionale è diventata solo uno stendardo di parte.

Ma solo ai docenti deve interessare questo argomento?

Fra i primi danneggiati da una scuola elitaria ci sono gli imprenditori che vedranno ridotto, ad esempio, il numero di ingegneri bravi e motivati tra cui reclutare i nuovi assunti dato che si restringerà la base di chi può permettersi di frequentare l’università. Saranno costretti a reclutare gli ingegneri all’estero, in Paesi (Cina, …) in cui comunque la formazione è delegata alla scuola pubblica.

L’idea della scuola pubblica sopravvisse perfino alla restaurazione sopraggiunta alla fine del periodo napoleonico, perché ci si accorse che è un valore.

La scuola pubblica è una conquista e non un danno per il Paese.

22 dicembre 2010

Explore a XML file structure with QXmlEdit

Filed under: Open Source,QT,qxmledit,xml — lbell @ 22:08
Tags: , ,

One of QXmlEdit peculiar characteristics is the possibility to change the quantity and the type of informations shown on a XML file to examine it from various prospectives.

If the XML file is very large and complex it happens to focus on some details missing the big picture. Let us take for example a Qt user interface file, we can face the following situation:


 

it is very difficult, at least for me, to follow the widgets’s structure or differentiate between them. As a first help we can activate a display style that can list in the space reserved to element tag name, the value of one or more attributes that can characterize the element itself. The predefined style provided with QXmlEdit installer displays near to the element tag, the value of ‘name’, ‘id’ or ‘build’ attributes, if any. The styles can be created and installed by the end users; they can be applied using the ‘paint can’ icon button at the bottom right of the data tree.


The style makes the visualization more intuitive and the data structure stand out very quickly.

 

To solve the problem of seeing the element text together with his tag, we can activate the compact view visualization as shown in the following screenshot. The text, if present and if no attributes exist, appears in the column reserved to the attributes with a different color.


 

We can have an overview of the XML file while maintaining the desired level of detail.


Pagina successiva »

The Rubric Theme. Blog su WordPress.com.

Iscriviti

Ricevi al tuo indirizzo email tutti i nuovi post del sito.