/
sstQt01PathStoreView.cpp
784 lines (667 loc) · 23.9 KB
/
sstQt01PathStoreView.cpp
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
/**********************************************************************
*
* sstQt01Lib - sst Qt library
* Hosted on github
*
* Copyright (C) 2016 Uli Rehr
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
// sstQt01PathStoreView.cpp 23.07.18 Re. 23.07.18 Re.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <string>
#include <QtWidgets>
#include <QTreeView>
#include <QStandardItemModel>
#include <QItemSelectionModel>
#include <QTextBrowser>
#include <QPen>
#include <QColor>
#include <QPainterPath>
#include <QPoint>
#include <sstStr01Lib.h>
#include <sstMisc01Lib.h>
#include <sstRec04Lib.h>
#include <sstQt01Lib.h>
#include "sstQt01LibInt.h"
//=============================================================================
sstQt01PathStoreViewCls::sstQt01PathStoreViewCls(sstMisc01PrtFilCls *poTmpPrt)
{
dActualReadPos = 1; // table reading starts at begin of table
dActualReadPosSym = 1; // table reading starts at begin of table
this->poPrt = poTmpPrt;
this->uiVersion = 0; // default not known format version in csv file
}
//=============================================================================
sstQt01PathStoreViewCls::~sstQt01PathStoreViewCls()
{
}
//=============================================================================
int sstQt01PathStoreViewCls::LoadAllPathFromFile (int iKey, std::string oFilNam)
{
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
int iVers = this->FindCsvFileVersion(0,oFilNam);
if (iVers <= 0)return -2;
switch (iVers)
{
case 1:
iStat = this->LoadAllPathFromFile1(0,oFilNam);
break;
case 2:
iStat = this->LoadAllPathFromFile2(0,oFilNam);
break;
case 3:
iStat = this->LoadAllPathFromFile3(0,oFilNam);
break;
default:
assert(0);
break;
}
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::LoadAllPathFromFile3 (int iKey, std::string oFilNam)
{
sstQt01PathStorageCls *poPathTabStore;
// int iStat1 = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
poPathTabStore = new sstQt01PathStorageCls(this->poPrt);
iStat = poPathTabStore->LoadAllPathFromFile(0,oFilNam);
if (iStat < 0)
{
delete poPathTabStore;
return -2;
}
for (int ll = 1; ll <= poPathTabStore->countItems(); ll++)
{
sstQt01ShapeItem oShapeItem = poPathTabStore->getShapeItem(ll);
this->shapeItems.push_back(oShapeItem);
}
delete poPathTabStore;
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::LoadAllPathFromFile2 (int iKey, std::string oFilNam)
{
sstMisc01AscFilCls oPainterCsvFile;
std::string oCsvStr;
std::string oErrStr;
sstQt01PathElementCsv2Cls oShapeItemCsv2;
sstQt01PathElementCsv3Cls oShapeItemCsv3;
int iStat1 = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
iStat = oPainterCsvFile.fopenRd(0,oFilNam.c_str());
if (iStat < 0) return -2;
// Read and test title row
iStat = oPainterCsvFile.Rd_StrDS1( 0, &oCsvStr);
this->poPrt->SST_PrtWrt(1,(char*)"Version 2 found");
// load csv file into sst record table
iStat1 = oPainterCsvFile.Rd_StrDS1( 0, &oCsvStr);
while (iStat1 >= 0)
{
// interpret file row as path element
iStat = oShapeItemCsv2.ReadFromCsv( 0, oCsvStr, &oErrStr);
assert (iStat == 0);
oShapeItemCsv3.setFromVers2(oShapeItemCsv2);
// Write new Main Record in table if Element is next path <BR>
iStat = this->NewMainWithElement(0,&oShapeItemCsv3);
// Read next row from csv file
iStat1 = oPainterCsvFile.Rd_StrDS1(0,&oCsvStr);
}
// close csv file
oPainterCsvFile.fcloseFil(0);
// Update Maintable from Elementtable
iStat = this->UpdateMainPathSizeFromEleTab(0);
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::LoadAllPathFromFile1 (int iKey, std::string oFilNam)
{
sstMisc01AscFilCls oPainterCsvFile;
std::string oCsvStr;
std::string oErrStr;
sstQt01PathElementCsv1Cls oShapeItemCsv1;
sstQt01PathElementCsv2Cls oShapeItemCsv2;
sstQt01PathElementCsv3Cls oShapeItemCsv3;
int iStat1 = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
iStat = oPainterCsvFile.fopenRd(0,oFilNam.c_str());
if (iStat < 0) return -2;
// Read and test title row
iStat = oPainterCsvFile.Rd_StrDS1( 0, &oCsvStr);
this->poPrt->SST_PrtWrt(1,(char*)"Version 1 found");
// load csv file into sst record table
iStat1 = oPainterCsvFile.Rd_StrDS1( 0, &oCsvStr);
while (iStat1 >= 0)
{
// interpret file row as path element
iStat = oShapeItemCsv1.ReadFromCsv( 0, oCsvStr, &oErrStr);
assert (iStat == 0);
oShapeItemCsv2.setFromVers1(oShapeItemCsv1);
oShapeItemCsv3.setFromVers2(oShapeItemCsv2);
// Write new Main Record in table if Element is next path <BR>
iStat = this->NewMainWithElement(0,&oShapeItemCsv3);
// Read next row from csv file
iStat1 = oPainterCsvFile.Rd_StrDS1(0,&oCsvStr);
}
// close csv file
oPainterCsvFile.fcloseFil(0);
// Update Maintable from Elementtable
iStat = this->UpdateMainPathSizeFromEleTab(0);
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::StoreAllPathToFile (int iKey, std::string oFilNam)
{
sstQt01PathStorageCls *poPathTabStore;
// int iStat1 = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
poPathTabStore = new sstQt01PathStorageCls(this->poPrt);
QList<sstQt01ShapeItem>::iterator it;
for (it = this->shapeItems.begin(); it != this->shapeItems.end(); ++it)
{
poPathTabStore->appendShapeItem(*it);
}
iStat = poPathTabStore->StoreAllPathToFile(0,oFilNam);
delete poPathTabStore;
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::AppendPath(int iKey,
QPainterPath oTmpPath,
sstQt01ShapeType_enum eTmpPathType,
QColor oTmpColor,
QPen oTmpPen)
{
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem.setPath(oTmpPath);
oShapeItem.setShapeType(eTmpPathType);
oShapeItem.setColor(oTmpColor);
oShapeItem.setPen(oTmpPen);
this->shapeItems.append(oShapeItem);
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::AppendPathSymbol(int iKey,
QPainterPath oTmpPath,
sstQt01ShapeType_enum eTmpPathType,
QColor oTmpColor,
QPen oTmpPen)
{
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
int iEleNum = oTmpPath.elementCount();
for (int ii =1; ii <= iEleNum; ii++)
{
sstQt01PathElementCsv3Cls oShapeItemCsv;
QPainterPath::Element oElement;
oElement = oTmpPath.elementAt(ii-1);
oShapeItemCsv.setAll(oElement.type,oElement.x,oElement.y, oTmpColor);
if (oElement.type == 0)
{
oShapeItemCsv.setIPenStyle(oTmpPen.style());
oShapeItemCsv.setIPenWidth(oTmpPen.width());
oShapeItemCsv.setShapeType(eTmpPathType);
}
}
return 0;
}
//=============================================================================
int sstQt01PathStoreViewCls::ReadNextPath(int iKey, QPainterPath *oTmpPath, QColor *oTmpColor)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
// PainterPath object should be empty
if (oTmpPath->elementCount() != 0) return -2;
// stop reading at end of table
if (this->dActualReadPos >= this->countItems()) return -3;
oShapeItem = this->getShapeItem(this->dActualReadPos);
this->dActualReadPos++;
*oTmpPath = oShapeItem.getPath();
*oTmpColor = oShapeItem.getColor();
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::ReadPath(int iKey, dREC04RECNUMTYP dStartElementRecNo, QPainterPath *oTmpPath)
{
sstQt01PathElementCsv3Cls oShapeItemCsv1;
sstQt01PathElementCsv3Cls oShapeItemCsv2;
sstQt01PathElementCsv3Cls oShapeItemCsv3;
// int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
// PainterPath object should be empty
if (oTmpPath->elementCount() != 0) return -2;
this->dActualReadPos = dStartElementRecNo;
oTmpPath->moveTo(oShapeItemCsv1.getIXX(),oShapeItemCsv1.getIYY());
return 0;
}
//=============================================================================
dREC04RECNUMTYP sstQt01PathStoreViewCls::RecordCount() const
{
return 0;
}
//=============================================================================
unsigned int sstQt01PathStoreViewCls::ColumnCount() const
{
sstQt01PathElementCsv3Cls oElementCsvRecord;
return oElementCsvRecord.ColumnCount();
}
//=============================================================================
QString sstQt01PathStoreViewCls::getToolTip(dREC04RECNUMTYP index)
{
sstQt01ShapeItem oShapeItem;
int iStat = 0;
oShapeItem = this->shapeItems.at(index-1);
assert(iStat == 0);
return oShapeItem.getToolTip();
}
//=============================================================================
int sstQt01PathStoreViewCls::setToolTip(dREC04RECNUMTYP index, QString oTooltip)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at(index-1);
oShapeItem.setToolTip( oTooltip);
this->shapeItems.replace(index-1,oShapeItem);
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::setToolTip(dREC04RECNUMTYP index, std::string oTooltip)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
oShapeItem.setToolTip( QString::fromStdString(oTooltip));
this->shapeItems.replace( index-1, oShapeItem);
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::setPosition(dREC04RECNUMTYP index, QPoint oPosition)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
oShapeItem.setPosition(oPosition);
this->shapeItems.replace( index-1, oShapeItem);
return iStat;
}
//=============================================================================
QPoint sstQt01PathStoreViewCls::getPosition(dREC04RECNUMTYP index)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
assert(iStat >= 0);
return oShapeItem.getPosition();
}
//=============================================================================
int sstQt01PathStoreViewCls::addPosition(dREC04RECNUMTYP index)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
assert(iStat >= 0);
QPoint oPnt = oShapeItem.getPosition();
oShapeItem.setPosition(oPnt);
this->shapeItems.replace( index-1, oShapeItem);
return 0;
}
//=============================================================================
int sstQt01PathStoreViewCls::addPositionSym(dREC04RECNUMTYP index)
{
int iStat = 0;
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
QPoint oPnt = oShapeItem.getPosition();
oShapeItem.setPosition(oPnt);
this->shapeItems.replace( index-1, oShapeItem);
return iStat;
}
//=============================================================================
QColor sstQt01PathStoreViewCls::getColor(dREC04RECNUMTYP index)
{
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
return oShapeItem.getColor();
}
//=============================================================================
QPen sstQt01PathStoreViewCls::getPen(dREC04RECNUMTYP index)
{
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
return oShapeItem.getPen();
}
//=============================================================================
QPainterPath sstQt01PathStoreViewCls::getPath(dREC04RECNUMTYP index)
{
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
QPainterPath oPath;
oPath = oShapeItem.getPath();
return oPath;
}
//=============================================================================
sstQt01ShapeItem sstQt01PathStoreViewCls::getShapeItem(dREC04RECNUMTYP index)
{
sstQt01ShapeItem oItem;
oItem = this->shapeItems.at( index-1);
return oItem;
}
//=============================================================================
int sstQt01PathStoreViewCls::getShapeItem2(int iKey, dREC04RECNUMTYP index,sstQt01ShapeItem *poShapeItem)
{
int iRet = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
sstQt01ShapeItem oItem;
*poShapeItem = this->shapeItems.at( index-1);
assert(iRet >= 0);
// Small Errors will given back
iRet = iStat;
return iRet;
}
//=============================================================================
int sstQt01PathStoreViewCls::appendShapeItem(sstQt01ShapeItem oItem)
{
// Append to element table
// Store Init Position before interactive
// Moving,Scaling,Rotating PainterPath Object
QPainterPath::Element oElement;
sstMath01dPnt2Cls oInitPos;
oItem.getFirstPathElement(&oElement);
oInitPos.Set((double)oElement.x,(double)oElement.y);
oItem.setInitPos(oInitPos);
this->shapeItems.append( oItem);
return 0;
}
//=============================================================================
int sstQt01PathStoreViewCls::appendItemSymbol(sstQt01ShapeItem oItem)
{
// Append to element table
QPainterPath oPath = oItem.getPath();
int iStat = this->AppendPathSymbol(0,oPath,oItem.getShapeType(), oItem.getColor(),oItem.getPen());
assert(iStat >= 0);
// Append to main table
sstQt01PathMainRecCls oMainRec;
oMainRec.setQCol(oItem.getColor());
oMainRec.setPosition(oItem.getPosition());
int iNumElements = oPath.elementCount();
dREC04RECNUMTYP dLastRecNo = 0;
oMainRec.setStartElementRecNo(dLastRecNo-iNumElements+1);
oMainRec.setNumElements(iNumElements);
oMainRec.setShapeType(oItem.getShapeType());
QString oToolTipStr = oItem.getToolTip();
oMainRec.setTooltip(oToolTipStr.toStdString());
// Store Extern Id for example dxf in sstPathStorage
dREC04RECNUMTYP dExternId = oItem.getExternId();
oMainRec.setExternId(dExternId);
dREC04RECNUMTYP dRecNo = 0;
// move position from main table to element table
this->addPositionSym(dRecNo);
return iStat;
}
//=============================================================================
unsigned int sstQt01PathStoreViewCls::countItems()
{
unsigned int uiRecs = this->shapeItems.count();
return uiRecs;
}
//=============================================================================
int sstQt01PathStoreViewCls::createDefaultItems(int iKey)
{
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
QPainterPath circlePath;
QPainterPath squarePath;
QPainterPath trianglePath;
circlePath.addEllipse(QRect(0, 0, 100, 100));
squarePath.addRect(QRect(0, 0, 100, 100));
qreal x = trianglePath.currentPosition().x();
qreal y = trianglePath.currentPosition().y();
trianglePath.moveTo(x + 120 / 2, y);
trianglePath.lineTo(0, 100);
trianglePath.lineTo(120, 100);
trianglePath.lineTo(x + 120 / 2, y);
sstQt01ShapeItem oItem;
oItem.createShapeItem(circlePath, "Circle", initialItemPosition(circlePath),
initialItemColor(),eSstQt01PathCircle);
this->appendShapeItem(oItem);
oItem.createShapeItem(squarePath, "Square", initialItemPosition(squarePath),
initialItemColor(),eSstQt01PathArea);
this->appendShapeItem(oItem);
oItem.createShapeItem(trianglePath, "Triangle",
initialItemPosition(trianglePath), initialItemColor(),eSstQt01PathArea);
this->appendShapeItem(oItem);
return 0;
}
//=============================================================================
QPoint sstQt01PathStoreViewCls::initialItemPosition(const QPainterPath &path)
{
int x;
int y = (height - (int)path.controlPointRect().height()) / 2;
// if (shapeItems.size() == 0)
if ( this->countItems() == 0)
x = ((3 * width) / 2 - (int)path.controlPointRect().width()) / 2;
else
// x = (width / shapeItems.size()
x = (width / this->countItems()
- (int)path.controlPointRect().width()) / 2;
return QPoint(x, y);
}
//=============================================================================
QColor sstQt01PathStoreViewCls::initialItemColor()
{
return QColor::fromHsv(((this->countItems() + 1) * 85) % 256, 255, 190);
}
//=============================================================================
int sstQt01PathStoreViewCls::SearchPathItem(int iKey, dREC04RECNUMTYP dRowNum, dREC04RECNUMTYP *dItemNum)
{
sstQt01PathMainRecCls oMainRec;
int iRet = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
// dREC04RECNUMTYP dMaxRow = this->poShapeItemMainTable->count();
dREC04RECNUMTYP dMaxRow = 0;
for (dREC04RECNUMTYP ll=1; ll <= dMaxRow; ll++)
{
if (dRowNum >= oMainRec.getStartElementRecNo() && dRowNum <= oMainRec.getEndElementRecNo())
{
*dItemNum = ll;
return 0;
}
}
*dItemNum = 0;
iStat = -2;
// Fatal Errors goes to an assert
assert(iRet >= 0);
// Small Errors will given back
iRet = iStat;
return iRet;
}
//=============================================================================
int sstQt01PathStoreViewCls::DeletePathItem(int iKey, dREC04RECNUMTYP dItemNum)
{
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
this->shapeItems.removeAt(dItemNum-1);
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::UpdatePathItem(int iKey, dREC04RECNUMTYP dItemNo)
{
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
dREC04RECNUMTYP dNumItems = this->shapeItems.count();
if (dItemNo > dNumItems ) return -2;
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::UpdateTabElement(int iKey)
{
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::UpdateMainAttribFromElemTab(int iKey)
{
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
return iStat;
}
//=============================================================================
int sstQt01PathStoreViewCls::FindCsvFileVersion(int iKey, const std::string sFilNam)
{
sstQt01PathElementCsv1Cls oCsvVers1;
sstQt01PathElementCsv2Cls oCsvVers2;
sstQt01PathElementCsv3Cls oCsvVers3;
sstMisc01AscFilCls oPathCsvFil;
int iVers = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
// Open Asc File for reading
iStat = oPathCsvFil.fopenRd ( 0, sFilNam.c_str());
if (iStat < 0) return -2;
// Read Header row from Path csv file
std::string sHeaderRow;
iStat = oPathCsvFil.Rd_StrDS1( 0, &sHeaderRow);
iStat =sHeaderRow.compare(oCsvVers3.GetCsvFileTitle());
if (iStat == 0)
{
iVers = 3;
}
iStat =sHeaderRow.compare(oCsvVers2.GetCsvFileTitle());
if (iStat == 0)
{
iVers = 2;
}
iStat =sHeaderRow.compare(oCsvVers1.GetCsvFileTitle());
if (iStat == 0)
{
iVers = 1;
}
iStat = oPathCsvFil.fcloseFil(0);
assert(iStat == 0);
return iVers;
}
//=============================================================================
int sstQt01PathStoreViewCls::UpdateMainPathSizeFromEleTab (int iKey)
//-----------------------------------------------------------------------------
{
int iRet = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
// update number records per path in main table
sstQt01PathMainRecCls oPathRec1;
sstQt01PathMainRecCls oPathRec2;
dREC04RECNUMTYP dNumRecs = 0;
// Update last record in main table
oPathRec2.setNumElements(dNumRecs);
assert (iStat >= 0);
// Fatal Errors goes to an assert
assert(iRet >= 0);
// Small Errors will given back
iRet = iStat;
return iRet;
}
//=============================================================================
int sstQt01PathStoreViewCls::NewMainWithElement (int iKey, sstQt01PathElementCsv3Cls *oShapeItemCsv3)
//-----------------------------------------------------------------------------
{
int iRet = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
if (oShapeItemCsv3->getIType() == 0 && oShapeItemCsv3->isShapeType())
{ // new path, create path item record and store in path main table
QColor oQCol = oShapeItemCsv3->getQCol();
QPen oPen;
oPen.setWidth(oShapeItemCsv3->getIPenWidth());
Qt::PenStyle oStyle;
oStyle = (Qt::PenStyle) oShapeItemCsv3->getIPenStyle();
oPen.setStyle(oStyle);
sstQt01PathMainRecCls oPathMainRec;
oPathMainRec.setQCol(oQCol);
oPathMainRec.setQPen(oPen);
oPathMainRec.setStartElementRecNo(this->dActualReadPos);
oPathMainRec.setShapeType(oShapeItemCsv3->getShapeType());
// Generate tooltip (Type and row number) from csv file information
std::string oTooltipStr;
oTooltipStr += oShapeItemCsv3->getSType().toStdString();
sstStr01Cls oStrCnvt;
oStrCnvt.Csv_UInt4_2String(0,this->dActualReadPos,&oTooltipStr);
oPathMainRec.setTooltip(oTooltipStr);
}
// Fatal Errors goes to an assert
assert(iRet >= 0);
// Small Errors will given back
iRet = iStat;
return iRet;
}
//=============================================================================
sstQt01ShapeType_enum sstQt01PathStoreViewCls::getShapeType(int index)
{
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
return oShapeItem.getShapeType();
}
//=============================================================================
dREC04RECNUMTYP sstQt01PathStoreViewCls::getExternId(dREC04RECNUMTYP index)
{
sstQt01ShapeItem oShapeItem;
oShapeItem = this->shapeItems.at( index-1);
int iStat = 0;
assert(iStat >= 0);
return oShapeItem.getExternId();
}
//=============================================================================
int sstQt01PathStoreViewCls::replaceShapeItem(int iKey, dREC04RECNUMTYP index, sstQt01ShapeItem oItem)
{
int iRet = 0;
int iStat = 0;
//-----------------------------------------------------------------------------
if ( iKey != 0) return -1;
this->shapeItems.replace(index-1,oItem);
// Fatal Errors goes to an assert
if (iRet < 0)
{
// Expression (iRet >= 0) has to be fullfilled
assert(0);
}
// Small Errors will given back
iRet = iStat;
return iRet;
}
//=============================================================================