<div dir="ltr"><div>Greetings,</div><div>I am new to VTK so may be my question is very basic.</div><div><br></div><div>I have following code, where the aim is to be able to change the lines colors using dynamically based on data we get from <code>QColorDialog</code>. if I apply the color directly to <code>vtkActor</code> and re-render the window then it just works fine.
But eventually I wan to be able to change individual line Points color and thats why I am setting <code>self.linesPolyData.GetCellData().SetScalars(self.colors)</code> when I change the color using <code>QPushButton</code> in function <code>def select_color(self):</code> it doesn't re-render the lines with new color. What am I doing wrong?</div><div><br></div><div><pre class="inbox-inbox-lang-py inbox-inbox-prettyprint inbox-inbox-prettyprinted"><code><span class="inbox-inbox-kwd">from</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">Analysis</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Channel</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-pun">*</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> vtk
</span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> numpy </span><span class="inbox-inbox-kwd">as</span><span class="inbox-inbox-pln"> np
</span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> itertools
</span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> sys
</span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> math
</span><span class="inbox-inbox-kwd">from</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">PyQt5</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QtGui</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QtCore</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">from</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">PyQt5</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">QtWidgets</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QApplication</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QWidget</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QGridLayout</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QScrollArea</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QPushButton</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QColorDialog</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">from</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">qt</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">QVTKRenderWindowInteractor</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-kwd">import</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QVTKRenderWindowInteractor</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Qt Class which will render the objects</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">class</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">MainWindow</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-typ">QWidget</span><span class="inbox-inbox-pun">):</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">def</span><span class="inbox-inbox-pln"> __init__</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> parent </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-kwd">None</span><span class="inbox-inbox-pun">):</span><span class="inbox-inbox-pln">
super</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-pln">__init__</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">layout </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QGridLayout</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color_button </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QPushButton</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-str">'Select Color'</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">layout</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">addWidget</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color_button</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color_button</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">clicked</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">connect</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">select_color</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-pun">[</span><span class="inbox-inbox-lit">255</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">255</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">255</span><span class="inbox-inbox-pun">]</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">colors </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkUnsignedCharArray</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">colors</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">SetNumberOfComponents</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">4</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Create the polydata where we will store all the geometric data</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkPolyData</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Create three points</span><span class="inbox-inbox-pln">
origin </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-pun">[</span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">]</span><span class="inbox-inbox-pln">
p0 </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-pun">[</span><span class="inbox-inbox-lit">1.0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">]</span><span class="inbox-inbox-pln">
p1 </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-pun">[</span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">1.0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0.0</span><span class="inbox-inbox-pun">]</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Create a vtkPoints container and store the points in it</span><span class="inbox-inbox-pln">
pts </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkPoints</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
pts</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextPoint</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">origin</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
pts</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextPoint</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">p0</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
pts</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextPoint</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">p1</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">SetPoints</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">pts</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Create the first line (between Origin and P0)</span><span class="inbox-inbox-pln">
line0 </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkLine</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
line0</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetPointIds</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetId</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-com"># the second 0 is the index of the Origin in linesPolyData's points</span><span class="inbox-inbox-pln">
line0</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetPointIds</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetId</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">1</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">1</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-com"># the second 1 is the index of P0 in linesPolyData's points</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Create the second line (between Origin and P1)</span><span class="inbox-inbox-pln">
line1 </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkLine</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
line1</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetPointIds</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetId</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-com"># the second 0 is the index of the Origin in linesPolyData's points</span><span class="inbox-inbox-pln">
line1</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetPointIds</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetId</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">1</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-lit">2</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-com"># 2 is the index of P1 in linesPolyData's points</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">lines </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkCellArray</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">lines</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextCell</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">line0</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">lines</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextCell</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">line1</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># Add the lines to the polydata container</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">SetLines</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">lines</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">for</span><span class="inbox-inbox-pln"> i </span><span class="inbox-inbox-kwd">in</span><span class="inbox-inbox-pln"> range</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">lines</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetNumberOfCells</span><span class="inbox-inbox-pun">()):</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">colors</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextTuple</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetCellData</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetScalars</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">colors</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">mapper </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkPolyDataMapper</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">mapper</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">SetInputData</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">actor </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkActor</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">actor</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">SetMapper</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">mapper</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">actor</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetProperty</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetLineWidth</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">4</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtk_widget </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QVTKRenderWindowInteractor</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># vtk_widget.setMinimumSize(round(1024/3), round(1024/3))</span><span class="inbox-inbox-pln">
ren </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> vtk</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtkRenderer</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtk_widget</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetRenderWindow</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">AddRenderer</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">ren</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
ren</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">AddActor</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">actor</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
ren</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">ResetCamera</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
interactor </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtk_widget</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetRenderWindow</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">GetInteractor</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
interactor</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Initialize</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
interactor</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Start</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">layout</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">addWidget</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtk_widget</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">def</span><span class="inbox-inbox-pln"> select_color</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">):</span><span class="inbox-inbox-pln">
color </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QColorDialog</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">getColor</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-typ">QtCore</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Qt</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">green</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> self</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">if</span><span class="inbox-inbox-pln"> color</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">isValid</span><span class="inbox-inbox-pun">():</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> color</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">getRgb</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">for</span><span class="inbox-inbox-pln"> i </span><span class="inbox-inbox-kwd">in</span><span class="inbox-inbox-pln"> range</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-lit">0</span><span class="inbox-inbox-pun">,</span><span class="inbox-inbox-pln"> self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">lines</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetNumberOfCells</span><span class="inbox-inbox-pun">()):</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">colors</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">InsertNextTuple</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">color</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">GetCellData</span><span class="inbox-inbox-pun">().</span><span class="inbox-inbox-typ">SetScalars</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">colors</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">mapper</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">SetInputData</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">linesPolyData</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Modified</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">mapper</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Modified</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-com"># self.actor.GetProperty().Modified()</span><span class="inbox-inbox-pln">
self</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">vtk_widget</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-typ">Render</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
</span><span class="inbox-inbox-kwd">if</span><span class="inbox-inbox-pln"> __name__ </span><span class="inbox-inbox-pun">==</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-str">'__main__'</span><span class="inbox-inbox-pun">:</span><span class="inbox-inbox-pln">
app </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">QApplication</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">sys</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">argv</span><span class="inbox-inbox-pun">)</span><span class="inbox-inbox-pln">
win </span><span class="inbox-inbox-pun">=</span><span class="inbox-inbox-pln"> </span><span class="inbox-inbox-typ">MainWindow</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
win</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">show</span><span class="inbox-inbox-pun">()</span><span class="inbox-inbox-pln">
sys</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">exit</span><span class="inbox-inbox-pun">(</span><span class="inbox-inbox-pln">app</span><span class="inbox-inbox-pun">.</span><span class="inbox-inbox-pln">exec_</span><span class="inbox-inbox-pun">())<br><span style="font-family:serif"><font size="2"><br></font></span></span></code></pre><pre class="inbox-inbox-lang-py inbox-inbox-prettyprint inbox-inbox-prettyprinted"><span style="font-family:serif"><font size="2"><code><span class="inbox-inbox-pun">--<br></span></code></font></span></pre><pre class="inbox-inbox-lang-py inbox-inbox-prettyprint inbox-inbox-prettyprinted"><code><span class="inbox-inbox-pun"><font size="2"><span style="font-family:serif">Abhishek</span><br></font></span></code></pre><pre class="inbox-inbox-lang-py inbox-inbox-prettyprint inbox-inbox-prettyprinted"><code><span class="inbox-inbox-pun"><font size="2"><span style="font-family:serif"><a href="http://zeroth.me">zeroth.me</a></span><br></font></span></code></pre></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Abhishek Patil<br></div><a href="http://zeroth.me">zeroth.me</a><br></div></div>