summaryrefslogtreecommitdiffstats
path: root/src/gui/probepositioner.h
blob: 1be66dd66b275964301a64a19ef9a032ca4526f9 (plain)
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
/***************************************************************************
 *   Copyright (C) 2005 by David Saxton                                    *
 *   [email protected]                                                    *
 *                                                                         *
 *   This program is free software; 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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef PROBEPOSITIONER_H
#define PROBEPOSITIONER_H

#include <tqwidget.h>

class ProbeData;
typedef TQMap< int, ProbeData* > ProbeDataMap;

const float probeArrowWidth = 9;
const float probeArrowHeight = 12;

/**
Widget for positioning the output of Probes in the OscilloscopeView
@author David Saxton
*/
class ProbePositioner : public TQWidget
{
	TQ_OBJECT
  
	public:
		ProbePositioner(TQWidget *parent = 0, const char *name = 0);
		~ProbePositioner();
		/**
		 * Returns the amount of space (height in pixels) that a probe output
		 * takes up
		 */
		int probeOutputHeight() const;
		/**
		 * Returns the probe position (from the top) in pixels that the probe
		 * with the given id should be displayed at, or -1 if probe with the
		 * given id couldn't be found
		 */
		int probePosition( ProbeData *probeData ) const;
		/**
		 * Sets the probe position relative to the top of this widget (and hence
		 * relative to the top of the oscilloscope view) in pixels
		 */
		void setProbePosition( ProbeData *probeData, int position );
		/**
		 * Returns the probe at the given position (plus or minus an an arrow),
		 * or NULL if none. Records the offset of the position from the mouse
		 * in m_probePosOffset.
		 */
		ProbeData* probeAtPosition( const TQPoint &pos );
		
	public slots:
		void forceRepaint();
		
	protected slots:
		void slotProbeDataRegistered( int id, ProbeData *probe );
		void slotProbeDataUnregistered( int id );
		
	protected:
		virtual void mousePressEvent( TQMouseEvent * e );
		virtual void mouseReleaseEvent( TQMouseEvent * e );
		virtual void mouseMoveEvent( TQMouseEvent * e );
		virtual void paintEvent( TQPaintEvent *e );
		virtual void resizeEvent( TQResizeEvent *event );
		
		ProbeDataMap m_probeDataMap;
		ProbeData *p_draggedProbe;
		int m_probePosOffset;
		
		bool b_needRedraw;
		TQPixmap *m_pixmap;
};

#endif