File: events.cpp

package info (click to toggle)
dpuser 4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,084 kB
  • sloc: cpp: 124,807; ansic: 6,866; lex: 1,113; makefile: 777; yacc: 742; sh: 78
file content (69 lines) | stat: -rw-r--r-- 2,024 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
/*
 * Project: QFitsView
 * File:    events.cpp
 * Purpose: Communication events between QFitsView GUI and DPUSER
 * Author:  Thomas Ott
 * History: August 20, 2004: File created
 *             May 31, 2005: Add function "injectVariable"
 */

#include "events.h"
#include "dpuser.h"
#include "dpuser.yacchelper.h"
#include "qtdpuser.h"
#include "fits.h"
#include "QFitsGlobal.h"

extern int scriptlock;
extern std::map<std::string, bool>loopVariables;

void dpUpdateVar(const std::string what) {
        if (looplock == 0)
            dpuserthread.sendVar(what);
        else
            loopVariables[what] = true;
//	if (looplock == 0 && scriptlock == 0) {
//		dpDpuserEvent *ev = new dpDpuserEvent(what);
//		if (fitsMainWindow) QApplication::postEvent(fitsMainWindow, ev);
//	}
}

void dpUpdateView(const std::string what) {
    dpuserthread.sendView(what);
}

void dpCommandQFitsView(const char *what, const char *args, const int &option) {
    dpuserthread.sendCommand(what, args, option);
}

void dpProgress(const int what, const char *text) {
	dpuserthread.sendProgress(what, text);
//	QString str = text;
//	dpProgressEvent *ev = new dpProgressEvent(what, str);
//	QApplication::postEvent(fitsMainWindow, ev);
}

/*
 * inject a new variable in the dpuser working thread.
 * The variable will be of type FITS and initialised with
 * a copy of given data.
 * This bypasses the event loop, so the variable will NOT be
 * displayed automatically. To display, add the following code after
 * the call to injectVariable:
 *     QString cmd = "view " + name;
 *     dpuser_widget->executeCommand(cmd);
 */
std::string injectVariable(const QString &name, const Fits &data) {
    std::string rv;
	
        QWriteLocker locker(&buffersLock);
//	dpusermutex->lock();
    rv = name.toStdString();
    dpuser_vars[rv].type = typeFits;
    dpuser_vars[rv].fvalue = new Fits();
    dpuser_vars[rv].fvalue->copy(data);
//	dpusermutex->unlock();
	
	return rv;
}