Developer Documentation
QtApplication.cc
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43  * *
44  * $Revision$ *
45  * $Author$ *
46  * $Date$ *
47  * *
48 \*===========================================================================*/
49 
50 
51 
52 //=============================================================================
53 //
54 // CLASS QtApplication - IMPLEMENTATION
55 //
56 //=============================================================================
57 
58 
59 //== INCLUDES =================================================================
60 
61 
62 // ACG
63 #include "QtApplication.hh"
64 //#include <ACG/QtWidgets/QtMacroDialog.hh>
65 
66 
67 // Qt
68 #include <QWidget>
69 #include <QWheelEvent>
70 
71 // stdc++
72 #include <fstream>
73 
74 
75 //== NAMESPACES ===============================================================
76 
77 
78 namespace ACG {
79 namespace QtWidgets {
80 
81 
82 //== IMPLEMENTATION ==========================================================
83 
84 
85 // input / output for QPoint
86 // static std::istream& operator>>(std::istream& _is, QPoint& _p)
87 // {
88 // int x, y;
89 // _is >> x >> y;
90 // _p.setX(x);
91 // _p.setY(y);
92 // return _is;
93 // }
94 
95 // static std::ostream& operator<<(std::ostream& _os, const QPoint& _p)
96 // {
97 // _os << _p.x() << ' ' << _p.y();
98 // return _os;
99 // }
100 
101 
102 //-----------------------------------------------------------------------------
103 
104 
105 // input / output for QSize
106 // static std::istream& operator>>(std::istream& _is, QSize& _s)
107 // {
108 // int w, h;
109 // _is >> w >> h;
110 // _s.setWidth(w);
111 // _s.setHeight(h);
112 // return _is;
113 // }
114 
115 // static std::ostream& operator<<(std::ostream& _os, const QSize& _s)
116 // {
117 // _os << _s.width() << ' ' << _s.height();
118 // return _os;
119 // }
120 
121 
122 //-----------------------------------------------------------------------------
123 
124 
125 // static std::string read_name(std::istream& _is)
126 // {
127 // char cb[255];
128 // _is.getline(cb, 255);
129 // return std::string(cb);
130 // }
131 
132 
133 //-----------------------------------------------------------------------------
134 
135 
136 // copy qt event
137 template <class SomeEvent>
138 static QEvent* clone_event(QEvent* _event)
139 { return dynamic_cast<QEvent*>(new SomeEvent(*(dynamic_cast<SomeEvent*>(_event)) )); }
140 
141 
142 
143 //-----------------------------------------------------------------------------
144 
145 
146 QtApplication::QtApplication(int _argc, char** _argv)
147  : QApplication(_argc, _argv),
148  record_(false),
149  playback_(false),
150  play_loop_(false),
151  eventnr_(0),
152  timer_id_(0),
153  dialog_(0),
154  mainWidget_(0)
155 {
156  // create new macro Dialog
157 // dialog_ = new QtMacroDialog(0, "MacroDialog");
158 
159 
160 // // connect functions to macro dialog
161 // connect(dialog_, SIGNAL(play()),
162 // this, SLOT(play()));
163 // connect(dialog_, SIGNAL(stop()),
164 // this, SLOT(stop()));
165 // connect(dialog_, SIGNAL(record()),
166 // this, SLOT(record()));
167 // connect(dialog_, SIGNAL(loop(bool)),
168 // this, SLOT(loop(bool)));
169 // connect(dialog_, SIGNAL(saveFile(const char*)),
170 // this, SLOT(saveFile(const char*)));
171 // connect(dialog_, SIGNAL(loadFile(const char*)),
172 // this, SLOT(loadFile(const char*)));
173 
174 }
175 
176 //-----------------------------------------------------------------------------
177 
178 
179 void QtApplication::cleanUpEventBuffer()
180 {
181  // delete memory of events
182  for(unsigned int i=0; i<events_.size(); i++)
183  if (events_[i].event)
184  delete events_[i].event;
185 
186  events_.clear();
187 }
188 
189 
190 //-----------------------------------------------------------------------------
191 
192 
193 void QtApplication::loop(bool _b)
194 {
195  play_loop_ = _b;
196 }
197 
198 
199 //-----------------------------------------------------------------------------
200 
201 
202 void QtApplication::play()
203 {
204  // check for main widget
205  mainWidget_ = activeWindow();
206  // mainWidget_ = mainWidget();
207  if (!mainWidget_)
208  {
209  std::cerr << "No Main Widget defined!\n";
210  return;
211  }
212 
213 
214  // stop recording first
215  record_ = false;
216  playback_ = true;
217  eventnr_ = 0;
218 
219  restoreTopLevelSizes();
220 
221  mainWidgetDiff_ = mainWidget_->mapToGlobal(QPoint(0,0)) - oldMainWidgetPos_;
222 
223  time_.start();
224  timer_id_ = startTimer(10);
225 }
226 
227 
228 //-----------------------------------------------------------------------------
229 
230 
231 void QtApplication::stop()
232 {
233  record_ = false;
234  playback_ = false;
235  killTimer( timer_id_ );
236 }
237 
238 
239 //-----------------------------------------------------------------------------
240 
241 
242 void QtApplication::record()
243 {
244  // check main widget
245  mainWidget_ = activeWindow();
246  // mainWidget_ = mainWidget();
247  if (!mainWidget_)
248  {
249  std::cerr << "No Main Widget defined!\n";
250  return;
251  }
252 
253  // stop playback first
254  playback_ = false;
255  killTimer( timer_id_ );
256 
257  record_ = true;
258 
259  cleanUpEventBuffer();
260 
261  storeTopLevelSizes();
262 
263  // save mainWidgetPos
264  oldMainWidgetPos_ = mainWidget_->mapToGlobal(QPoint(0,0));
265 
266  // start recording Time
267  time_.start();
268 }
269 
270 
271 //-----------------------------------------------------------------------------
272 
273 
274 bool QtApplication::notify (QObject* _receiver, QEvent* _event)
275 {
276 // // record events
277 // if (record_ && !playback_)
278 // recordEvent(_receiver, _event);
279 
280 
281 // //check for recording or playback Keypresses
282 // if (_event->type() == QEvent::KeyPress)
283 // {
284 // switch(((QKeyEvent*) _event)->key())
285 // {
286 // case Qt::Key_F5:
287 // dialog_->show();
288 // break;
289 
290 // case Qt::Key_F6:
291 // play();
292 // break;
293 
294 // case Qt::Key_F7:
295 // stop();
296 // break;
297 
298 // case Qt::Key_F8:
299 // record();
300 // break;
301 // }
302 // }
303 
304 
305  // handle Event like Qt do
306  return QApplication::notify(_receiver, _event);
307 }
308 
309 
310 //-----------------------------------------------------------------------------
311 
312 
313 void QtApplication::recordEvent(QObject* /* _receiver */ , QEvent* /* _event */ )
314 {
315 // // save only events for widgets
316 // if (_receiver->inherits("QWidget"))
317 // {
318 // QWidget*receiver = (QWidget*)_receiver;
319 
320 
321 // // skip events for macro dialog
322 // // if (receiver->activeWindow()->windowTitle() == "MacroDialog")
323 // // return;
324 // // if (receiver->topLevelWidget()->name() == "MacroDialog")
325 // // return;
326 
327 
328 // // generate event footprint
329 // FootPrint fp;
330 // fp.event = 0;
331 // fp.time = time_.elapsed();
332 // fp.cursorPos = mainWidget_->mapFromGlobal(QCursor::pos());
333 // // fp.name = receiver->name();
334 // // fp.classname = receiver->className();
335 // fp.position = receiver->pos();
336 // fp.size = receiver->size();
337 // // fp.parent = (receiver->parent() ?
338 // // receiver->parent()->name() : "noParent");
339 
340 
341 
342 // switch(_event->type())
343 // {
344 
345 // // mouse event ----------------------------------------------------------
346 // case QEvent::MouseButtonPress:
347 // case QEvent::MouseButtonRelease:
348 // case QEvent::MouseMove:
349 // case QEvent::MouseButtonDblClick:
350 // {
351 // fp.event = clone_event<QMouseEvent>(_event);
352 // break;
353 // }
354 
355 
356 // // wheel event ----------------------------------------------------------
357 // case QEvent::Wheel:
358 // {
359 // fp.event = clone_event<QWheelEvent>(_event);
360 // break;
361 // }
362 
363 
364 // // key event ------------------------------------------------------------
365 // case QEvent::KeyPress:
366 // case QEvent::KeyRelease:
367 // case QEvent::Shortcut:
368 // case QEvent::ShortcutOverride:
369 // {
370 // QKeyEvent* e = (QKeyEvent*) _event;
371 
372 // // skip F5, F6, F7, F8
373 // if (e->key() != Qt::Key_F5 && e->key() != Qt::Key_F6 &&
374 // e->key() != Qt::Key_F7 && e->key() != Qt::Key_F8)
375 // fp.event = clone_event<QKeyEvent>(_event);
376 // break;
377 // }
378 
379 
380 // // context menu event ---------------------------------------------------
381 // case QEvent::ContextMenu:
382 // {
383 // fp.event = clone_event<QContextMenuEvent>(_event);
384 // break;
385 // }
386 
387 
388 // // move event -----------------------------------------------------------
389 // case QEvent::Move:
390 // {
391 // if (_event->spontaneous())
392 // fp.event = clone_event<QMoveEvent>(_event);
393 // break;
394 // }
395 
396 
397 // // close event ----------------------------------------------------------
398 // case QEvent::Close:
399 // {
400 // // can be non-spontaneous !
401 // fp.event = clone_event<QCloseEvent>(_event);
402 // break;
403 // }
404 
405 
406 // default: // avoid warning
407 // break;
408 // }
409 
410 
411 // // if event has been handled, store it
412 // if (fp.event) events_.push_back(fp);
413 // }
414 }
415 
416 
417 //-----------------------------------------------------------------------------
418 
419 
420 void QtApplication::playbackEvent(FootPrint & /* _fp */ )
421 {
422 // // determine widget for saved event at runtime
423 // QWidget* eventWidget = findWidget(_fp);
424 // if (!eventWidget) return;
425 
426 
427 // // position and size
428 // if (eventWidget->isTopLevel())
429 // {
430 // // restore widget size
431 // if (eventWidget->size() != _fp.size)
432 // eventWidget->resize(_fp.size);
433 
434 // // correct position wrt to main widget
435 // if (eventWidget != mainWidget_)
436 // {
437 // QPoint newWidgetPos = _fp.position + mainWidgetDiff_;
438 
439 // if (newWidgetPos != eventWidget->pos())
440 // eventWidget->move(newWidgetPos);
441 // }
442 // }
443 
444 
445 // // global cursor position
446 // QPoint globalPos = mainWidget_->mapToGlobal(_fp.cursorPos);
447 // QCursor::setPos(globalPos);
448 
449 
450 // // correct global mouse position in events
451 // switch(_fp.event->type())
452 // {
453 
454 // // mouse event ----------------------------------------------------------
455 // case QEvent::MouseButtonPress:
456 // case QEvent::MouseButtonRelease:
457 // case QEvent::MouseMove:
458 // case QEvent::MouseButtonDblClick:
459 // {
460 // QMouseEvent* e = (QMouseEvent*) _fp.event;
461 // QMouseEvent me = QMouseEvent(e->type(),
462 // e->pos(),
463 // globalPos,
464 // e->button(),
465 // e->state());
466 
467 // notify((QObject*) eventWidget, &me);
468 // break;
469 // }
470 
471 
472 // // wheel event ------------------------------------------------------------
473 // case QEvent::Wheel:
474 // {
475 // QWheelEvent* e = (QWheelEvent*) _fp.event;
476 // QWheelEvent we = QWheelEvent(e->pos(),
477 // globalPos,
478 // e->delta(),
479 // e->state(),
480 // e->orientation());
481 
482 // notify((QObject*) eventWidget, &we);
483 // break;
484 // }
485 
486 
487 // // context menu event -----------------------------------------------------
488 // case QEvent::ContextMenu:
489 // {
490 // QContextMenuEvent* e = (QContextMenuEvent*) _fp.event;
491 // QContextMenuEvent ce = QContextMenuEvent(e->reason(),
492 // e->pos(),
493 // globalPos,
494 // e->state());
495 
496 // notify((QObject*) eventWidget, &ce);
497 // break;
498 // }
499 
500 
501 // // move event -----------------------------------------------------------
502 // case QEvent::Move:
503 // {
504 // // pos has been adjusted above, but its still needed here...
505 // break;
506 // }
507 
508 
509 // // all other events... ----------------------------------------------------
510 // default:
511 // {
512 // // send event unmodified to the widget
513 // notify((QObject*) eventWidget, _fp.event);
514 // break;
515 // }
516 // }
517 }
518 
519 
520 //-----------------------------------------------------------------------------
521 
522 
523 QWidget* QtApplication::findWidget(FootPrint & /* _fp */ )
524 {
525 // QWidget *w;
526 // std::vector<QWidget*> candidates;
527 // QWidgetList list = allWidgets();
528 
529 // for (int i = 0; i < list.size(); ++i)
530 // {
531 // w = list.at(i);
532 
533 // if (_fp.name == w->name() && _fp.classname == w->className())
534 // if (_fp.parent == (w->parent() ? w->parent()->name() : "noParent"))
535 // candidates.push_back(w);
536 // }
537 
538 
539 
540 // if (candidates.size() == 1)
541 // return candidates[0];
542 
543 // else
544 // {
545 // std::cerr << "Error: found " << candidates.size()
546 // << " widgets with name " << "\"" << _fp.name << "\"\n";
547 // return 0;
548 // }
549 
550  return 0;
551 }
552 
553 
554 //-----------------------------------------------------------------------------
555 
556 
557 void QtApplication::timerEvent(QTimerEvent* /* _e */ )
558 {
559  // all events processed ?
560  if (eventnr_ < events_.size())
561  {
562  // get current event
563  FootPrint fp = events_[eventnr_];
564 
565  // right time to send ?
566  if (fp.time < time_.elapsed())
567  {
568  // increase counter
569  ++eventnr_;
570 
571  // send event to widget
572  playbackEvent(fp);
573  }
574  }
575 
576  // restart or stop playing
577  else
578  {
579  if (play_loop_) // restart
580  {
581  eventnr_ = 0;
582  time_.start();
583  }
584  else killTimer( timer_id_ ); // stop
585  }
586 }
587 
588 
589 //-----------------------------------------------------------------------------
590 
591 
592 void QtApplication::storeTopLevelSizes()
593 {
594 // // clear buffer
595 // toplevels_.clear();
596 
597 
598 // QWidgetList list = topLevelWidgets();
599 // QWidget *w;
600 // FootPrint fp;
601 
602 
603 // for (int i = 0; i < list.size(); ++i)
604 // {
605 // w = list.at(i);
606 
607 // fp.name = w->name();
608 // fp.classname = w->className();
609 // fp.parent = w->parent() ? w->parent()->name() : "noParent";
610 // fp.size = w->size();
611 
612 // toplevels_.push_back(fp);
613 // }
614 }
615 
616 
617 //-----------------------------------------------------------------------------
618 
619 
620 void QtApplication::restoreTopLevelSizes()
621 {
622 // QWidget* w;
623 
624 // for(FootPrintIter it=toplevels_.begin(); it!=toplevels_.end(); ++it)
625 // {
626 // // find widget to restore size
627 // if ((w = findWidget(*it)))
628 // {
629 // // size differs -> restore it
630 // if (w->size() != it->size)
631 // w->resize(it->size);
632 // }
633 // }
634 }
635 
636 
637 //-----------------------------------------------------------------------------
638 
639 
640 void QtApplication::saveFile(const char* /* _filename */ )
641 {
642 // std::ofstream ofs(_filename, std::ios::out);
643 // if (!ofs) return;
644 
645 
646 // // write File Signature
647 // ofs << "QTMacro " << events_.size() << std::endl;
648 // ofs << oldMainWidgetPos_ << std::endl;
649 
650 
651 // // save toplevel sizes to file
652 // saveTopLevelSizes(ofs);
653 
654 
655 // // save all events
656 // for(FootPrintIter it=events_.begin(); it!=events_.end(); ++it)
657 // {
658 // ofs << "###" << std::endl;
659 
660 // ofs << it->time << std::endl;
661 // ofs << it->name << std::endl;
662 // ofs << it->classname << std::endl;
663 // ofs << it->parent << std::endl;
664 // ofs << it->cursorPos << std::endl;
665 // ofs << it->position << std::endl;
666 // ofs << it->size << std::endl;
667 // ofs << (int)it->event->type() << std::endl;
668 
669 
670 // switch(it->event->type())
671 // {
672 // // mouse events ---------------------------------------------------------
673 // case QEvent::MouseButtonPress:
674 // case QEvent::MouseButtonRelease:
675 // case QEvent::MouseMove:
676 // case QEvent::MouseButtonDblClick:
677 // {
678 // QMouseEvent* e = (QMouseEvent*) it->event;
679 // ofs << e->pos() << std::endl;
680 // ofs << e->globalPos() << std::endl;
681 // ofs << (int)e->button() << std::endl;
682 // ofs << (int)e->state() << std::endl;
683 // break;
684 // }
685 
686 
687 // // wheel events ---------------------------------------------------------
688 // case QEvent::Wheel:
689 // {
690 // QWheelEvent* e = (QWheelEvent*) it->event;
691 // ofs << e->pos() << std::endl;
692 // ofs << e->globalPos() << std::endl;
693 // ofs << e->delta() << std::endl;
694 // ofs << (int)e->state() << std::endl;
695 // ofs << (int)e->orientation() << std::endl;
696 // break;
697 // }
698 
699 
700 // // key events -----------------------------------------------------------
701 // case QEvent::KeyPress:
702 // case QEvent::KeyRelease:
703 // case QEvent::Shortcut:
704 // case QEvent::ShortcutOverride:
705 // {
706 // QKeyEvent* e = (QKeyEvent*) it->event;
707 // ofs << (int)e->key() << std::endl;
708 // ofs << (int)e->ascii() << std::endl;
709 // ofs << (int)e->state() << std::endl;
710 // ofs << (int)e->isAutoRepeat() << std::endl;
711 // ofs << (int)e->count() << std::endl;
712 // break;
713 // }
714 
715 
716 // // context menu events --------------------------------------------------
717 // case QEvent::ContextMenu:
718 // {
719 // QContextMenuEvent* e = (QContextMenuEvent*) it->event;
720 // ofs << (int)e->reason() << std::endl;
721 // ofs << e->pos() << std::endl;
722 // ofs << e->globalPos() << std::endl;
723 // ofs << (int)e->state() << std::endl;
724 // break;
725 // }
726 
727 
728 // // move events ----------------------------------------------------------
729 // case QEvent::Move:
730 // {
731 // QMoveEvent* e = (QMoveEvent*) it->event;
732 // ofs << e->pos() << std::endl;
733 // ofs << e->oldPos() << std::endl;
734 // break;
735 // }
736 
737 
738 // // close events ---------------------------------------------------------
739 // case QEvent::Close:
740 // {
741 // // nothing has to be stored
742 // break;
743 // }
744 
745 
746 // default: // avoid warning
747 // break;
748 // }
749 // }
750 
751 // ofs.close();
752 }
753 
754 
755 //-----------------------------------------------------------------------------
756 
757 
758 void QtApplication::loadFile(const char* /* _filename */ )
759 {
760 // std::ifstream ifs(_filename, std::ios::in);
761 // if (!ifs) return;
762 
763 
764 // // helper
765 // std::string s;
766 // int size = 0;
767 // FootPrint fp;
768 
769 
770 
771 // // check header
772 // ifs >> s;
773 // if (s != "QTMacro")
774 // {
775 // std::cerr << "wrong file format!!!" << std::endl;
776 // return;
777 // }
778 // ifs >> size >> oldMainWidgetPos_;
779 
780 
781 // // alloc
782 // cleanUpEventBuffer();
783 // events_.clear();
784 
785 
786 // // load toplevel sizes
787 // loadTopLevelSizes(ifs);
788 
789 
790 // // load all events
791 // for(int i=0; i<size; ++i)
792 // {
793 // fp.event = 0;
794 
795 
796 // // check for errors
797 // ifs >> s;
798 // if (s!="###")
799 // {
800 // std::cerr << "Event parsing error: " << s << std::endl;
801 // return;
802 // }
803 
804 
805 // // general event data
806 // ifs >> fp.time;
807 // ifs.ignore(1, '\n');
808 // fp.name = read_name(ifs);
809 // fp.classname = read_name(ifs);
810 // fp.parent = read_name(ifs);
811 // ifs >> fp.cursorPos >> fp.position >> fp.size;
812 // ifs.ignore(1, '\n');
813 
814 
815 // // determine event type
816 // int type;
817 // ifs >> type;
818 
819 
820 // // type specific data
821 // switch(type)
822 // {
823 
824 // // mouse events ---------------------------------------------------------
825 // case QEvent::MouseButtonPress:
826 // case QEvent::MouseButtonRelease:
827 // case QEvent::MouseMove:
828 // case QEvent::MouseButtonDblClick:
829 // {
830 // QPoint pos, globalPos;
831 // int button, state;
832 
833 // ifs >> pos >> globalPos >> button >> state;
834 
835 // fp.event = new QMouseEvent((QEvent::Type)type,
836 // pos,
837 // globalPos,
838 // button,
839 // state);
840 // break;
841 // }
842 
843 
844 // // mouse wheel events ---------------------------------------------------
845 // case QEvent::Wheel:
846 // {
847 // int delta, state, orientation;
848 // QPoint pos, globalPos;
849 
850 // // read values from file
851 // ifs >> pos >> globalPos >> delta >> state >> orientation;
852 
853 // fp.event = new QWheelEvent(pos,
854 // globalPos,
855 // delta,
856 // state,
857 // (Qt::Orientation) orientation);
858 // break;
859 // }
860 
861 
862 // // key events -----------------------------------------------------------
863 // case QEvent::KeyPress:
864 // case QEvent::KeyRelease:
865 // case QEvent::Shortcut:
866 // case QEvent::ShortcutOverride:
867 // {
868 // int key, ascii, state, count, isAutoRepeat;
869 // char text[2];
870 
871 // ifs >> key >> ascii >> state >> isAutoRepeat >> count;
872 
873 // text[0] = (char)ascii;
874 // text[1] = '\0';
875 
876 // fp.event = new QKeyEvent((QEvent::Type)type,
877 // key,
878 // ascii,
879 // state,
880 // QString(text),
881 // isAutoRepeat,
882 // count);
883 // break;
884 // }
885 
886 
887 
888 // // context menu events --------------------------------------------------
889 // case QEvent::ContextMenu:
890 // {
891 // int reason, state;
892 // QPoint pos, globalPos;
893 
894 // ifs >> reason >> pos >> globalPos >> state;
895 
896 // fp.event = new QContextMenuEvent((QContextMenuEvent::Reason)reason,
897 // pos,
898 // globalPos,
899 // state);
900 // break;
901 // }
902 
903 
904 // // move events ----------------------------------------------------------
905 // case QEvent::Move:
906 // {
907 // QPoint pos, oldPos;
908 
909 // ifs >> pos >> oldPos;
910 
911 // fp.event = new QMoveEvent(pos, oldPos);
912 // break;
913 // }
914 
915 
916 // // close events ---------------------------------------------------------
917 // case QEvent::Close:
918 // {
919 // fp.event = new QCloseEvent();
920 // break;
921 // }
922 
923 
924 
925 // default:
926 // {
927 // std::cerr << "Error: unknown event type: " << type << std::endl;
928 // break;
929 // }
930 // }
931 
932 
933 // // store event
934 // if (fp.event) events_.push_back(fp);
935 // }
936 
937 
938 // ifs.close();
939 }
940 
941 
942 //-----------------------------------------------------------------------------
943 
944 
945 void QtApplication::saveTopLevelSizes(std::ostream & /* _os */ )
946 {
947 // _os << "TLS " << toplevels_.size() << std::endl;
948 
949 // for(FootPrintIter it=toplevels_.begin(); it!=toplevels_.end(); ++it)
950 // {
951 // _os << it->name << std::endl;
952 // _os << it->classname << std::endl;
953 // _os << it->parent << std::endl;
954 // _os << it->size << std::endl;
955 // }
956 
957 // _os << "ENDTLS" << std::endl;
958 
959 }
960 
961 
962 //-----------------------------------------------------------------------------
963 
964 
965 void QtApplication::loadTopLevelSizes(std::istream & /* _is */ )
966 {
967 // std::string s;
968 // int size;
969 // FootPrint fp;
970 
971 
972 // // check header
973 // _is >> s;
974 // if (s != "TLS")
975 // {
976 // std::cerr << "error in toplevel block (start)\n";
977 // return;
978 // }
979 // _is >> size;
980 // _is.ignore(1, '\n');
981 
982 
983 // // read top level sizes
984 // toplevels_.clear();
985 
986 // for(int i=0; i<size; i++)
987 // {
988 // // read names
989 // fp.name = read_name(_is);
990 // fp.classname = read_name(_is);
991 // fp.parent = read_name(_is);
992 
993 // // read size
994 // _is >> fp.size;
995 // _is.ignore(1, '\n');
996 
997 // // store footprint
998 // toplevels_.push_back(fp);
999 // }
1000 
1001 
1002 // _is >> s;
1003 // if (s != "ENDTLS")
1004 // {
1005 // std::cerr << "Error in toplevel block (end)\n";
1006 // return;
1007 // }
1008 // _is.ignore(1, '\n');
1009 }
1010 
1011 
1012 //=============================================================================
1013 } // namespace QtWidgets
1014 } // namespace ACG
1015 //=============================================================================
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51