text: /*==============================================================================
  
    Program: 3D Slicer
  
    Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
    Queen's University, Kingston, ON, Canada. All Rights Reserved.
  
    See COPYRIGHT.txt
    or http://www.slicer.org/copyright/copyright.txt for details.
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  
    This file was originally developed by Csaba Pinter, PerkLab, Queen's University
    and was supported through the Applied Cancer Research Unit program of Cancer Care
    Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
  
  ==============================================================================*/
  
  #ifndef __qSlicerSubjectHierarchyLabelMapsPlugin_h
  #define __qSlicerSubjectHierarchyLabelMapsPlugin_h
  
  // SubjectHierarchy includes
  #include "qSlicerSubjectHierarchyAbstractPlugin.h"
  
  #include "qSlicerVolumesSubjectHierarchyPluginsExport.h"
  
  class qSlicerSubjectHierarchyLabelMapsPluginPrivate;
  class vtkMRMLNode;
  class vtkMRMLScalarVolumeNode;
  class vtkMRMLSubjectHierarchyNode;
  
  // Due to some reason the Python wrapping of this class fails, therefore
  // put everything between BTX/ETX to exclude from wrapping.
  // TODO investigate why the wrapping fails:
  //   https://www.assembla.com/spaces/slicerrt/tickets/210-python-wrapping-error-when-starting-up-slicer-with-slicerrt
  //BTX
  
  /// \ingroup Slicer_QtModules_SubjectHierarchy_Plugins
  class Q_SLICER_VOLUMES_SUBJECT_HIERARCHY_PLUGINS_EXPORT qSlicerSubjectHierarchyLabelMapsPlugin : public qSlicerSubjectHierarchyAbstractPlugin
  {
  public:
    Q_OBJECT
  
  public:
    typedef qSlicerSubjectHierarchyAbstractPlugin Superclass;
    qSlicerSubjectHierarchyLabelMapsPlugin(QObject* parent = NULL);
    virtual ~qSlicerSubjectHierarchyLabelMapsPlugin();
  
  public:
    /// Determines if a non subject hierarchy node can be placed in the hierarchy, and gets a confidence
    ///   value for a certain MRML node (usually the type and possibly attributes are checked)
    /// \param nodeToAdd Node to be added to the hierarchy
    /// \param parent Prospective parent of the node to add.
    ///   Default value is NULL. In that case the parent will be ignored, the confidence numbers are got based on the to-be child node alone.
    /// \return Floating point confidence number between 0 and 1, where 0 means that the plugin cannot handle the
    ///   node, and 1 means that the plugin is the only one that can handle the node (by type or identifier attribute)
    virtual double canAddNodeToSubjectHierarchy(vtkMRMLNode* nodeToAdd, vtkMRMLSubjectHierarchyNode* parent=NULL)const;
  
    /// Determines if the actual plugin can handle a subject hierarchy node. The plugin with
    /// the highest confidence number will "own" the node in the subject hierarchy (set icon, tooltip,
    /// set context menu etc.)
    /// \param node Note to handle in the subject hierarchy tree
    /// \return Floating point confidence number between 0 and 1, where 0 means that the plugin cannot handle the
    ///   node, and 1 means that the plugin is the only one that can handle the node (by node type or identifier attribute)
    virtual double canOwnSubjectHierarchyNode(vtkMRMLSubjectHierarchyNode* node)const;
  
    /// Get role that the plugin assigns to the subject hierarchy node.
    ///   Each plugin should provide only one role.
    Q_INVOKABLE virtual const QString roleForPlugin()const;
  
    /// Get icon of an owned subject hierarchy node
    /// \return Icon to set, NULL if nothing to set
    virtual QIcon icon(vtkMRMLSubjectHierarchyNode* node);
  
    /// Get visibility icon for a visibility state
    virtual QIcon visibilityIcon(int visible);
  
    /// Generate tooltip for a owned subject hierarchy node
    virtual QString tooltip(vtkMRMLSubjectHierarchyNode* node)const;
  
    /// Set display visibility of a owned subject hierarchy node
    virtual void setDisplayVisibility(vtkMRMLSubjectHierarchyNode* node, int visible);
  
    /// Get display visibility of a owned subject hierarchy node
    /// \return Display visibility (0: hidden, 1: shown, 2: partially shown)
    virtual int getDisplayVisibility(vtkMRMLSubjectHierarchyNode* node)const;
  
    /// Get node context menu item actions to add to tree view
    Q_INVOKABLE virtual QList<QAction*> nodeContextMenuActions()const;
  
    /// Show context menu actions valid for  given subject hierarchy node.
    /// \param node Subject Hierarchy node to show the context menu items for. If NULL, then shows menu items for the scene
    virtual void showContextMenuActionsForNode(vtkMRMLSubjectHierarchyNode* node);
  
  protected:
    /// Show volume in slice viewers. The argument node becomes the background, and the previous
    /// background becomes the foreground with 50% transparency.
    void showLabelMap(vtkMRMLScalarVolumeNode* node, int visible=1);
  
    /// Update selection node based on current volumes visibility (if the selection is different in the slice viewers, then the first one is set)
    /// TODO: This is a workaround (http://www.na-mic.org/Bug/view.php?id=3551)
    void updateSelectionNodeBasedOnCurrentLabelMapVisibility()const;
    /// Determine labelmap selection (if the selection is different in the slice viewers, then the first one is set)
    /// TODO: This is a workaround (http://www.na-mic.org/Bug/view.php?id=3551)
    std::string getSelectedLabelmapVolumeNodeID()const;
  
  protected slots:
    /// Toggle between labelmap outline display in the slice views
    void toggleLabelmapOutlineDisplay(bool checked);
  
  protected:
    QScopedPointer<qSlicerSubjectHierarchyLabelMapsPluginPrivate> d_ptr;
  
  private:
    Q_DECLARE_PRIVATE(qSlicerSubjectHierarchyLabelMapsPlugin);
    Q_DISABLE_COPY(qSlicerSubjectHierarchyLabelMapsPlugin);
  };
  
  //ETX
  
  #endif
  