This file is indexed.

/usr/include/CGAL/Qt/GraphicsViewPolygonWithHolesInput.h is in libcgal-qt5-dev 4.7-4.

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
// Copyright (c) 2008  GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// 
//
// Author(s)     : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
//                 Laurent Rineau <Laurent.Rineau@geometryfactory.com>

#ifndef CGAL_QT_GRAPHICS_VIEW_POLYGON_WITH_HOLES_INPUT_H
#define CGAL_QT_GRAPHICS_VIEW_POLYGON_WITH_HOLES_INPUT_H

#include <list>

#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>

#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Qt/GraphicsViewInput.h>
#include <CGAL/Qt/PolygonWithHolesGraphicsItem.h>
#include <CGAL/Qt/GraphicsViewPolylineInput.h>
#include <CGAL/array.h>

namespace CGAL {
namespace Qt {

  /*
    We store a polygon with holes and display it with a graphics item
    We use a PolygonInput tool for entering the boundary and the holes
    We forward most events directly to the polygon input tool
    We only deal with events when the polygon input is not active
    - left click: enter new polygon
    - right click: return result
    - backspace: delete last polygon
    - esc: return with empty result

    todo: check that polygons don't intersect
   */



template <typename K>
class GraphicsViewPolygonWithHolesInput : public GraphicsViewInput
{
public:
  GraphicsViewPolygonWithHolesInput(QObject *parent, QGraphicsScene* s); 
  ~GraphicsViewPolygonWithHolesInput();
  
public Q_SLOTS:
  void processInput(CGAL::Object o);

typedef CGAL::Polygon_2<K> Polygon;
typedef CGAL::Polygon_with_holes_2<K> Polygon_with_holes;

protected:
    
  virtual void keyPressEvent(QKeyEvent *event);
  
  bool eventFilter(QObject *obj, QEvent *event);
  
private:

  Polygon polygon;
  std::list<Polygon> holes; 
  Polygon_with_holes pwh;  // this one collects the input polygons

  CGAL::Qt::PolygonWithHolesGraphicsItem<Polygon_with_holes> * pwhItem;
  CGAL::Qt::GraphicsViewPolylineInput<K> * pi;

  bool polygon_input;
  typedef typename K::Point_2 Point_2;
  QGraphicsScene *scene_;  
};


template <typename K>
GraphicsViewPolygonWithHolesInput<K>::GraphicsViewPolygonWithHolesInput(QObject *parent, QGraphicsScene* s)
  : GraphicsViewInput(parent), scene_(s), polygon_input(false)
{
  pwhItem = new CGAL::Qt::PolygonWithHolesGraphicsItem<Polygon_with_holes>(&pwh);
  pwhItem->setBrush(::Qt::yellow);
  scene_->addItem(pwhItem);
  pwhItem->hide();
  
  pi = new CGAL::Qt::GraphicsViewPolylineInput<K>(parent,s);
  QObject::connect(pi, SIGNAL(generate(CGAL::Object)),
		   this, SLOT(processInput(CGAL::Object)));

  QObject::connect(this, SIGNAL(modelChanged()),
		   pwhItem, SLOT(modelChanged()));

}

template <typename K>
GraphicsViewPolygonWithHolesInput<K>::~GraphicsViewPolygonWithHolesInput()
{
  //delete pwhItem;
  //delete pi;
}


template <typename K>
void
GraphicsViewPolygonWithHolesInput<K>::processInput(CGAL::Object o)
{
   std::list<Point_2> points;
  if(CGAL::assign(points, o)){
    if((points.size() == 1)&& polygon.size()>0){
    
    } else {
      polygon.clear();
      if(points.front() == points.back()){
	points.pop_back();
      }
      polygon.insert(polygon.vertices_begin(), points.begin(), points.end());
      if(holes.empty()){
	if(polygon.orientation() == CGAL::CLOCKWISE){
	  polygon.reverse_orientation();
	}
      } else {
	if(polygon.orientation() == CGAL::COUNTERCLOCKWISE){
	  polygon.reverse_orientation();
	}
      }
      holes.push_back(polygon);
      typename std::list<Polygon>::iterator it = holes.begin();
      it++;
      pwh = Polygon_with_holes(holes.front(), it, holes.end());
    }
    Q_EMIT( modelChanged());
    polygon_input = false;
  } 
}


template <typename K>
void 
GraphicsViewPolygonWithHolesInput<K>::keyPressEvent ( QKeyEvent * event ) 
{
}



template <typename K>
bool 
GraphicsViewPolygonWithHolesInput<K>::eventFilter(QObject *obj, QEvent *event)
{
  if(polygon_input){
    return pi->eventFilter(obj, event);
  } else {
    if (event->type() == QEvent::GraphicsSceneMousePress) {
      QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
      
      if(mouseEvent->modifiers()  & ::Qt::ShiftModifier){
	return QObject::eventFilter(obj, event);;
      }
      if(mouseEvent->button() == ::Qt::LeftButton) {
	polygon_input = true;
	return pi->eventFilter(obj, event);
      } else if(mouseEvent->button() == ::Qt::RightButton) {
	Q_EMIT( generate(CGAL::make_object(pwh)));
	pwh.clear();
	holes.clear();
	polygon_input = false;
	Q_EMIT( modelChanged());
      }
      return true;
    } else if (event->type() == QEvent::KeyPress) {
      QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
      keyPressEvent(keyEvent);
      return true;
    } else{
      // standard event processing
      return QObject::eventFilter(obj, event);
    }
  }
} 

} // namespace Qt

} // namespace CGAL

#endif // CGAL_QT_GRAPHICS_VIEW_POLYGON_WITH_HOLES_INPUT_H