|
|
(3 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | = Coding Conventions =
| + | <big>'''Note:''' We are migrating this content to the slicer.org domain - <font color="orange">The newer page is [https://www.slicer.org/wiki/Slicer3:Style_and_Conventions here]</font></big> |
− | | |
− | * Code that inherits from VTK classes should follow VTK coding conventions for naming, intentation, etc.
| |
− | * This will simplify debugging of code that relies on the VTK object model, command observer structures, and other key VTK elements.
| |
− | | |
− | == Naming ==
| |
− | | |
− | * Acronyms should be written in all CAPS.
| |
− | ** For example: '''RASToSlice''' not RasToSlice
| |
− | ** '''vtkMRML''' not vtkMrml
| |
− | * Words should be spelled out and not abreviated
| |
− | ** For example: '''GetWindow''' not GetWin
| |
− | * Local variable should start with a lower case.
| |
− | ** For example:
| |
− | | |
− | void vtkSlicerSliceLogic::SetForegroundLayer(vtkSlicerSliceLayerLogic *ForegroundLayer)
| |
− | | |
− | should be
| |
− | | |
− | void vtkSlicerSliceLogic::SetForegroundLayer(vtkSlicerSliceLayerLogic *foregroundLayer)
| |
− | | |
− | * Member variable should start with a capital letter, and in implementation should be used in conjunction with 'this->' convention
| |
− | ** For example
| |
− | | |
− | class Node {
| |
− | Object &Foo();
| |
− | Object Bla;
| |
− | };
| |
− | Object& Node::Foo() {
| |
− | return this->Bla;
| |
− | }
| |
− | | |
− | * '''Module GUI classes''' (those derived from vtkSlicerComponentGUI or vtkSlicerModuleGUI, which contain widgets, GUI building and mediator methods) should all have the prefix ''vtkSlicer'' and the suffix ''GUI''.
| |
− | ** For example: vtkSlicerVolumesGUI or vtkSlicerFiducialsGUI
| |
− | * For now, '''widgets''' derived from vtkKW classes should end in ''Widget'', ''Editor'', or ''Viewer'' (this convention may change)
| |
− | ** For example: vtkSlicerSliceViewerWidget or vtkSlicerWindowLevelThresholdEditor
| |
− | | |
− | == Comments ==
| |
− | | |
− | * include extensive comments in the header files
| |
− | * '''keep the comments up to date as the code changes'''
| |
− | * use the keyword '''TODO''' to flag spots in the code that need to be revisited
| |
− | | |
− | == Library Dependencies ==
| |
− | | |
− | * MRML classes should only depend on vtk and itk
| |
− | * Logic classes depend on MRML to store state
| |
− | * Logic classes should encapsulate vtk and itk pipelines to accomplish specific slicer tasks (such as resampling volumes for display)
| |
− | * GUI classes can depend on MRML and Logic and KWWidgets
| |
− | * Wherever possible, GUI functionality should be encapsulated as subclasses of vtkKWCompositeWidget with no dependence on MRML or Logic
| |
− | * GUI classes serve as the mediator between the Logic and MRML classes on one side and the 'pure UI and visualization' code in KWWidgets and VTK on the other side.
| |
− | | |
− | == GUI style guidelines (just a start!...) ==
| |
− | | |
− | * Use grooved relief for frames to clarify functional groupings of widgets; otherwise use no (flat) relief.
| |
− | * Wherever possible, use xpad = ypad = 2 between widgets; use xpad = ypad = 1 to tightly group related widgets.
| |
− | * Capitalize the first letter in any text specified for a label or button.
| |
− | * Try to use brief phrases when specifying text for a label or button rather than using sentences or sentence fragments ( use "Load Volumes" instead of "Choose a volume to load")
| |
− | * Provide fully descriptive tool tips with each widget defined.
| |
− | * Slicer's main GUI panel's dimensions are defined in slicer3/Base/GUI/vtkSlicerGUILayout.cxx; currently the GUI panel minimum width is set to 300 pixels; widgets wider than this will be clipped in Slicer's default window configuration.
| |
− | | |
− | == Development Practices ==
| |
− | | |
− | * While developing code, enable VTK_DEBUG_LEAKS in your vtk build and be sure to clean up and leaks that arise from your contributions.
| |
− | | |
− | = Coordinate Systems =
| |
− | | |
− | * World space for 3D Views is in RAS (Right Anterior Superior) space
| |
− | * All units are expressed in Millimeters (mm)
| |