This file is indexed.

/usr/share/makehuman-doc/html/_modules/selection.html is in makehuman-doc 1.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>selection &#8212; MakeHuman 1.0 documentation</title>
    
    <link rel="stylesheet" href="../_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head>
  <body role="document">
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <h1>Source code for selection</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/python2.7</span>
<span class="c1"># -*- coding: utf-8 -*-</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">**Project Name:**      MakeHuman</span>

<span class="sd">**Product Home Page:** http://www.makehuman.org/</span>

<span class="sd">**Code Home Page:**    https://bitbucket.org/MakeHuman/makehuman/</span>

<span class="sd">**Authors:**           Glynn Clements</span>

<span class="sd">**Copyright(c):**      MakeHuman Team 2001-2017</span>

<span class="sd">**Licensing:**         AGPL3</span>

<span class="sd">    This file is part of MakeHuman (www.makehuman.org).</span>

<span class="sd">    This program is free software: you can redistribute it and/or modify</span>
<span class="sd">    it under the terms of the GNU Affero General Public License as</span>
<span class="sd">    published by the Free Software Foundation, either version 3 of the</span>
<span class="sd">    License, or (at your option) any later version.</span>

<span class="sd">    This program is distributed in the hope that it will be useful,</span>
<span class="sd">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="sd">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="sd">    GNU Affero General Public License for more details.</span>

<span class="sd">    You should have received a copy of the GNU Affero General Public License</span>
<span class="sd">    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>


<span class="sd">Abstract</span>
<span class="sd">--------</span>

<span class="sd">TODO</span>
<span class="sd">&quot;&quot;&quot;</span>

<div class="viewcode-block" id="SelectionColorMap"><a class="viewcode-back" href="../module_selection.html#selection.SelectionColorMap">[docs]</a><span class="k">class</span> <span class="nc">SelectionColorMap</span><span class="p">:</span>

    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    The objects support the use of a technique called *Selection Using Unique</span>
<span class="sd">    Color IDs*, that internally uses color-coding of components within the</span>
<span class="sd">    scene to support the selection of objects by the user using the mouse.</span>

<span class="sd">    This technique generates a sequence of colors (color IDs), assigning a</span>
<span class="sd">    unique color to each uniquely selectable object or component in the scene.</span>
<span class="sd">    These colors are not displayed, but are used by MakeHuman to generates an</span>
<span class="sd">    unseen image of the various selectable elements. This image uses the same</span>
<span class="sd">    camera settings currently being used for the actual, on-screen image.</span>
<span class="sd">    When the mouse is clicked, the position of the mouse is used with the</span>
<span class="sd">    unseen image to retrieve a color. MakeHuman uses this color as an ID to</span>
<span class="sd">    identify which object or component the user clicked with the mouse.</span>

<span class="sd">    This technique uses glReadPixels() to read the single pixel at the</span>
<span class="sd">    current mouse location, using the unseen, color-coded image.</span>

<span class="sd">    For further information on this technique, see:</span>

<span class="sd">      - http://www.opengl.org/resources/faq/technical/selection.htm and</span>
<span class="sd">      - http://wiki.gamedev.net/index.php/OpenGL_Selection_Using_Unique_Color_IDs</span>

<span class="sd">    **Note.** Because the 3D engine uses glDrawElements in a highly opimized</span>
<span class="sd">    way and each vertex can have only one color ID, there there is a known</span>
<span class="sd">    problem with selecting individual faces with very small FaceGroups using</span>
<span class="sd">    this technique. However, this is not a major problem for MakeHuman, which</span>
<span class="sd">    doesn&#39;t use such low polygon groupings.</span>
<span class="sd">    </span>
<span class="sd">    - **self.colorIDToFaceGroup**: *Dictionary of colors IDs* A dictionary of the color IDs used for</span>
<span class="sd">      selection (see MakeHuman Selectors, above).</span>
<span class="sd">    - **self.colorID**: *float list* A progressive color ID.</span>
<span class="sd">    </span>
<span class="sd">    The attributes *self.colorID* and *self.colorIDToFaceGroup*</span>
<span class="sd">    support a technique called *Selection Using Unique Color IDs* to make each</span>
<span class="sd">    FaceGroup independently clickable.</span>

<span class="sd">    The attribute *self.colorID* stores a progressive color that is incremented for each successive</span>
<span class="sd">    FaceGroup added to the scene.</span>
<span class="sd">    The *self.colorIDToFaceGroup* attribute contains a list that serves as a directory to map</span>
<span class="sd">    each color back to the corresponding FaceGroup by using its color ID.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    
        <span class="bp">self</span><span class="o">.</span><span class="n">colorIDToFaceGroup</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">colorID</span> <span class="o">=</span> <span class="mi">0</span>

<div class="viewcode-block" id="SelectionColorMap.assignSelectionID"><a class="viewcode-back" href="../module_selection.html#selection.SelectionColorMap.assignSelectionID">[docs]</a>    <span class="k">def</span> <span class="nf">assignSelectionID</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        This method generates a new, unique color ID for each FaceGroup,</span>
<span class="sd">        within a particular Object3D object, that forms a part of this scene3D</span>
<span class="sd">        object. This color ID can subsequently be used in a non-displayed</span>
<span class="sd">        image map to determine the FaceGroup that a mouse click was made in.</span>

<span class="sd">        This method loops through the FaceGroups, assigning the next color</span>
<span class="sd">        in the sequence to each subsequent FaceGroup. The color value is</span>
<span class="sd">        written into a &#39;dictionary&#39; to serve as a color ID that can be</span>
<span class="sd">        translated back into the corresponding FaceGroup name when a mouse</span>
<span class="sd">        click is detected.</span>
<span class="sd">        This is part of a technique called *Selection Using Unique Color IDs*</span>
<span class="sd">        to make each FaceGroup independently clickable.</span>

<span class="sd">        :param obj: The object3D object for which color dictionary entries need to be generated.</span>
<span class="sd">        :type obj: module3d.Object 3D</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="n">obj</span><span class="o">.</span><span class="n">faceGroups</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">colorID</span> <span class="o">+=</span> <span class="mi">1</span>

            <span class="c1"># 555 to 24-bit rgb</span>

            <span class="n">idR</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">colorID</span> <span class="o">%</span> <span class="mi">32</span><span class="p">)</span> <span class="o">*</span> <span class="mi">8</span>
            <span class="n">idG</span> <span class="o">=</span> <span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">colorID</span> <span class="o">&gt;&gt;</span> <span class="mi">5</span><span class="p">)</span> <span class="o">%</span> <span class="mi">32</span><span class="p">)</span> <span class="o">*</span> <span class="mi">8</span>
            <span class="n">idB</span> <span class="o">=</span> <span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">colorID</span> <span class="o">&gt;&gt;</span> <span class="mi">10</span><span class="p">)</span> <span class="o">%</span> <span class="mi">32</span><span class="p">)</span> <span class="o">*</span> <span class="mi">8</span>

            <span class="n">g</span><span class="o">.</span><span class="n">colorID</span> <span class="o">=</span> <span class="p">(</span><span class="n">idR</span><span class="p">,</span> <span class="n">idG</span><span class="p">,</span> <span class="n">idB</span><span class="p">)</span>
            
            <span class="bp">self</span><span class="o">.</span><span class="n">colorIDToFaceGroup</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">colorID</span><span class="p">]</span> <span class="o">=</span> <span class="n">g</span></div>

            <span class="c1"># import log</span>
            <span class="c1"># log.debug(&quot;SELECTION DEBUG INFO: facegroup %s of obj %s has the colorID = %s,%s,%s or %s&quot;, g.name,obj.name,idR,idG,idB, self.colorID)</span>

<div class="viewcode-block" id="SelectionColorMap.getSelectedFaceGroup"><a class="viewcode-back" href="../module_selection.html#selection.SelectionColorMap.getSelectedFaceGroup">[docs]</a>    <span class="k">def</span> <span class="nf">getSelectedFaceGroup</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">picked</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        This method uses a non-displayed image containing color-coded faces</span>
<span class="sd">        to return the index of the FaceGroup selected by the user with the mouse.</span>
<span class="sd">        This is part of a technique called *Selection Using Unique Color IDs* to make each</span>
<span class="sd">        FaceGroup independently clickable.</span>

<span class="sd">        :return: The selected face group.</span>
<span class="sd">        :rtype: :py:class:`module3d.FaceGroup`</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">IDkey</span> <span class="o">=</span> <span class="n">picked</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">/</span> <span class="mi">8</span> <span class="o">|</span> <span class="n">picked</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="mi">8</span> <span class="o">&lt;&lt;</span> <span class="mi">5</span> <span class="o">|</span> <span class="n">picked</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">/</span> <span class="mi">8</span> <span class="o">&lt;&lt;</span> <span class="mi">10</span>  <span class="c1"># 555</span>

        <span class="c1"># print &quot;DEBUG COLOR PICKED: %s,%s,%s %s&quot;%(picked[0], picked[1], picked[2], IDkey)</span>

        <span class="k">try</span><span class="p">:</span>
            <span class="n">groupSelected</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">colorIDToFaceGroup</span><span class="p">[</span><span class="n">IDkey</span><span class="p">]</span>
        <span class="k">except</span><span class="p">:</span>

            <span class="c1"># print groupSelected.name</span>
            <span class="c1">#this print should only come on while debugging color picking</span>
            <span class="c1">#print &#39;Color %s (%s) not found&#39; % (IDkey, picked)</span>
            <span class="n">groupSelected</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">return</span> <span class="n">groupSelected</span></div>

<div class="viewcode-block" id="SelectionColorMap.getSelectedFaceGroupAndObject"><a class="viewcode-back" href="../module_selection.html#selection.SelectionColorMap.getSelectedFaceGroupAndObject">[docs]</a>    <span class="k">def</span> <span class="nf">getSelectedFaceGroupAndObject</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">picked</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        This method determines whether a FaceGroup or a non-selectable zone has been</span>
<span class="sd">        clicked with the mouse. It returns a tuple, showing the FaceGroup and the parent</span>
<span class="sd">        Object3D object, or None.</span>
<span class="sd">        If no object is picked, this method will simply print \&quot;no clickable zone.\&quot;</span>

<span class="sd">        :return: The selected face group and object.</span>
<span class="sd">        :rtype: (:py:class:`module3d.FaceGroup`, :py:class:`module3d.Object3d`)</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">facegroupPicked</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getSelectedFaceGroup</span><span class="p">(</span><span class="n">picked</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">facegroupPicked</span><span class="p">:</span>
            <span class="n">objPicked</span> <span class="o">=</span> <span class="n">facegroupPicked</span><span class="o">.</span><span class="n">parent</span>
            <span class="k">return</span> <span class="p">(</span><span class="n">facegroupPicked</span><span class="p">,</span> <span class="n">objPicked</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="c1">#this print should only be made while debugging picking</span>
            <span class="c1">#print &#39;not a clickable zone&#39;</span>
            <span class="k">return</span> <span class="kc">None</span></div></div>
    
<span class="n">selectionColorMap</span> <span class="o">=</span> <span class="n">SelectionColorMap</span><span class="p">()</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper"><div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../index.html">Documentation overview</a><ul>
  <li><a href="index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2017, MHteam.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.5.6</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.8</a>
      
    </div>

    

    
  </body>
</html>