File: View.sip

package info (click to toggle)
tulip 4.8.0dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 179,264 kB
  • ctags: 64,517
  • sloc: cpp: 600,444; ansic: 36,311; makefile: 22,136; python: 1,304; sh: 946; yacc: 522; xml: 337; pascal: 157; php: 66; lex: 55
file content (297 lines) | stat: -rw-r--r-- 8,269 bytes parent folder | download
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
/**
 *
 * This file is part of Tulip (www.tulip-software.org)
 *
 * Authors: David Auber and the Tulip development Team
 * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
 *
 * Tulip is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3
 * of the License, or (at your option) any later version.
 *
 * Tulip 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.
 *
 */

%ModuleHeaderCode
#include <tulip/NodeLinkDiagramComponent.h>
#include <tulip/GlMainView.h>
#include <tulip/View.h>
#include <QPixmap>
#include <QImage>
#include <QGraphicsView>
#include <iostream>
#include <stdint.h>
%End

namespace tlp {

class View  : tlp::Plugin /Abstract/ {
%TypeHeaderCode
#include <tulip/View.h>
%End

%ConvertToSubClassCode
   if (dynamic_cast<tlp::NodeLinkDiagramComponent*>(sipCpp)) {
        sipType = sipFindType("tlp::NodeLinkDiagramComponent");
   } else if (dynamic_cast<tlp::GlMainView*>(sipCpp)) {
        sipType = sipFindType("tlp::GlMainView");
   } else {
        sipType = NULL;
   }
%End

%Docstring
.. versionadded:: 4.4

Bases: :class:`tulip.tlp.Plugin`

This is the base class for Tulip data views. Use the following functions to get instances on such object :

    * :func:`tlpgui.createView`
    * :func:`tlpgui.getOpenedViews`
    * :func:`tlpgui.getViewsOfGraph`

%End

public:

// =========================================================================================================================

   View();

// =========================================================================================================================

   virtual ~View();

// =========================================================================================================================

    virtual void setState(const tlp::DataSet &dataSet) = 0;
%Docstring
tlpgui.View.setState(dataSet)

Sets the parameters for the view.

:param dataSet: the view parameters
:type dataSet: :class:`tulip.tlp.DataSet`
%End

// =========================================================================================================================

    virtual void setGraph(tlp::Graph *graph) = 0;
%Docstring
tlpgui.View.setGraph(graph)

Sets the graph for the view. The current parameters will be kept.

:param graph: the graph from which the view will be drawn.
:type graph: :class:`tulip.tlp.Graph`
%End

%MethodCode
    tvm.graphModel()->addGraph(a0);
    if (!tvm.tlpWorkspace()) {
      a0->addListener(&tvm);
    }
    sipCpp->setGraph(a0);
%End

// =========================================================================================================================

    virtual tlp::DataSet state() const = 0;
%Docstring
tlpgui.View.state()

Returns the current parameters of the view.

:rtype: :class:`tulip.tlp.DataSet`
%End

// =========================================================================================================================

    virtual tlp::Graph *graph() = 0;
%Docstring
tlpgui.View.graph()

Returns the graph currently attached to the view.

:rtype: :class:`tulip.tlp.Graph`
%End

	virtual void draw() = 0;
%Docstring
tlpgui.View.draw()

Draws/Updates the view.
%End

%MethodCode
    sipCpp->draw();
    QApplication::processEvents();
%End

// =========================================================================================================================

    void setVisible(const bool visible);
%Docstring
tlpgui.View.setVisible(visible)

Hides / Shows the view window. That method has effects only when working trough the
classical Python interpreter.

:param visible: the state of the view window visibility
:type visible: boolean

%End

%MethodCode
    tvm.setViewVisible(sipCpp, a0);
%End

// =========================================================================================================================

    void resize(int width, int height);
%Docstring
tlpgui.View.resize(width, height)

Resizes the view windows. That method has effects only when working trough the
classical Python interpreter.

:param width: the new width of the view window
:type width: integer
:param height: the new height of the view window
:type height: integer
%End

%MethodCode
    tvm.resizeView(sipCpp, a0, a1);
%End

// =========================================================================================================================

    void setPos(int x, int y);
%Docstring
tlpgui.View.setPos(x, y)

Set the position on screen of the view windows. That method has effects only when working trough the
classical Python interpreter.

:param x: the new x position of the view window
:type x: integer
:param y: the new y position of the view window
:type y: integer
%End

%MethodCode
    tvm.setViewPos(sipCpp, a0, a1);
%End

// =========================================================================================================================

  bool saveSnapshot(const std::string& pictureName, int width=-1, int height=-1);
%Docstring
tlpgui.View.saveSnapshot(picturePath, width, height)

Takes a snapshot of the view and saves it to an image file on disk.
The view is not required to be visible for that feature to work.
Returns :const:`True` if the operation succeeds.

:param picturePath: the absolute path of the image file with extension (used to infer image type)
:type picturePath: string
:param width: the image width
:type width: integer
:param height: the image height
:type height: integer
:rtype: boolean
%End

%MethodCode
    QPixmap snapshot = sipCpp->snapshot(QSize(a1, a2));
    sipRes = snapshot.toImage().save(a0->c_str());
%End

// =========================================================================================================================

    std::list<tlp::Interactor*> interactors() const;
%Docstring
tlpgui.View.interactors()

Returns the interactors currently installed on the view.

:rtype: list of :class:`tlpgui.Interactor`
%End

%MethodCode
    std::list<tlp::Interactor*> ret;
    QList<tlp::Interactor*> interactors = sipCpp->interactors();
    for (int i = 0 ; i < interactors.count() ; ++i) {
        ret.push_back(interactors.at(i));
    }
    sipRes = new std::list<tlp::Interactor*>(ret);
%End

// =========================================================================================================================

    tlp::Interactor* currentInteractor() const;
%Docstring
tlpgui.Interactor.currentInteractor()

Returns the current active interactor of the view.

:rtype: :class:`tlpgui.Interactor`
%End


// =========================================================================================================================

    std::list<tlp::Observable*> triggers() const;
%MethodCode
    std::list<tlp::Observable*> ret;
    QSet<tlp::Observable*> obs = sipCpp->triggers();
    QSet<tlp::Observable *>::const_iterator i = obs.constBegin();
    for ( ; i != obs.constEnd() ; ++i) {
        ret.push_back(*i);
    }
    sipRes = new std::list<tlp::Observable*>(ret);
%End

// =========================================================================================================================

    void setInteractors(const std::list<tlp::Interactor*>&);
%Docstring
tlpgui.View.setInteractors(interactors)

Installs a new set of interactors on the view.

:param interactors: the new interactors to install
:type interactors: list of :class:`tlpgui.Interactor`
%End


%MethodCode
    QList<tlp::Interactor*> param;
    std::list<tlp::Interactor*>::const_iterator it = a0->begin();
    for (; it != a0->end() ; ++it) {
        param.append(*it);
    }
    sipCpp->setInteractors(param);
%End

// =========================================================================================================================

    void setCurrentInteractor(tlp::Interactor* currentInteractor);
%Docstring
tlpgui.View.setCurrentInteractor(interactor)

Set the current active interactor on the view.

:param interactor: the interactor to set active
:type interactor: :class:`tlpgui.Interactor`
%End

};
};