<commit_before>#============================================================================
#
# Copyright (c) Kitware Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# 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.
#
#============================================================================

import imp, sys, os, unittest

from __main__ import vtk, qt, ctk, slicer

from InteractiveSegmentTubesLogic import *

#
# Interactive Segment Tubes widget
#

class InteractiveSegmentTubesWidget(AbstractInteractiveSegmentTubes):

  def __init__(self, parent=None):
    AbstractInteractiveSegmentTubes.__init__(self)

    self.widget = None
    self.moduleName = 'Interactive Segment Tubes'
    self.logic = InteractiveSegmentTubesLogic()

    if not parent:
      self.parent = slicer.qMRMLWidget()
      self.parent.setLayout(qt.QVBoxLayout())
      self.parent.setMRMLScene(slicer.mrmlScene)
    else:
      self.parent = parent
    self.layout = self.parent.layout()
    if not parent:
      self.setup()
      self.parent.show()

  def setup(self):
    self.loadUi('InteractiveSegmentTubes.ui')
    self.widget.setMRMLScene(slicer.mrmlScene)

    # Connect widget internal signals here:
    self.get('SeedsSizeSliderWidget').connect('valueChanged(double)', self.updateMRMLFromWidget)
    self.get('SeedsShowStatusCheckBox').connect('stateChanged(int)', self.updateMRMLFromWidget)

    # Connect widget signals to logic here:
    self.get('OutputNodeComboBox').connect('nodeAddedByUser(vtkMRMLNode*)', self.logic.addDisplayNodes)
    self.logic.setGUICallback(self.onSegmentTubesUpdated)

    self.get('InputNodeComboBox').connect('currentNodeChanged(vtkMRMLNode*)', self.logic.setInputNode)
    self.get('OutputNodeComboBox').connect('currentNodeChanged(vtkMRMLNode*)', self.logic.setOutputNode)

    # Connect signals that needs to be treated by both logic and GUI here:
    self.get('ApplyPushButton').connect('clicked(bool)', self.run)
    self.get('SeedPointNodeComboBox').connect('currentNodeChanged(vtkMRMLNode*)', self.setSeedNode)

  def enter(self):
    slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)
    self.updateWidgetFromMRML()

  def exit(self):
    pass

  def run( self, run ):
    if run:
      self.get('ApplyPushButton').setText('Stop')
    else:
      self.get('ApplyPushButton').setText('Start')
    self.logic.run(run)

  def onSegmentTubesUpdated( self, cliNode, *unused ):
    if not cliNode:
      return
<commit_msg>Set place mode persistence for Interactive Segment Tubes<commit_after>#============================================================================
#
# Copyright (c) Kitware Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# 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.
#
#============================================================================

import imp, sys, os, unittest

from __main__ import vtk, qt, ctk, slicer

from InteractiveSegmentTubesLogic import *

#
# Interactive Segment Tubes widget
#

class InteractiveSegmentTubesWidget(AbstractInteractiveSegmentTubes):

  def __init__(self, parent=None):
    AbstractInteractiveSegmentTubes.__init__(self)

    self.widget = None
    self.moduleName = 'Interactive Segment Tubes'
    self.logic = InteractiveSegmentTubesLogic()

    if not parent:
      self.parent = slicer.qMRMLWidget()
      self.parent.setLayout(qt.QVBoxLayout())
      self.parent.setMRMLScene(slicer.mrmlScene)
    else:
      self.parent = parent
    self.layout = self.parent.layout()
    if not parent:
      self.setup()
      self.parent.show()

  def setup(self):
    self.loadUi('InteractiveSegmentTubes.ui')
    self.widget.setMRMLScene(slicer.mrmlScene)

    # Connect widget internal signals here:
    self.get('SeedsSizeSliderWidget').connect('valueChanged(double)', self.updateMRMLFromWidget)
    self.get('SeedsShowStatusCheckBox').connect('stateChanged(int)', self.updateMRMLFromWidget)

    # Connect widget signals to logic here:
    self.get('OutputNodeComboBox').connect('nodeAddedByUser(vtkMRMLNode*)', self.logic.addDisplayNodes)
    self.logic.setGUICallback(self.onSegmentTubesUpdated)

    self.get('InputNodeComboBox').connect('currentNodeChanged(vtkMRMLNode*)', self.logic.setInputNode)
    self.get('OutputNodeComboBox').connect('currentNodeChanged(vtkMRMLNode*)', self.logic.setOutputNode)

    # Connect signals that needs to be treated by both logic and GUI here:
    self.get('ApplyPushButton').connect('clicked(bool)', self.run)
    self.get('SeedPointNodeComboBox').connect('currentNodeChanged(vtkMRMLNode*)', self.setSeedNode)

  def enter(self):
    slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)
    self.updateWidgetFromMRML()

    interactionNode = slicer.app.applicationLogic().GetInteractionNode()
    interactionNode.SetPlaceModePersistence(1)

  def exit(self):
    pass

  def run( self, run ):
    if run:
      self.get('ApplyPushButton').setText('Stop')
    else:
      self.get('ApplyPushButton').setText('Start')
    self.logic.run(run)

  def onSegmentTubesUpdated( self, cliNode, *unused ):
    if not cliNode:
      return

{'fraction_non_alphanumeric': 0.15125911199469846, 'fraction_numerical': 0.0014910536779324055, 'mean_word_length': 4.832850241545894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2898747', 'n_tokens_mistral': 1800, 'n_tokens_neox': 1727, 'n_words': 414}