<commit_before>import os, sys, PyQt4, getopt
from PyQt4 import QtCore, QtGui
import vtk
from vtk.util.colors import peacock, tomato, red, white, black

from PeacockActor import PeacockActor
from ClippedActor import ClippedActor

import RendererFactory

class MeshRenderWidget(QtGui.QWidget):
  def __init__(self, tree_widget):
    QtGui.QWidget.__init__(self)
    self.tree_widget = tree_widget
    self.tree_widget.mesh_item_changed.connect(self.meshItemChanged)

    self.mesh_file_name = ''

    self.current_block_actors = {}
    self.current_sideset_actors = {}
    self.current_nodeset_actors = {}

    self.this_layout = QtGui.QVBoxLayout()
    self.setLayout(self.this_layout)

    self.vtkwidget = vtk.QVTKWidget2()

    self.renderer = vtk.vtkRenderer()
    self.renderer.SetBackground(0.2,0.2,0.2)
    self.renderer.SetBackground2(1,1,1)
    self.renderer.SetGradientBackground(1)
    self.renderer.ResetCamera()
    
    self.this_layout.addWidget(self.vtkwidget)
    self.vtkwidget.setMinimumHeight(600)
    self.vtkwidget.show()    

    self.vtkwidget.GetRenderWindow().AddRenderer(self.renderer)

    self.controls_layout = QtGui.QHBoxLayout()

    self.left_controls_layout = QtGui.QVBoxLayout()

    self.block_view_group_box = QtGui.QGroupBox('Show Blocks')
    self.block_view_group_box.setMaximumWidth(150)
#    self.block_view_group_box.setMaximumHeight(200)
    
    self.block_view_layout = QtGui.QVBoxLayout()
    self.block_view_list = QtGui.QListView()
    self.block_view_model = QtGui.QStandardItemModel()
    self.block_view_model.itemChanged.connect(self._blockViewItemChanged)
    self.block_view_list.setModel(self.block_view_model)
    self.block_view_layout.addWidget(self.block_view_list)

    self.block_view_group_box.setLayout(self.block_view_layout)
    self.left_controls_layout.addWidget(self.block_view_group_box)
    self.controls_layout.addLayout(self.left_controls_layout)


    self.right_controls_layout = QtGui.QVBoxLayout()
    self.controls_layout.addLayout(self.right_controls_layout)

    self.view_mesh_checkbox = QtGui.QCheckBox('View Mesh')
    self.view_mesh_checkbox.setToolTip('Toggle viewing of mesh elements')
    self.view_mesh_checkbox.setCheckState(QtCore.Qt.Checked)
    self.view_mesh_checkbox.stateChanged.connect(self.viewMeshCheckboxChanged)
    self.right_controls_layout.addWidget(self.view_mesh_checkbox)

    self.highlight_group_box = QtGui.QGroupBox('Highlight')
    self.highlight_group_box.setMaximumHeight(70)
    self.highlight_layout = QtGui.QHBoxLayout()
    self.highlight_group_box.setLayout(self.highlight_layout)
    self.right_controls_layout.addWidget(self.highlight_group_box)

    self.highlight_block_label = QtGui.QLabel('Block:')
    self.highlight_block_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    self.highlight_block_combo = QtGui.QComboBox()
    self.highlight_block_combo.setToolTip('Highlight a block in the mesh')
    self.highlight_block_combo.currentIndexChanged[str].connect(self.showBlockSelected)
    self.highlight_layout.addWidget(self.highlight_block_label)
    self.highlight_layout.addWidget(self.highlight_block_combo)

    self.highlight_sideset_label = QtGui.QLabel('Sideset:')
    self.highlight_sideset_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    self.highlight_sideset_combo = QtGui.QComboBox()
    self.highlight_sideset_combo.setToolTip('Highlight a sideset in the mesh')
    self.highlight_sideset_combo.currentIndexChanged[str].connect(self.showSidesetSelected)
    self.highlight_layout.addWidget(self.highlight_sideset_label)
    self.highlight_layout.addWidget(self.highlight_sideset_combo)

    self.highlight_nodeset_label = QtGui.QLabel('Nodeset:')
    self.highlight_nodeset_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    self.highlight_nodeset_combo = QtGui.QComboBox()
    self.highlight_nodeset_combo.setToolTip('Highlight a nodeset in the mesh')
    self.highlight_nodeset_combo.currentIndexChanged[str].connect(self.showNodesetSelected)
    self.highlight_layout.addWidget(self.highlight_nodeset_label)
    self.highlight_layout.addWidget(self.highlight_nodeset_combo)

    self.highlight_clear = QtGui.QPushButton('Clear')
    self.highlight_clear.setToolTip('Clear highlighting')
    self.highlight_clear.setDisabled(True)
    self.highlight_clear.clicked.connect(self.clearHighlight)
    self.highlight_layout.addWidget(self.highlight_clear)
    
    self.plane = vtk.vtkPlane()
    self.plane.SetOrigin(0, 0, 0)
    self.plane.SetNormal(1, 0, 0)

    self.clip_groupbox = QtGui.QGroupBox("Clip")
    self.clip_groupbox.setToolTip('Toggle clip mode to slice the mesh open along a plane')
    self.clip_groupbox.setCheckable(True)
    self.clip_groupbox.setChecked(False)
    self.clip_groupbox.setMaximumHeight(70)
    self.clip_groupbox.toggled[bool].connect(self._clippingToggled)
    clip_layout = QtGui.QHBoxLayout()
    
    self.clip_plane_combobox = QtGui.QComboBox()
    self.clip_plane_combobox.setToolTip('Direction of the normal for the clip plane')
    self.clip_plane_combobox.addItem('x')
    self.clip_plane_combobox.addItem('y')
    self.clip_plane_combobox.addItem('z')
    self.clip_plane_combobox.currentIndexChanged[str].connect(self._clipNormalChanged)

    clip_layout.addWidget(self.clip_plane_combobox)
    
    self.clip_plane_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
    self.clip_plane_slider.setToolTip('Slide to change plane position')
    self.clip_plane_slider.setRange(0, 100)
    self.clip_plane_slider.setSliderPosition(50)
    self.clip_plane_slider.sliderMoved[int].connect(self._clipSliderMoved)
    clip_layout.addWidget(self.clip_plane_slider)
#     vbox->addStretch(1);
    self.clip_groupbox.setLayout(clip_layout)

    self.right_controls_layout.addWidget(self.clip_groupbox)

    self.this_layout.addLayout(self.controls_layout)


    self.bounds = {}
    self.bounds['x'] = [0.0, 0.0]
    self.bounds['y'] = [0.0, 0.0]
    self.bounds['z'] = [0.0, 0.0]

#    self.draw_edges_checkbox = QtGui.QCheckBox("View Mesh")

#    self.left_controls_layout.addWidget(self.draw_edges_checkbox)

  def clear(self):
    self.highlight_block_combo.clear()
    self.highlight_sideset_combo.clear()
    self.highlight_nodeset_combo.clear()

    for block_actor_name, block_actor in self.current_block_actors.items():
      block_actor.hide()
      
    for sideset_actor_name, sideset_actor in self.current_sideset_actors.items():<commit_msg>fix stretching of mesh view<commit_after>import os, sys, PyQt4, getopt
from PyQt4 import QtCore, QtGui
import vtk
from vtk.util.colors import peacock, tomato, red, white, black

from PeacockActor import PeacockActor
from ClippedActor import ClippedActor

import RendererFactory

class MeshRenderWidget(QtGui.QWidget):
  def __init__(self, tree_widget):
    QtGui.QWidget.__init__(self)
    self.tree_widget = tree_widget
    self.tree_widget.mesh_item_changed.connect(self.meshItemChanged)

    self.mesh_file_name = ''

    self.current_block_actors = {}
    self.current_sideset_actors = {}
    self.current_nodeset_actors = {}

    self.this_layout = QtGui.QVBoxLayout()
    self.setLayout(self.this_layout)

    self.vtkwidget = vtk.QVTKWidget2()

    self.renderer = vtk.vtkRenderer()
    self.renderer.SetBackground(0.2,0.2,0.2)
    self.renderer.SetBackground2(1,1,1)
    self.renderer.SetGradientBackground(1)
    self.renderer.ResetCamera()
    
    self.this_layout.addWidget(self.vtkwidget)
    self.this_layout.setStretchFactor(self.vtkwidget, 10)

    self.vtkwidget.setMinimumHeight(600)
    self.vtkwidget.show()    

    self.vtkwidget.GetRenderWindow().AddRenderer(self.renderer)

    self.controls_layout = QtGui.QHBoxLayout()

    self.left_controls_layout = QtGui.QVBoxLayout()

    self.block_view_group_box = QtGui.QGroupBox('Show Blocks')
    self.block_view_group_box.setMaximumWidth(150)
#    self.block_view_group_box.setMaximumHeight(200)
    
    self.block_view_layout = QtGui.QVBoxLayout()
    self.block_view_list = QtGui.QListView()
    self.block_view_model = QtGui.QStandardItemModel()
    self.block_view_model.itemChanged.connect(self._blockViewItemChanged)
    self.block_view_list.setModel(self.block_view_model)
    self.block_view_layout.addWidget(self.block_view_list)

    self.block_view_group_box.setLayout(self.block_view_layout)
    self.left_controls_layout.addWidget(self.block_view_group_box)
    self.controls_layout.addLayout(self.left_controls_layout)


    self.right_controls_layout = QtGui.QVBoxLayout()
    self.controls_layout.addLayout(self.right_controls_layout)

    self.view_mesh_checkbox = QtGui.QCheckBox('View Mesh')
    self.view_mesh_checkbox.setToolTip('Toggle viewing of mesh elements')
    self.view_mesh_checkbox.setCheckState(QtCore.Qt.Checked)
    self.view_mesh_checkbox.stateChanged.connect(self.viewMeshCheckboxChanged)
    self.right_controls_layout.addWidget(self.view_mesh_checkbox)

    self.highlight_group_box = QtGui.QGroupBox('Highlight')
    self.highlight_group_box.setMaximumHeight(70)
    self.highlight_layout = QtGui.QHBoxLayout()
    self.highlight_group_box.setLayout(self.highlight_layout)
    self.right_controls_layout.addWidget(self.highlight_group_box)

    self.highlight_block_label = QtGui.QLabel('Block:')
    self.highlight_block_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    self.highlight_block_combo = QtGui.QComboBox()
    self.highlight_block_combo.setToolTip('Highlight a block in the mesh')
    self.highlight_block_combo.currentIndexChanged[str].connect(self.showBlockSelected)
    self.highlight_layout.addWidget(self.highlight_block_label)
    self.highlight_layout.addWidget(self.highlight_block_combo)

    self.highlight_sideset_label = QtGui.QLabel('Sideset:')
    self.highlight_sideset_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    self.highlight_sideset_combo = QtGui.QComboBox()
    self.highlight_sideset_combo.setToolTip('Highlight a sideset in the mesh')
    self.highlight_sideset_combo.currentIndexChanged[str].connect(self.showSidesetSelected)
    self.highlight_layout.addWidget(self.highlight_sideset_label)
    self.highlight_layout.addWidget(self.highlight_sideset_combo)

    self.highlight_nodeset_label = QtGui.QLabel('Nodeset:')
    self.highlight_nodeset_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
    self.highlight_nodeset_combo = QtGui.QComboBox()
    self.highlight_nodeset_combo.setToolTip('Highlight a nodeset in the mesh')
    self.highlight_nodeset_combo.currentIndexChanged[str].connect(self.showNodesetSelected)
    self.highlight_layout.addWidget(self.highlight_nodeset_label)
    self.highlight_layout.addWidget(self.highlight_nodeset_combo)

    self.highlight_clear = QtGui.QPushButton('Clear')
    self.highlight_clear.setToolTip('Clear highlighting')
    self.highlight_clear.setDisabled(True)
    self.highlight_clear.clicked.connect(self.clearHighlight)
    self.highlight_layout.addWidget(self.highlight_clear)
    
    self.plane = vtk.vtkPlane()
    self.plane.SetOrigin(0, 0, 0)
    self.plane.SetNormal(1, 0, 0)

    self.clip_groupbox = QtGui.QGroupBox("Clip")
    self.clip_groupbox.setToolTip('Toggle clip mode to slice the mesh open along a plane')
    self.clip_groupbox.setCheckable(True)
    self.clip_groupbox.setChecked(False)
    self.clip_groupbox.setMaximumHeight(70)
    self.clip_groupbox.toggled[bool].connect(self._clippingToggled)
    clip_layout = QtGui.QHBoxLayout()
    
    self.clip_plane_combobox = QtGui.QComboBox()
    self.clip_plane_combobox.setToolTip('Direction of the normal for the clip plane')
    self.clip_plane_combobox.addItem('x')
    self.clip_plane_combobox.addItem('y')
    self.clip_plane_combobox.addItem('z')
    self.clip_plane_combobox.currentIndexChanged[str].connect(self._clipNormalChanged)

    clip_layout.addWidget(self.clip_plane_combobox)
    
    self.clip_plane_slider = QtGui.QSlider(QtCore.Qt.Horizontal)
    self.clip_plane_slider.setToolTip('Slide to change plane position')
    self.clip_plane_slider.setRange(0, 100)
    self.clip_plane_slider.setSliderPosition(50)
    self.clip_plane_slider.sliderMoved[int].connect(self._clipSliderMoved)
    clip_layout.addWidget(self.clip_plane_slider)
#     vbox->addStretch(1);
    self.clip_groupbox.setLayout(clip_layout)

    self.right_controls_layout.addWidget(self.clip_groupbox)

    self.this_layout.addLayout(self.controls_layout)
    self.this_layout.setStretchFactor(self.controls_layout, 1)

    self.bounds = {}
    self.bounds['x'] = [0.0, 0.0]
    self.bounds['y'] = [0.0, 0.0]
    self.bounds['z'] = [0.0, 0.0]

#    self.draw_edges_checkbox = QtGui.QCheckBox("View Mesh")

#    self.left_controls_layout.addWidget(self.draw_edges_checkbox)

  def clear(self):
    self.highlight_block_combo.clear()
    self.highlight_sideset_combo.clear()
    self.highlight_nodeset_combo.clear()

    for block_actor_name, block_actor in self.current_block_actors.items():
      block_actor.hide()
      
    for sideset_actor_name, sideset_actor in self.current_sideset_actors.items():
{'fraction_non_alphanumeric': 0.09953438668803909, 'fraction_numerical': 0.008167315472101366, 'mean_word_length': 5.035006909258406, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7431582', 'n_tokens_mistral': 4615, 'n_tokens_neox': 4398, 'n_words': 487}