File: gui_scope.h

package info (click to toggle)
gpsim 0.32.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,640 kB
  • sloc: cpp: 121,258; asm: 54,223; ansic: 13,576; python: 9,708; sh: 4,695; makefile: 1,566; lex: 1,139; yacc: 854; pascal: 511; perl: 93; awk: 44; xml: 41
file content (159 lines) | stat: -rw-r--r-- 4,201 bytes parent folder | download | duplicates (2)
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
/*
   Copyright (C) 1998,1999,2000,2001,2002,2003,2004
   T. Scott Dattalo and Ralf Forsberg

This file is part of gpsim.

gpsim 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, or (at your option)
any later version.

gpsim is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with gpsim; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */

#ifndef GUI_GUI_SCOPE_H_
#define GUI_GUI_SCOPE_H_

#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <glib.h>

#include <valarray>
#include <vector>
#include "gui_object.h"

class GUI_Processor;
class TimeMarker;
class ZoomAttribute;
class PanAttribute;
class Waveform;
class SignalNameEntry;
class TimeAxis;

class GridPointMapping {
public:
  explicit GridPointMapping(int nPointsToMap);
  ~GridPointMapping();

  int     pixel(int index)
  {
    return (index < m_nPoints) ? m_pixel[index] : 0;
  }
  guint64 cycle(int index)
  {
    return (index < m_nPoints) ? m_cycle[index] : 0;
  }
  int sze()
  {
    return m_nPoints;
  }

  int      m_nPoints;
  std::valarray<int> m_pixel;
  std::valarray<guint64> m_cycle;
};


//
// The Scope Window
//

class Scope_Window : public GUI_Object {
public:
  explicit Scope_Window(GUI_Processor *gp);
  Scope_Window(const Scope_Window &) = delete;
  Scope_Window& operator =(const Scope_Window &) = delete;

  void Build() override;
  void Update() override;

  /// zoom - positive values mean zoom in, negative values mean zoom out
  void zoom(int);

  /// pan - positive values mean pan right, negative values mean pan left.
  void pan(int);

  /// getSpan - returns time span currently cached (essentially tStop-tStart).
  gdouble getSpan();

  /// mapTimeToPixel - convert time to a pixel horizontal offset.
  int mapTimeToPixel(guint64 time);

  GridPointMapping &MajorTicks()
  {
    return m_MajorTicks;
  }
  GridPointMapping &MinorTicks()
  {
    return m_MinorTicks;
  }

private:
  /// Signals for the scope window
  static gint signalButtonPress(GtkWidget *, GdkEventButton *, Scope_Window *sw);
  static gint signalEntryKeyPress(GtkEntry *, GdkEventKey *, Scope_Window *sw);
  static gboolean signal_name_expose(GtkWidget *widget,
                                     GdkEventExpose *event, Scope_Window *sw);
  static gboolean signal_expose(GtkWidget *widget,
                                GdkEventExpose *event, Scope_Window *sw);
  static gboolean key_press(GtkWidget *widget, GdkEventKey *key,
                            Scope_Window *sw);
  static gboolean on_configure(GtkWidget *widget, GdkEvent *event, Scope_Window *sw);

  /// selectSignalName - begin the signal name editing mode
  /// returns true if selection state has changed.
  bool selectSignalName(int y);

  /// endSignalNameSelection - end the signal name editing mode.
  bool endSignalNameSelection(bool bAccept);

  ///
  int waveXoffset();

  /// gridPoints - Fill the major and minor axis grid point arrays
  ///   These arrays map time values into pixel coordinates.
  void gridPoints(guint64 *start, guint64 *stop);

  /// Adjust the internal representation to account for a change of the
  /// window size on screen
  void setWidth ( int w );

  enum {
    eStart = 0,
    eStop,
    eLeftButton,
    eRightButton,
    eNumMarkers
  } MarkerLabels;

  TimeMarker *m_Markers[eNumMarkers];
  ZoomAttribute *m_zoom;
  PanAttribute  *m_pan;

  GtkWidget *m_pHpaned;     /* The signal names and waves are rendered
			       in a horizontal pane */
  GtkWidget *m_phScrollBar; // scroll bar for the waves

  int m_PixmapWidth; // Width of waveform pixmaps.

  GridPointMapping m_MajorTicks;
  GridPointMapping m_MinorTicks;

  bool m_bFrozen;

  GtkObject *m_hAdj;
  SignalNameEntry *m_entry;
  TimeAxis *m_TimeAxis;
  std::vector<Waveform *> signals;
};


#endif // GUI_GUI_SCOPE_H_