This file is indexed.

/usr/include/gofigure2/TraceContainerBase.h is in libgofigure-dev 0.9.0-3+b1.

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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
/*=========================================================================
 Authors: The GoFigure Dev. Team.
 at Megason Lab, Systems biology, Harvard Medical school, 2009-11

 Copyright (c) 2009-11, President and Fellows of Harvard College.
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

 Redistributions of source code must retain the above copyright notice,
 this list of conditions and the following disclaimer.
 Redistributions in binary form must reproduce the above copyright notice,
 this list of conditions and the following disclaimer in the documentation
 and/or other materials provided with the distribution.
 Neither the name of the  President and Fellows of Harvard College
 nor the names of its contributors may be used to endorse or promote
 products derived from this software without specific prior written
 permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=========================================================================*/

#ifndef __TraceContainerBase_h
#define __TraceContainerBase_h

#include <Qt>
#include <QObject>
#include "QGoImageView3D.h"

#include "vtkProperty.h"
#include "StructureHelper.h"
#include "QGoGUILibConfigure.h"

#include "vtkIntArray.h"
#include "vtkActor.h"
#include "vtkMapper.h"
#include "vtkDataSet.h"
#include "vtkPointData.h"

#include "TraceStructure.h"

#include "boost/multi_index_container.hpp"
#include "boost/multi_index/member.hpp"
#include "boost/multi_index/hashed_index.hpp"
#include "boost/multi_index/ordered_index.hpp"
#include "boost/numeric/conversion/cast.hpp"
#include "boost/lexical_cast.hpp"


//-----------------------------------------------------------------------------

template <class T> struct change_highlighted
{
  change_highlighted(bool& iHighlight):highlighted(iHighlight){}

  void operator()(T& iStructure)
  {
    iStructure.Highlighted = highlighted;
  }

private:
  bool highlighted;
};

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template <class T> struct change_visible
{
  change_visible(const bool& iVisibile):visible(iVisibile){}

  void operator()(T& iStructure)
  {
    iStructure.Visible = visible;
  }

private:
  bool visible;
};

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template <class T> struct change_actors
{
  change_actors(std::vector<vtkActor*>& iActors):actor(iActors){}

  void operator()(T& iStructure)
  {
    iStructure.ActorXY = actor[0];
    iStructure.ActorXZ = actor[1];
    iStructure.ActorYZ = actor[2];
    iStructure.ActorXYZ = actor[3];
  }

private:
  std::vector<vtkActor*> actor;
};

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template <class T> struct change_color
{
  change_color(QColor iColor):color(iColor){}

  void operator()(T& iStructure)
  {
    iStructure.rgba[0] = color.redF();
    iStructure.rgba[1] = color.greenF();
    iStructure.rgba[2] = color.blueF();
    iStructure.rgba[3] = color.alphaF();
  }

private:
  QColor color;
};

//-----------------------------------------------------------------------------

/**
 * \class TraceContainerBase
 * \tparam TContainer boost::multi_index_container of a given TraceStructure
 * \brief Generic interface for trace container.
 * More specific container should inherit from this class and get specialized
 * depending on the kind of trace it contains.
 * */
template< class TContainer >
class TraceContainerBase : public QObject
{
public:
  typedef TContainer                                    MultiIndexContainerType;
  typedef typename MultiIndexContainerType::value_type  MultiIndexContainerElementType;

  typedef typename MultiIndexContainerType::template index< TraceID >::type::iterator
  MultiIndexContainerTraceIDIterator;

  typedef typename MultiIndexContainerType::template index< CollectionID >::type::iterator
  MultiIndexContainerCollectionIDIterator;

  typedef typename MultiIndexContainerType::template index< Highlighted >::type::iterator
  MultiIndexContainerHighlightedIterator;

  typedef typename MultiIndexContainerType::template index< Visible >::type::iterator
  MultiIndexContainerVisibleIterator;

  /** \brief Constructor
 * \param[in] iParent Parent to provide ownership (Qt style)
 * \param[in] iView Visualization for trace
 * */
  explicit TraceContainerBase( QObject* iParent, QGoImageView3D* iView );

  /** \brief Destructor */
  virtual ~TraceContainerBase();

  /** \brief Trace Contaienr */
  MultiIndexContainerType m_Container;

  /** \brief Link to the visualization. */
  QGoImageView3D *m_ImageView;

  /** \brief Current Element of the trace type. */
  MultiIndexContainerElementType m_CurrentElement;

  // ----------------------------------------------------------------------

  /** \brief Print the container content in the application output.
 * \tparam TIterator Iterator on one index of boost::multi_index_container
 * or on the container itself.
 * */
  template< class TIterator >
  void Print(TIterator iBegin, TIterator iEnd)
    {
    TIterator it = iBegin;

    while ( it != iEnd )
      {
      std::cout << *it;
      std::cout << "***" << std::endl;
      std::cout << std::endl;
      ++it;
      }
    }

  /**
    \brief Print the container content in the application output according
    to the template parameter.
    \tparam TIndex
    */
  template< class TIndex >
  void Print()
    {
    using boost::multi_index::get;

    this->Print(  this->m_Container.get< TIndex >().begin(),
                  this->m_Container.get< TIndex >().end() );
    }

  /** \brief Print the container content in the application output. */
  void Print();

  // ----------------------------------------------------------------------

  /**
    \brief Set property whenever the trace is highlighted
    \param[in] iProperty
  */
  void SetHighlightedProperty(vtkProperty *iProperty);

  /**
    \brief Get property for highlighted traces
  */
  vtkProperty * GetHighlightedProperty();

  /** \brief Get the CollectionID given a TraceID */
  unsigned int GetCollectionIDOfGivenTraceID( unsigned int iTraceID);

  /**
    \brief Update Visualization of the given TraceIDs
    \tparam TContainer Container of TraceIDs
    \param[in] iList input container of TraceIDs
  */
  template< class TList >
  void UpdateVisualizationForGivenIDs(TList iList)
    {
    using boost::multi_index::get;

    typename TList::iterator it = iList.begin();

    while ( it != iList.end() )
      {
      MultiIndexContainerTraceIDIterator id_it =
        m_Container.get< TraceID >().find( static_cast< unsigned int >( *it ) );

      if ( id_it != m_Container.get< TraceID >().end() )
        {
        bool test = false;
        m_Container.get< TraceID >().
            modify( id_it , change_visible<MultiIndexContainerElementType>(test) );
        m_Container.get< TraceID >().
            modify( id_it , change_highlighted<MultiIndexContainerElementType>(test) );

        vtkProperty *tproperty = vtkProperty::New();
        tproperty->SetColor(id_it->rgba[0], id_it->rgba[1], id_it->rgba[2]);
        tproperty->SetOpacity(id_it->rgba[3]);
        tproperty->SetLineWidth( this->m_IntersectionLineWidth );

        if ( id_it->Nodes )
          {
          bool test2 = id_it->Visible;
          m_Container.get< TraceID >().
              modify( id_it , change_visible<MultiIndexContainerElementType>( test2 ) );

          std::vector< vtkActor * > actor =
              this->m_ImageView->AddContour( id_it->Nodes, tproperty );

          m_Container.get< TraceID >().
              modify( id_it , change_actors<MultiIndexContainerElementType>( actor ) );

          typedef void ( QGoImageView3D::*ImageViewMember )(const int &, vtkActor *);
          ImageViewMember f;

          if ( id_it->Visible )
            {
            f = &QGoImageView3D::AddActor;
            }
          else
            {
            f = &QGoImageView3D::RemoveActor;
            }

          assert( m_ImageView );
          for ( int i = 0; i < 4; i++ )
            {
            ( m_ImageView->*f )(i, actor[i]);
            }
          }
        else
          {
          m_Container.get< TraceID >().
              modify( id_it , change_visible<MultiIndexContainerElementType>(test) );
          }
        }
      ++it;
      }
    }

  /**
  * \brief Update Actors, Highlighted, Visibility (properties) of given
  * a element
  * \tparam TIndex Index Type (referring to multi index container's indices)
  * \param[in] iIt element to update
  * \param[in] iActors its actors
  * \param[in] iHighlighted
  * \param[in] iVisible if false remove the element from the scene, else
  * add it */
  template< class TIndex >
  void UpdateVisualizationForGivenElement(
    typename MultiIndexContainerType::template index< TIndex >::type::iterator& iIt,
    std::vector< vtkActor * > iActors,
    const bool & iHighlighted,
    const bool & iVisible)
    {

    using boost::multi_index::get;

    if ( iActors.size() == 4 )
      {
      m_Container.get< TIndex >().
          modify( iIt , change_actors<MultiIndexContainerElementType>(iActors) );
      }
    bool highlighted = iHighlighted;
    bool visible = iVisible;
    m_Container.get< TIndex >().
        modify( iIt , change_visible<MultiIndexContainerElementType>(visible) );
    m_Container.get< TIndex >().
        modify( iIt , change_highlighted<MultiIndexContainerElementType>(highlighted) );

    typedef void ( QGoImageView3D::*ImageViewMember )(const int &, vtkActor *);
    ImageViewMember f;

    if ( iVisible )
      {
      f = &QGoImageView3D::AddActor;
      }
    else
      {
      f = &QGoImageView3D::RemoveActor;
      }

    assert( m_ImageView );
    for ( int i = 0; i < 4; i++ )
      {
      ( m_ImageView->*f )(i, iActors[i]);
      }
    }

  /**
  \brief Insert one element in the container
  \param[in] iE element to be insert in the container
  */
  void Insert(const MultiIndexContainerElementType & iE);

  /** \brief Insert Current Element in the container */
  void InsertCurrentElement();

  /** \brief Reset Current Element to a default state */
  void ResetCurrentElement();

  /**
  \brief Update Current Element from te database.
  \param[in] iTraceID
  \param[in] irgba
  \param[in] IsVisible
  */
  void UpdateCurrentElementFromDB(unsigned int iTraceID, double irgba[4],
    bool IsVisible = false);

  void UpdateCurrentElementCollection(unsigned int iCollectionID);

  /**
    \brief Get the polydata representing the current element track
    \return Pointer to the current element track
  */
  vtkPolyData* GetCurrentElementNodes();

  /**
    \brief Get the color of the current element track
    \return Pointer to the current element color
  */
  double* GetCurrentElementColor();

  std::vector<vtkActor*> GetActorGivenTraceID( unsigned int iTraceID );

  /**
  \brief put the information of the existing element into m_CurrentElement
  and remove the existing element from the container,the visu and the memory
  \param[in] iTraceID ID of the existing element
  \return true if the element was found in the container, false if not
  */
  bool UpdateCurrentElementFromExistingOne(unsigned int iTraceID, bool iErase = true);

  /** \brief */
  template< class TIndex >
  bool UpdateCurrentElementFromExistingOne(
    typename MultiIndexContainerType::template index< TIndex >::type::iterator iIt )
    {
    using boost::multi_index::get;

    // update current element
    this->m_CurrentElement = *iIt;

    // clean the container but don't erase the pointers since we still have the
    // adresses in the m_CurrentElement
    m_Container.get< TIndex >().erase( iIt );

    return true;
    }

  /**
    \brief Update element visibility given it TraceId
    \param[in] iId TraceID of the element to be modified
    \return true if the element was present in the container.
    \todo Nicolas-should return visibility instead??
  */
  bool UpdateElementVisibilityWithGivenTraceID(const unsigned int & iId);

  //-------------------------------------------------------------------------

  /**
    \brief Remove element from visualization
    \param[in] iId TraceID of the element to be removed
    \return true if the element was present in the container.
  */
  bool
  RemoveElementFromVisualizationWithGivenTraceID(
    const unsigned int & iId);

  /**
    \brief Update element highlighting given it TraceId
    \param[in] iId TraceID of the element to be modified
    \return true if the element was present in the container.
  */
  bool UpdateElementHighlightingWithGivenTraceID(const unsigned int & iId);

  //-------------------------------------------------------------------------

  /**
    \brief Get the list of highlighted elements TraceID.
    */
  std::list< unsigned int > GetHighlightedElementsTraceID();

  std::list< unsigned int > GetHighlightedElementsCollectionID();

  /**
    \brief Get all highlighted elements by pair<ID, Polydata>.
    */

  std::list< vtkPolyData* > GetHighlightedElements();

  /**
    \brief Remove the element which TraceId = iId
    <ul>
      <li>from the visualization
      <li>from the container
      <li>from memory (release memory)
    </ul>
    \param[in] iId TraceID of the element to be deleted
    \return true if the element was present in the container.
  */
  virtual bool DeleteElement(const unsigned int & iId) = 0;

  /**
  \overload DeleteElement(const unsigned int & iId)
  */
  virtual bool DeleteElement(MultiIndexContainerTraceIDIterator iIter) = 0;

  /** \brief Delete all highlighted elements
  \return the list of TraceIDs of such elements
  */
  virtual std::list< unsigned int > DeleteAllHighlightedElements() = 0;

  /**
    \brief Update all highlighted elements in the container with a given color.
    \note Elements remain highlighted as long as it is checked in the Table Widget.
    \param[in] iColor
    \return list of highlighted elements
  */
  std::list< unsigned int > UpdateAllHighlightedElementsWithGivenColor(
    QColor iColor);

  /**
    \brief Color code contour / mesh according to values provided
    \param[in] iColumnName Name of data provided
    \param[in] iValues is a map where the key is the TraceID and the Value is
    a string that can be either converted to a double, or not
    \note if iColumnName and/or iValues are empty traces will be then rendered
    with their original colors.
  */
  void SetColorCode( const std::string& iColumnName,
                     const std::map< unsigned int, std::string >& iValues );

  /**
    \brief Color code contour / mesh according to values provided
    \tparam TValue numerical type that can be converted into double
    \param[in] iColumnName Name of data provided
    \param[in] iValues is a map where the key is the TraceID and the Value is
    the actual data used to color.
    \note if iColumnName and/or iValues are empty traces will be then rendered
    with their original colors.
  */
  template< typename TValue >
  void SetColorCode( const std::string& iColumnName,
                     const std::map< unsigned int, TValue >& iValues )
    {
    typedef TValue                                        ValueType;
    typedef typename std::map< unsigned int, ValueType >  MapType;
    typedef typename MapType::const_iterator              MapConstIterator;

    using boost::multi_index::get;

    if( iColumnName.empty() || iValues.empty() )
      {
      RenderAllElementsWithOriginalColors();
      return;
      }

    MapConstIterator it = iValues.begin();

    double temp = 0.;
    try
      {
      temp = boost::numeric_cast< double >( it->second );
      }
    catch( boost::numeric::bad_numeric_cast& e )
      {
      std::cout <<  e.what() <<std::endl;
      return;
      }

    double min_value = temp;
    double max_value = temp;

    while( it != iValues.end() )
      {
      MultiIndexContainerTraceIDIterator
          trace_it = this->m_Container.get<TraceID>().find( it->first );

      if( trace_it != this->m_Container.get<TraceID>().end() )
        {
          if (trace_it->Nodes) //make sure the trace has points !!!
          {
          // Here let's make sure you are not passing crazy values!
          try
            {
            temp = boost::numeric_cast< double >( it->second );
            }
          catch( boost::numeric::bad_numeric_cast& e )
            {
            std::cout << e.what() <<std::endl;
            return;
            }

          if( temp > max_value )
            {
            max_value = temp;
            }
          if( temp < min_value )
            {
            min_value = temp;
            }

          trace_it->SetScalarData( iColumnName, temp );
          }
        } //end make sure the trace has points !!!
      ++it;
      }

    SetScalarRangeForAllElements( min_value, max_value );

    if( m_ImageView )
      {
      this->m_ImageView->UpdateRenderWindows();
      }
    }

  void SetRandomColor( const std::string& iColumnName,
                       const std::map< unsigned int, unsigned int >& iIds );

  void SetRandomColor( const std::string& iColumnName,
                       const std::map< unsigned int, std::string >& iValues );

  /** \brief Apply the given lookup table to all traces in the container
      \param[in] iLut lookup table */
  void SetLookupTableForColorCoding( vtkLookupTable* iLut );

  void SetIntersectionLineWidth( const float& iWidth );


protected:
  vtkProperty *m_HighlightedProperty;
  float m_IntersectionLineWidth;

  /** \brief Change elements highlighting property given a list of TraceIDs
  and the new status.
    \param[in] iList list of TraceIDs
    \param[in] iCheck */
  virtual void UpdateElementHighlightingWithGivenTraceIDsBase( const QStringList& iList,
                                                   const Qt::CheckState& iCheck );

  /** \brief Change elements visibility property given a list of TraceIDs
  and the new status.
    \param[in] iList list of TraceIDs
    \param[in] iCheck */
  virtual void UpdateElementVisibilityWithGivenTraceIDsBase( const QStringList& iList,
                                                 const Qt::CheckState& iCheck );


  /** \brief Render with original colors */
  void RenderAllElementsWithOriginalColors();

  /** \brief Set the scalar range */
  void SetScalarRangeForAllElements(const double& iMin, const double& iMax );

  void UpdateCurrentElementFromVisuBase( std::vector< vtkActor* >& iActors,
                                         vtkPolyData* iNodes,
                                         const bool& iHighlighted,
                                         const bool& iVisible );

  /**
  \brief Update highlighting property of one element given one actor.
  \param[in] iActor Actor of the element to be modified
  \param[out] oTraceId TraceId of the element
  \param[out] oState Qt::Checked if the element is not highlighted else Qt::UnChecked
  \return true if the element exists
  \return false else
  */
  void UpdateElementHighlightingWithTraceID(
      const unsigned int& oTraceId,
      Qt::CheckState& oState )
    {
      using boost::multi_index::get;

      typedef typename MultiIndexContainerType::template index< TraceID >::type::iterator
      IteratorType;
      IteratorType it = m_Container.get< TraceID >().find(oTraceId);

      vtkProperty *temp_property = vtkProperty::New();

      assert ( it != m_Container.get< TraceID >().end() );

      if ( it->Highlighted )
        {
        temp_property->SetColor(it->rgba[0],
                                it->rgba[1],
                                it->rgba[2]);
        temp_property->SetOpacity(it->rgba[3]);
        temp_property->SetLineWidth( this->m_IntersectionLineWidth );
        }
      else
        {
        temp_property->DeepCopy(this->m_HighlightedProperty);
        }

      it->SetActorProperties( temp_property );

      temp_property->Delete();

      // Note: it->Highlighted is the status before picking the actor
      bool checked = false;
      if ( !it->Highlighted )
        {
        oState = Qt::Checked;
        checked = true;
        }
      else
        {
        oState = Qt::Unchecked;
        }

      m_Container.get< TraceID >().
          modify( it , change_highlighted<MultiIndexContainerElementType>(checked) );

      assert( m_ImageView );

      m_ImageView->UpdateRenderWindows();
    }

  void UpdateElementVisibilityWithTraceID(
      const unsigned int& oTraceId,
      const bool& iState)
    {
    using boost::multi_index::get;

    typedef typename MultiIndexContainerType::template index< TraceID >::type::iterator
    IteratorType;
    IteratorType it = m_Container.get< TraceID >().find(oTraceId);

    assert ( it != m_Container.get< TraceID >().end() );

    if ( it->Visible != iState )
      {
      it->SetActorVisibility( iState );
      m_Container.get< TraceID >().
          modify( it , change_visible<MultiIndexContainerElementType>(iState) );
      }
    }
};

#include "TraceContainerBase.txx"

#endif // __TraceContainerBase_h