summaryrefslogtreecommitdiff
blob: 5be4aec9e9c512f758d34aebd55ce4dea6e2208c (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
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
diff --git a/src/ImportOPJ.cc b/src/ImportOPJ.cc
index 2b625d4..c49752f 100644
--- a/src/ImportOPJ.cc
+++ b/src/ImportOPJ.cc
@@ -12,6 +12,44 @@
 
 #include <liborigin/OPJFile.h>
 
+// The declaration of liborigin's OPJFile::colType() changed from
+//     const char *OPJFile::colType(int, int) const;
+// in version 20071119 to
+//     ColumnType OPJFile::colType(int, int) const;
+// in version 20080225. This function can be used to get the string
+// that colType() returned in liborigin/20071119 from the ColumnType
+// that colType() returns in liborigin/20080225. The use of this
+// function requires a build-dependency on liborigin (>= 20080225).
+QString colTypeToString(const ColumnType type) {
+    QString type_str = "";
+
+    switch (type) {
+    case X:
+        type_str = "X";
+        break;
+    case Y:
+        type_str = "Y";
+        break;
+    case Z:
+        type_str = "Z";
+        break;
+    case XErr:
+        type_str = "DX";
+        break;
+    case YErr:
+        type_str = "DY";
+        break;
+    case Label:
+        type_str = "LABEL";
+        break;
+    case NONE:
+        type_str = "NONE";
+        break;
+    }
+
+    return type_str;
+}
+
 ImportOPJ::ImportOPJ(MainWin *mw, QString filename)
 	: mw(mw),filename(filename)
 {}
@@ -44,13 +82,13 @@ int ImportOPJ::import() {
 		for (int j=0;j<nr_cols;j++) {
 			QString name(opj.colName(s,j));
 			spread->setColumnTitle(j,name.replace(QRegExp(".*_"),""));
-			spread->setColumnType(j,opj.colType(s,j));
+			spread->setColumnType(j,colTypeToString(opj.colType(s,j)));
 
 			for (int i=0;i<opj.numRows(s,j);i++) {
 				double *v = (double *) opj.oData(s,j,i,true);
 
 				LTableItem *item;
-				if(strcmp(opj.colType(s,j),"LABEL")) {	// number
+				if(strcmp(colTypeToString(opj.colType(s,j)),"LABEL")) {	// number
 					if(fabs(*v)>0 && fabs(*v)<2.0e-300)	// empty entry
 						continue;
 					item = new LTableItem( table, QTableItem::OnTyping,QString::number(*v));
@@ -62,7 +100,7 @@ int ImportOPJ::import() {
 		}
 	}
 	for (int s=0;s<opj.numMatrices();s++) {
-		kdDebug()<<"		Matrix "<<s+1<<" : "<<opj.matrixName(s)<<" (ParentFolder : "<<opj.matrixParentFolder(s)<<")"<<endl;
+		kdDebug()<<"		Matrix "<<s+1<<" : "<<opj.matrixName(s)<<endl; //" (ParentFolder : "<<opj.matrixParentFolder(s)<<")"<<endl;
 		kdDebug()<<"			Label : "<<opj.matrixLabel(s)<<" Cols/Rows : "<<opj.numMatrixCols(s)<<'/'<<opj.numMatrixRows(s)<<endl;
 		kdDebug()<<"			Formula : "<<opj.matrixFormula(s)<<" DisplayType : "<<opj.matrixNumDisplayType(s)<<endl;
 
@@ -99,7 +137,7 @@ int ImportOPJ::import() {
 
 	QString notes = mw->getProject()->Notes();
 	for (int s=0;s<opj.numNotes();s++) {
-		kdDebug()<<"		Note "<<s+1<<" : "<<opj.noteName(s)<<" (ParentFolder : "<<opj.noteParentFolder(s)<<")"<<endl;
+		kdDebug()<<"		Note "<<s+1<<" : "<<opj.noteName(s)<<endl; //" (ParentFolder : "<<opj.noteParentFolder(s)<<")"<<endl;
 		kdDebug()<<"			Label : "<<opj.noteLabel(s)<<" Text : "<<opj.noteText(s)<<endl;
 		notes.append(QString(opj.noteLabel(s))+":\n");
 		notes.append(opj.noteText(s));
@@ -115,7 +153,7 @@ int ImportOPJ::import() {
 	}
 
 	for (int s=0;s<opj.numGraphs();s++) {
-		kdDebug()<<"		Graph "<<s+1<<" : "<<opj.graphName(s)<<" (ParentFolder : "<<opj.graphParentFolder(s)<<")"<<endl;
+		kdDebug()<<"		Graph "<<s+1<<" : "<<opj.graphName(s)<<endl; //" (ParentFolder : "<<opj.graphParentFolder(s)<<")"<<endl;
 		kdDebug()<<"			Label : "<<opj.graphLabel(s)<<" Layers : "<<opj.numLayers(s)<<endl;
 
 		Worksheet *work = mw->newWorksheet();
@@ -139,8 +177,10 @@ int ImportOPJ::import() {
 #else
 			kdDebug()<<"Layer	x axis : "<<opj.layerXAxisTitle(s,l).txt<<endl;
 			kdDebug()<<"Layer	y axis : "<<opj.layerYAxisTitle(s,l).txt<<endl;
-			Label *xlabel = new Label(parseOriginText(opj.layerXAxisTitle(s,l).txt));
-			Label *ylabel = new Label(parseOriginText(opj.layerYAxisTitle(s,l).txt));
+
+            // The name Label is ambiguous, therefore use LPLabel here.
+			LPLabel *xlabel = new LPLabel(parseOriginText(opj.layerXAxisTitle(s,l).txt));
+			LPLabel *ylabel = new LPLabel(parseOriginText(opj.layerYAxisTitle(s,l).txt));
 			kdDebug()<<"Layer	legend : "<<opj.layerLegend(s,l).txt<<endl;
 #endif
 			plot->getAxis(0)->setLabel(xlabel);
@@ -342,11 +382,11 @@ int ImportOPJ::import() {
 			}
 
 			// axis range
-			vector<double> xrange=opj.layerXRange(s,l);
-			vector<double> yrange=opj.layerYRange(s,l);
+			graphLayerRange xrange=opj.layerXRange(s,l);
+			graphLayerRange yrange=opj.layerYRange(s,l);
 			LRange range[2];
-			range[0] = LRange(xrange[0],xrange[1]);
-			range[1] = LRange(yrange[0],yrange[1]);
+			range[0] = LRange(xrange.min,xrange.max);
+			range[1] = LRange(yrange.min,yrange.max);
 			plot->setActRanges(range);
 
 			// axis scale
diff --git a/src/Label.h b/src/Label.h
index b61c55b..5aa7097 100644
--- a/src/Label.h
+++ b/src/Label.h
@@ -66,4 +66,10 @@ private:
 	bool is_texlabel;		// if it is a tex label
 };
 
+// <liborigin/OPJFile.h> defines an enumerator of the type ColumnType with
+// the name Label in the global namespace. Since the class Label defined in
+// this file ("Label.h") collides with the aforementioned enumerator in
+// "ImportOPJ.cc" we define a synonym for Label here to avoid the ambiguity.
+typedef Label LPLabel;
+
 #endif //LABEL_H