Slicer4:Layouts

From Slicer Wiki
Jump to: navigation, search
Home < Slicer4:Layouts

XML specification for a layout

  • XSD schema for layouts

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="layout">
    <xs:complexType>
      <xs:annotation>
        <xs:documentation xml:lang="en">
          A Layout must contain at least 1 item.
          If split is true and the layout type is horizontal or vertical,
           then a QSplitter is added between each subelement item.
        </xsd:documentation>
      </xs:annotation>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="unbounded" ref="item"/>
      </xs:sequence>
      <xs:attribute name="split" type="xs:boolean"/>
      <xs:attribute name="type" use="required" type="xs:layoutType"/>
    </xs:complexType>
  </xs:element>
  <xs:simpleType name="layoutType">
    <xs:restriction base="xs:NMTOKEN">
      <xs:enumeration value="horizontal" />
      <xs:enumeration value="vertical" />
      <xs:enumeration value="grid" />
      <xs:enumeration value="tab" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="item">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="layout"/>
        <xs:element ref="view"/>
      </xs:choice>
      <xs:attribute name="column" type="xs:nonNegativeInteger" />
      <xs:attribute name="colspan" type="xs:integer" />
      <xs:attribute name="multiple" type="xs:boolean"/>
      <xs:attribute name="name"/>
      <xs:attribute name="row" type="xs:nonNegativeInteger" />
      <xs:attribute name="rowspan" type="integer" />
    </xs:complexType>
  </xs:element>
  <xs:element name="view">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="property"/>
      </xs:sequence>
      <xs:attribute name="class" use="required" type="xs:string"/>
      <xs:attribute name="singletontag" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="property">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="name" use="required" type="xs:string"/>
          <xs:attribute name="action" type="xs:string"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
</xs:schema>

Adding a new layout to Slicer4

  1. Libs/MRML/vtkMRMLLayoutNode.h
    1. Add an enum to the list of available layouts
  2. Libs/MRMLLogic/vtkMRMLLayoutLogic.cxx
    1. Add a string constant containing the XML describing the layout
    2. Add a line to the AddDefaultsLayouts() method
  3. Libs/qMRMLWidgets/Resources/Icons/
    1. Add an icon
  4. Applications/SlicerQT/Resources/qSlicerMainWindow.ui
    1. Add an action using the Action Editor View
    2. Drag&Drop created action into the LayoutMenu (View->Layout)
    3. Drag&Drop created action into the LayoutToolbar
  5. Applications/SlicerQt/qSlicerMainWindow.cxx
    1. Add a line to setupMenuActions()