IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Qt Discussion :

"Debug Assertion Failed"


Sujet :

Qt

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2017
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2017
    Messages : 37
    Points : 29
    Points
    29
    Par défaut "Debug Assertion Failed"
    Bonjour,

    J'ai un petit soucis avec mon projet Qt, quand je le debug il marche mais quand je l'installe sur un autre PC (avec un setup) j'ai cette erreur:
    Nom : erreurassertion.png
Affichages : 924
Taille : 15,2 Ko
    Je ne comprend pas j'ai essayé avec un petit projet simple tout marche mais pas avec mon projet.

  2. #2
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2010
    Messages
    248
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Suisse

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Mai 2010
    Messages : 248
    Points : 421
    Points
    421
    Par défaut
    Bonjour,

    Visiblement il y a un problème de corruption mémoire lors de l'exécution. Peut-on voir le code ?

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2017
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2017
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Quelle partie du code?
    Nom : solution.PNG
Affichages : 762
Taille : 19,5 Ko
    Le test.cpp est là où on le plus de code donc:
    testcv.h
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    #ifndef TESTCV_H
    #define TESTCV_H
     
    #include <QtWidgets/QMainWindow>
    #include "ui_testcv.h"
     
    #include <opencv2/opencv.hpp>
     
    //#include "Resizable_rubber_band.h"
     
    #include "cosDialog.h"
     
     
    using namespace cv;
     
    class testCV : public QMainWindow
    {
    	Q_OBJECT
     
    public:
    	testCV(QWidget *parent = 0);
    	bool eventFilter(QObject *obj, QEvent *event);
    	~testCV();
     
    	void checkBoundary();
    	void showImage();
     
    private:
    	Ui::testCVClass ui;
    	QString pathfoder;
    	Mat image;
    	Mat img ;
    	int xp, x,x2;
    	int y,y2;
    	Mat /*src,*/imgcrop,ROI;
    	Rect cropRect;
    	Point P1;
    	Point P2;
    	QPoint porigine;
    	bool clicked,clicked2;
    	bool traitement;
    	QGraphicsScene scene_original, scene_selection;
    	QGraphicsPixmapItem* item;
    	QGraphicsPixmapItem* itemselection;
    	QGraphicsRectItem* rect;
     
     
    	QMap<QTreeWidgetItem*, QGraphicsRectItem*> map;
    	QMap<QGraphicsRectItem*, QTreeWidgetItem*> mapinverse;
     
     
    	//QRubberBand* rubberBand;
    	Resizable_rubber_band* rubberBand;
    	QRect rct;
    	bool released;
     
    	bool move_rubberband;
        QPoint rubberband_offset;
     
    	QList<int> indexitemsfree;
    	QMap<QTreeWidgetItem*, int> mapindex;
     
    	bool modificationItem;
    	QGraphicsRectItem *itemEnModification;
     
     
    public slots:
    	void addRect ();
    	void deleteRect ();
    	void selectItem (QTreeWidgetItem * treeitem);
     
    	void editItem (QTreeWidgetItem * treeitem,  int column);
     
    	void changedselection ();
     
    	void rup ();
    	void rdown ();
    	void rleft ();
    	void rright (); 
     
    	void rrup ();
    	void rrdown ();
    	void rrleft ();
    	void rrright ();
     
    	void fullScreen ();
     
    	void dragmode ();
     
    	void zoomIn ();
    	void zoomOut ();
     
    	void deleteRectTree (QTreeWidgetItem * treeitem,  int column);
     
    	void renameRectTree (QTreeWidgetItem * treeitem,  int column);
     
    	void precedent ();
    	void suivant ();
     
    signals:
    	void pressLabel();
     
    };
     
    #endif // TESTCV_H
    testcv.cpp
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    #include "testcv.h"
    //#include <opencv2/core/core.hpp>
    //#include <opencv2/highgui/highgui.hpp>
    #include <QMessageBox>
    #include <QGraphicsPixmapItem>
    #include <opencv2/opencv.hpp>
    #include  <QMouseEvent>
    #include <QRubberBand>
    #include <QHBoxLayout>
    #include <QSizeGrip>
    #include <QTreeWidgetItem>
    #include <QLabel>
    #include <QLineEdit>
    #include <QDir>
     
     
     
     
    using namespace cv;
     
    static const double scaleFactor = 1.15;
    static double currentScale = 1.0;  // stores the current scale value.
    static const double scaleMin = 1.0; // defines the min scale limit.
     
    testCV::testCV(QWidget *parent)
    	: QMainWindow(parent)
    {
    	ui.setupUi(this);
     
    	QDir dir;
    	pathfoder = dir.currentPath();
     
    	QIcon ajouterIcon(pathfoder+"/ajouter.png");
    	QIcon deleteIcon(pathfoder+"/supprimer.png");
    	QIcon renameIcon (pathfoder+"/renommer.png");
    	QIcon handIcon(pathfoder+"/mnt.png");
    	QIcon ziIcon(pathfoder+"/zi.png");
    	QIcon zoIcon (pathfoder+"/zo.png");
    	QIcon peIcon (pathfoder+"/pe.png");
     
    	ui.pb_add->setIcon(ajouterIcon);
    	ui.pb_delete->setIcon(deleteIcon);
    	ui.pb_drag->setIcon(handIcon);
    	ui.pb_zoomIn->setIcon(ziIcon);
    	ui.pb_zoomOut->setIcon(zoIcon);
    	ui.pb_fullScreen->setIcon(peIcon);
     
     
     
    	ui.pb_drag->setCheckable(true);
     
    	// buttons in ToolBar
    	//ui.mainToolBar->addWidget(ui.pb_user);
    	//ui.mainToolBar->addSeparator();
    	ui.mainToolBar->addWidget(ui.pb_add);
    	ui.mainToolBar->addWidget(ui.pb_delete);
    	ui.mainToolBar->addSeparator();
    	ui.mainToolBar->addWidget(ui.pb_drag);
    	ui.mainToolBar->addWidget(ui.pb_zoomIn);
    	ui.mainToolBar->addWidget(ui.pb_zoomOut);
    	ui.mainToolBar->addSeparator();
    	ui.mainToolBar->addWidget(ui.pb_fullScreen);
     
    	//ui.graphicsView_selection->setScene(&scene_selection);
    	//ui.graphicsView_selection->setAlignment(Qt::AlignTop|Qt::AlignLeft);
    	//ui.graphicsView_selection->setAlignment(Qt::AlignTop|Qt::AlignLeft);
     
    	connect(&scene_original, SIGNAL(selectionChanged()), this, SLOT(changedselection()));
     
     
    	// cacher bouttons rubban
    	ui.pb_bas->hide();
    	ui.pb_haut->hide();
    	ui.pb_droite->hide();
    	ui.pb_gauche->hide();
    	ui.pb_bas_haut->hide();
    	ui.pb_haut_bas->hide();
    	ui.pb_droite_gauche->hide();
    	ui.pb_gauche_droite->hide();
    	ui.line0->hide();
    	ui.line1->hide();
    	ui.line2->hide();
    	ui.line3->hide();
    	ui.line4->hide();
    	ui.line5->hide();
    	ui.line6->hide();
    	ui.line7->hide();
    	ui.line8->hide();
    	ui.line9->hide();
    	ui.line10->hide();
    	ui.line11->hide();
     
    	clicked=false;
    	clicked2=false;
     
    	released = false;
     
    	xp =1;
     
    	cropRect.x = 0;
    	cropRect.y = 0;
    	cropRect.height = 0;
    	cropRect.width = 0;
    	P1.x = 0;
    	P1.y = 0;
    	P2.x = 0;
    	P2.y = 0;
     
    	move_rubberband = false;
     
    	modificationItem = false;
    	QString nomimage = "/cap2.bmp";
    	img  = imread(pathfoder.toStdString()+ nomimage.toStdString());
    	//img  = imread("C:\\Users\\nadhir.abdellatif\\Desktop\\cap2.bmp");
    	if(! img .data ) // Check for invalid input
    	{
    		// Message d'erreur
    		QMessageBox msgBox;
    		msgBox.setText("Could not open or find the image! "+ pathfoder +"/cap2.bmp");
    		msgBox.exec();
    	}
     
    	image = img.clone();
     
    	cvtColor(img, img, CV_BGR2RGB);
    	item = new QGraphicsPixmapItem(QPixmap::fromImage(QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)));
     
    	// rendre item selectionable
    	//item->setFlag(QGraphicsItem::ItemIsSelectable);
     
    	scene_original.addItem(item);
     
    	//QRectF toutou = scene_original.itemsBoundingRect();
    	//scene_original.setSceneRect(toutou);
     
     
    	ui.graphicsView_original->setScene(&scene_original);
     
    	//ui.graphicsView_original->setMinimumWidth(scene_original.width());
     
    	//ui.graphicsView_original->scale(scene_original.width(), scene_original.height()); //
    	//ui.graphicsView_original->scale(ui.graphicsView_original->frameSize().width() / scene_original.width(), ui.graphicsView_original->frameSize().height() / scene_original.height());
    	//ui.graphicsView_original->fitInView(scene_original.itemsBoundingRect() ,Qt::KeepAspectRatio); //  ->sceneRect()
    	//ui.graphicsView_original->resize(scene_original.width(), scene_original.height());
     
    	// taille 0 de scene resultat
    	//ui.graphicsView_selection->resize(cropRect.width, cropRect.height);
     
    	//--------------------------------------------------------------------------------------------------------------------------------------------
     
    	//ui.graphicsView_original->setDragMode(QGraphicsView::RubberBandDrag);
     
    	//// RubberBand
    	//		QRubberBand* rubberBand = new QRubberBand(QRubberBand::Rectangle, ui.graphicsView_original);
    	//		rubberBand->resize(500, 500);
    	//		rubberBand->show();
    	//		//scene_original.addItem(rubberBand);
     
    	//		QRectF rct = scene_original.selectionArea().boundingRect();
     
    	//ui.label->setPixmap(QPixmap::fromImage(QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)));
    	//---------------------------------------------------------------------------------------------------------------------------------------------
     
    	// détection de lignes. (edge detection first)
    	Mat dst, cdst;
    	/// Apply Canny edge detector
    	Canny(img, dst, 50, 200, 3);
    	/// Pass the image to gray
    	cvtColor(dst, cdst, CV_GRAY2BGR);
     
    #if 0
    	vector<Vec2f> lines;
    	/// Use Standard Hough Transform
    	HoughLines(dst, lines, 1, CV_PI/180, 100, 0, 0 );
    	/// Show the result
    	for( size_t i = 0; i < lines.size(); i++ )
    	{
    		float rho = lines[i][0], theta = lines[i][1];
    		Point pt1, pt2;
    		double a = cos(theta), b = sin(theta);
    		double x0 = a*rho, y0 = b*rho;
    		pt1.x = cvRound(x0 + 1000*(-b));
    		pt1.y = cvRound(y0 + 1000*(a));
    		pt2.x = cvRound(x0 - 1000*(-b));
    		pt2.y = cvRound(y0 - 1000*(a));
    		line( cdst, pt1, pt2, Scalar(0,0,255), 3, CV_AA);
    	}
    #else
    	vector<Vec4i> lines;
    	/// Use Probabilistic Hough Transform
    	HoughLinesP(dst, lines, 1, CV_PI/180, 50, 50, 10 );
    	/// Show the result
    	for( size_t i = 0; i < lines.size(); i++ )
    	{
    		Vec4i l = lines[i];
    		line( cdst, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
    	}
    #endif
     
     
    	/*cvtColor(cdst, cdst, CV_BGR2RGB);
     
    	ui.label_r->setPixmap(QPixmap::fromImage(QImage(cdst.data, cdst.cols, cdst.rows, cdst.step, QImage::Format_RGB888)));
     
     
    	connect(ui.spinBox, SIGNAL(valueChanged(int)), this, SLOT(updatelabel(int)));*/
     
     
    	// eventFilter to View
    	ui.graphicsView_original->installEventFilter(this);
    	//ui.graphicsView_original->setMouseTracking(true);
    	//ui.graphicsView_original->setHandlesChildEvents(true);
    	//ui.graphicsView_original->scene()->installSceneEventFilter(this);
    	//scene_original.installEventFilter(this);
    	//ui.graphicsView_original->scene()->setMouseTracking(true);
    	//connect(this, SIGNAL(pressLabel()), this, SLOT(position()));
     
    	//connect(ui.graphicsView_original, SIGNAL(mouseReleaseEvent(QMouseEvent *)), this, SLOT(position()));
     
    	//connect(ui.pb_add, SIGNAL(clicked()), this, SLOT(addRect()));
     
    		connect(ui.pb_add, &QPushButton::clicked, [=] {emit addRect();});
     
    	// Connect tree and selections
    	connect(ui.treeWidget,SIGNAL(itemClicked(QTreeWidgetItem *,int)),this,SLOT(selectItem (QTreeWidgetItem *)));
    	//connect(scene_original,SIGNAL(focusItemChanged(QGraphicsItem *, QGraphicsItem *, Qt::FocusReason)),this,SLOT(selectItem (QTreeWidgetItem *))); // Beug
     
    	// delete rectangle
    	connect(ui.pb_delete, SIGNAL(clicked()), this, SLOT(deleteRect()));
     
     
    	//recadrer Rubban
    	connect(ui.pb_haut, SIGNAL(clicked()), this, SLOT(rup()));
    	connect(ui.pb_bas, SIGNAL(clicked()), this, SLOT(rdown()));
    	connect(ui.pb_gauche, SIGNAL(clicked()), this, SLOT(rleft()));
    	connect(ui.pb_droite, SIGNAL(clicked()), this, SLOT(rright()));
    	connect(ui.pb_haut_bas, SIGNAL(clicked()), this, SLOT(rrup()));
    	connect(ui.pb_bas_haut, SIGNAL(clicked()), this, SLOT(rrdown()));
    	connect(ui.pb_gauche_droite, SIGNAL(clicked()), this, SLOT(rrleft()));
    	connect(ui.pb_droite_gauche, SIGNAL(clicked()), this, SLOT(rrright()));
     
     
    	// view full screen
    	connect(ui.pb_fullScreen, SIGNAL(clicked()), this, SLOT(fullScreen()));
     
    	// drag mode
    	connect(ui.pb_drag, SIGNAL(clicked()), this, SLOT(dragmode()));
     
    	// Zoom in
    	connect(ui.pb_zoomIn, SIGNAL(clicked()), this, SLOT(zoomIn()));
     
    	// Zoom out
    	connect(ui.pb_zoomOut, SIGNAL(clicked()), this, SLOT(zoomOut()));
     
     
    	connect(ui.pb_precedent, SIGNAL(clicked()), this, SLOT(precedent()));
    	connect(ui.pb_suivant, SIGNAL(clicked()), this, SLOT(suivant()));
     
     
    	// Edit treeItem
    	//connect(ui.treeWidget,SIGNAL(itemClicked(QTreeWidgetItem *,int)),this,SLOT(editItem (QTreeWidgetItem *,int)));
     
    	//logo
    	QPixmap image(pathfoder+"/process.png");
    	ui.label_process->setPixmap(image);
    	ui.label_process->setAlignment(Qt::AlignHCenter);
     
     
    }
     
     
    bool testCV::eventFilter(QObject *obj, QEvent *event)
    {
     
    	traitement = false;
     
     
    	if(obj == ui.graphicsView_original && event->type() == QMouseEvent::MouseButtonPress/*QMouseEvent::MouseButtonPress*/) //QGraphicsSceneMouseEvent 
    	{
     
     
    		released = false;
     
     
    		//---------------------------------------------------------------------------------------------------------------------------
    		QMouseEvent *me = (QMouseEvent *)event;
    		porigine = me->pos();
     
    		if (ui.graphicsView_original->scene()->sceneRect().contains(ui.graphicsView_original->mapToScene(porigine)))
    		{
    			//QPointF poriginescene = ui.graphicsView_original->mapToScene(porigine);
    			//porigine.setX(poriginescene.x());
    			//porigine.setY(poriginescene.y());
     
     
     
    			if(!rct.isNull() && rubberBand->geometry().contains(porigine))
    			{
    				rubberband_offset = me->pos() - rubberBand->pos();
    				move_rubberband = true;
    			}
    			else
    			{
    				if(!rct.isNull() && rubberBand->isVisible())
    				{
     
    					if(modificationItem)
    					{
    						QMessageBox msgBox;
    						msgBox.setWindowTitle("Edition");
    						msgBox.setText("\n\nVoulez-vous annuler la modification?\n\n");
     
     
    						QPushButton * okButton = msgBox.addButton(tr("Oui"), QMessageBox::ActionRole);
    						QPushButton * nonButton = msgBox.addButton(tr("Non"), QMessageBox::ActionRole);	
    						msgBox.exec();
     
    						if (msgBox.clickedButton()==okButton)
    						{
    							rubberBand->hide();
     
    							// cacher bouttons rubban
    							ui.pb_bas->hide();
    							ui.pb_haut->hide();
    							ui.pb_droite->hide();
    							ui.pb_gauche->hide();
    							ui.pb_bas_haut->hide();
    							ui.pb_haut_bas->hide();
    							ui.pb_droite_gauche->hide();
    							ui.pb_gauche_droite->hide();
    							ui.line0->hide();
    							ui.line1->hide();
    							ui.line2->hide();
    							ui.line3->hide();
    							ui.line4->hide();
    							ui.line5->hide();
    							ui.line6->hide();
    							ui.line7->hide();
    							ui.line8->hide();
    							ui.line9->hide();
    							ui.line10->hide();
    							ui.line11->hide();
     
    							modificationItem = false;
    							ui.pb_add->setText("Add");
    							itemEnModification->setPen(QPen(Qt::green));
    						}
    						else
    						{
    							msgBox.close();
    							return QObject::eventFilter(obj, event);
     
    						}
    					}
    					else
    					{
    						rubberBand->hide();
    					}
    				}
     
     
     
    				//rubberBand = new QRubberBand(QRubberBand::Rectangle, ui.graphicsView_original);
    				rubberBand = new Resizable_rubber_band(ui.graphicsView_original);
     
     
    				rubberBand->setGeometry(QRect(porigine, QSize()));
     
     
    				rubberBand->show();
    			}
    			traitement = true;
    			ui.graphicsView_original->grabMouse();
     
    			//---------------------------------------------------------------------------------------------------------------------------
     
    		}
    	}
     
     
     
    	if(obj == ui.graphicsView_original && event->type() == QMouseEvent::MouseMove && !released)
    	{
     
    		QMouseEvent *me = (QMouseEvent *)event;
     
    		if (ui.graphicsView_original->scene()->sceneRect().contains(ui.graphicsView_original->mapToScene(me->pos())))
    		{
    			//QPointF poriginescene = ui.graphicsView_original->mapToScene(me->pos());
    			//QPoint pp;
    			//pp.setX(poriginescene.x());
    			//pp.setY(poriginescene.y());
     
    			if(move_rubberband)
    			{
    				rubberBand->move(me->pos() - rubberband_offset);
    			}
    			else
     
    			{
    				rubberBand->setGeometry(QRect(porigine, me->pos()).normalized());
    				//rubberBand->resize(size());
    			}
    		}
    	}
     
     
    	if(obj == ui.graphicsView_original && event->type() == QMouseEvent::MouseButtonRelease)
    	{
     
    		released = true;
     
    		QMouseEvent *me = (QMouseEvent *)event;
     
     
    		ui.graphicsView_original->releaseMouse();
     
    		//ui.graphicsView_original->setDragMode(QGraphicsView::RubberBandDrag);
     
     
    		// montrer bouttons rubban
     
    		rct = rubberBand->geometry();
     
    		if(!(rct.isNull()))
    		{
    			ui.pb_bas->show();
    			ui.pb_haut->show();
    			ui.pb_droite->show();
    			ui.pb_gauche->show();
    			ui.pb_bas_haut->show();
    			ui.pb_haut_bas->show();
    			ui.pb_droite_gauche->show();
    			ui.pb_gauche_droite->show();
    			ui.line0->show();
    			ui.line1->show();
    			ui.line2->show();
    			ui.line3->show();
    			ui.line4->show();
    			ui.line5->show();
    			ui.line6->show();
    			ui.line7->show();
    			ui.line8->show();
    			ui.line9->show();
    			ui.line10->show();
    			ui.line11->show();
    		}
    		else
    		{
    			// cacher bouttons rubban
    			ui.pb_bas->hide();
    			ui.pb_haut->hide();
    			ui.pb_droite->hide();
    			ui.pb_gauche->hide();
    			ui.pb_bas_haut->hide();
    			ui.pb_haut_bas->hide();
    			ui.pb_droite_gauche->hide();
    			ui.pb_gauche_droite->hide();
    			ui.line0->hide();
    			ui.line1->hide();
    			ui.line2->hide();
    			ui.line3->hide();
    			ui.line4->hide();
    			ui.line5->hide();
    			ui.line6->hide();
    			ui.line7->hide();
    			ui.line8->hide();
    			ui.line9->hide();
    			ui.line10->hide();
    			ui.line11->hide();
    		}
     
    		move_rubberband = false;
     
    	}
     
     
    	// Zoom
    	if(obj == ui.graphicsView_original && event->type() == QWheelEvent::Wheel) // QEvent::GraphicsSceneWheel
    	{
     
    		QWheelEvent *me = (QWheelEvent *)event;
    		if(me->modifiers() & Qt::ControlModifier)
    		{
    			ui.graphicsView_original->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    			// Scale the view / do the zoom
    			//double scaleFactor = 1.15;
    			//
     
    			if(!rct.isNull() && rubberBand->isVisible())
    			{
    				rubberBand->hide();
     
    				// cacher bouttons rubban
    				ui.pb_bas->hide();
    				ui.pb_haut->hide();
    				ui.pb_droite->hide();
    				ui.pb_gauche->hide();
    				ui.pb_bas_haut->hide();
    				ui.pb_haut_bas->hide();
    				ui.pb_droite_gauche->hide();
    				ui.pb_gauche_droite->hide();
    				ui.line0->hide();
    				ui.line1->hide();
    				ui.line2->hide();
    				ui.line3->hide();
    				ui.line4->hide();
    				ui.line5->hide();
    				ui.line6->hide();
    				ui.line7->hide();
    				ui.line8->hide();
    				ui.line9->hide();
    				ui.line10->hide();
    				ui.line11->hide();
    			}
     
    			if(me->delta() > 0) {
    				// Zoom in
    				ui.graphicsView_original->scale(scaleFactor, scaleFactor);
    				currentScale *= scaleFactor;
     
    			} else if (currentScale > scaleMin) {
    				// Zooming out
    				ui.graphicsView_original->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    				currentScale /= scaleFactor;
    			}
    		}
     
     
    	}
     
     
    	//// Pointing hand
    	//if(obj == ui.graphicsView_original && event->type() == QMouseEvent::MouseButtonPress) // QEvent::GraphicsSceneWheel
    	//       {
    	//		QMouseEvent *me = (QMouseEvent *)event;
    	//		if(me->modifiers() & Qt::ControlModifier)
    	//		{
    	//			ui.graphicsView_original->setDragMode(QGraphicsView::ScrollHandDrag);
    	//		}
     
    	//}
     
    	//if(obj == ui.graphicsView_original && event->type() == QMouseEvent::MouseButtonRelease) // QEvent::GraphicsSceneWheel
    	//       {
    	//		QMouseEvent *me = (QMouseEvent *)event;
    	//		if(!(me->modifiers() & Qt::ControlModifier))
    	//		{
    	//			ui.graphicsView_original->setDragMode(QGraphicsView::NoDrag);
    	//		}
     
    	//}
     
     
     
     
     
    	if(traitement){
     
    		emit pressLabel();
    		return true;
    	}
     
    	return QObject::eventFilter(obj, event);
    }
     
     
    void testCV::checkBoundary(){
    	//check croping rectangle exceed image boundary
    	if(cropRect.width>imgcrop.cols-cropRect.x)
    		cropRect.width=imgcrop.cols-cropRect.x;
     
    	if(cropRect.height>imgcrop.rows-cropRect.y)
    		cropRect.height=imgcrop.rows-cropRect.y;
     
    	if(cropRect.x<0)
    		cropRect.x=0;
     
    	if(cropRect.y<0)
    		cropRect.height=0;
    }
     
    void testCV::showImage(){
    	imgcrop=image.clone();
    	checkBoundary();
    	if(cropRect.width>0&&cropRect.height>0){
    		ROI=imgcrop(cropRect);
    		//imshow("cropped",ROI);
    		/*cvtColor(ROI, ROI, CV_BGR2RGB);
    		ui.label_selection->setPixmap(QPixmap::fromImage(QImage(ROI.data, ROI.cols, ROI.rows, ROI.step, QImage::Format_RGB888)));*/
     
    		scene_selection.clear();
     
    		cvtColor(ROI, ROI, CV_BGR2RGB);
    		itemselection = new QGraphicsPixmapItem(QPixmap::fromImage(QImage(ROI.data, ROI.cols, ROI.rows, ROI.step, QImage::Format_RGB888)));
    		scene_selection.addItem(itemselection);
    		//ui.graphicsView_selection->resize(cropRect.width, cropRect.height);
    	}
     
    	//   rectangle(img, cropRect, Scalar(0,255,0), 1, 8, 0 );
    	//   //imshow("Crop Image",img);
    	//cvtColor(img, img, CV_BGR2RGB);
    	//ui.label_selection->setPixmap(QPixmap::fromImage(QImage(img.data, img.cols, img.rows, img.step, QImage::Format_RGB888)));
    }
     
     
     
    void testCV::addRect()
    {
     
     
     
     
    	if(!rct.isNull())
    	{
     
    		rct = rubberBand->geometry();
     
    		//conversion view ->scene
     
    		QPointF topLeftf = ui.graphicsView_original->mapToScene(rct.topLeft());
    		QPointF bottomRightf = ui.graphicsView_original->mapToScene(rct.bottomRight());
    		QPoint topLeft, bottomRight;
    		topLeft.setX(topLeftf.x());
    		topLeft.setY(topLeftf.y());
    		bottomRight.setX(bottomRightf.x());
    		bottomRight.setY(bottomRightf.y());
     
    		QRect rr(topLeft, bottomRight);
     
     
    		// vérifier que le rubban est dans la scene
    		if (ui.graphicsView_original->scene()->sceneRect().contains(rr)) 
    		{
     
    			if (modificationItem)
    			{
    				// Supprimer item de la scene
    				scene_original.removeItem(itemEnModification);
    				// enlever du tree
    				QTreeWidgetItem* itemTreeToDelete = mapinverse.value(itemEnModification);
    				//QTreeWidgetItem * itemChild = itemTreeToDelete->child(0);
    				//itemTreeToDelete->removeChild(itemChild);
    				int childNumber = itemTreeToDelete->childCount();
    				for(int i=childNumber; i>=0; i--)
    				{
    					itemTreeToDelete->removeChild(itemTreeToDelete->child(i));
    				}
    			}
     
    			// vérifier que le rubban ne rentre pas dans un item
    			QGraphicsRectItem rubban_rectangle_inScene;
    			rubban_rectangle_inScene.setRect(rr);
    			QList<QGraphicsItem *> listeCollidingItems = scene_original.collidingItems(&rubban_rectangle_inScene);
    			if(listeCollidingItems.size() == 1)
    			{
     
     
     
    				//dessiner rectangle.			
    				rect = scene_original.addRect(rr);
    				// Couleur de selection
    				rect->setPen(QPen(Qt::green));
     
     
    				rect->setFlag(QGraphicsItem::ItemIsSelectable, true);
    				//rect->setFlag(QGraphicsItem::ItemIsMovable, true);
    				if(rubberBand->isVisible())
    				{
    					rubberBand->hide();
     
    					// cacher bouttons rubban
    					ui.pb_bas->hide();
    					ui.pb_haut->hide();
    					ui.pb_droite->hide();
    					ui.pb_gauche->hide();
    					ui.pb_bas_haut->hide();
    					ui.pb_haut_bas->hide();
    					ui.pb_droite_gauche->hide();
    					ui.pb_gauche_droite->hide();
    					ui.line0->hide();
    					ui.line1->hide();
    					ui.line2->hide();
    					ui.line3->hide();
    					ui.line4->hide();
    					ui.line5->hide();
    					ui.line6->hide();
    					ui.line7->hide();
    					ui.line8->hide();
    					ui.line9->hide();
    					ui.line10->hide();
    					ui.line11->hide();
    				}
     
     
    				QTreeWidgetItem* rectangle;
    				if (modificationItem)
    				{
    					QTreeWidgetItem* itemTreeToDelete = mapinverse.value(itemEnModification);
    					rectangle = itemTreeToDelete;
    					modificationItem = false;
    					ui.pb_add->setText("Add");
    				}
    				else
    				{
    				// Ajouter dans le treeWidget
    				rectangle = new QTreeWidgetItem(ui.treeWidget);
     
    				//int index = ui.treeWidget->indexOfTopLevelItem(rectangle);
    				int index = ui.treeWidget->topLevelItemCount();
    				//rectangle->setText(0, tr("Connecteur " + index));
     
    				// si on supprime tout
    				if(index == 1)
    				{
    					indexitemsfree.clear();
    				}
     
    				if(indexitemsfree.isEmpty())
    				{
    					rectangle->setText(0, ("Connecteur " + QString::number(index)));
    					mapindex.insert(rectangle, index);
    				}
    				else
    				{
    					qSort(indexitemsfree);
    					int indexfree = indexitemsfree.first();
    					rectangle->setText(0, ("Connecteur " + QString::number(indexfree)));
    					indexitemsfree.removeFirst();
    					mapindex.insert(rectangle, indexfree);
    				}
     
     
    				ui.treeWidget->insertTopLevelItem(0, rectangle);
    				}
     
    				// Ajouter image dans tree
    				//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    				imgcrop=image.clone();
    				checkBoundary();
     
    				Rect monRect;
    				rr.getRect(&monRect.x, &monRect.y, &monRect.width, &monRect.height);
    				//monRect.x = 0;
    				//monRect.y = 0;
    				//monRect.width = 0;
    				//monRect.height = 0;
     
    				if(monRect.width>0&&monRect.height>0){
    					ROI=imgcrop(monRect);
    					/*cvtColor(ROI, ROI, CV_BGR2RGB);
    					ui.label_selection->setPixmap(QPixmap::fromImage(QImage(ROI.data, ROI.cols, ROI.rows, ROI.step, QImage::Format_RGB888)));*/
     
    					scene_selection.clear();
    					cvtColor(ROI, ROI, CV_BGR2RGB);
    					itemselection = new QGraphicsPixmapItem(QPixmap::fromImage(QImage(ROI.data, ROI.cols, ROI.rows, ROI.step, QImage::Format_RGB888)));
     
    					QLabel *label = new QLabel();
    					label->setPixmap(QPixmap::fromImage(QImage(ROI.data, ROI.cols, ROI.rows, ROI.step, QImage::Format_RGB888)));
    					QTreeWidgetItem *treeimage = new QTreeWidgetItem();
    					//treeimage->setFlags(Qt::NoItemFlags);
    					rectangle->addChild(treeimage);
    					ui.treeWidget->setItemWidget(treeimage, 0, label);
     
    					QTreeWidgetItem * item;
     
    					for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
    					{
    						item = ui.treeWidget->topLevelItem(i);
    						item->setExpanded(false);
    					}
     
    					rectangle->setExpanded(true);
     
    					//// Boutton de modificationn           
    					//QPushButton *topLevelButton = new QPushButton("...");
    					//ui.treeWidget->setItemWidget(rectangle, 1, topLevelButton);
    					////connect(topLevelButton, SIGNAL(clicked()), this, SLOT(zoomIn()));
    					//connect(topLevelButton, &QPushButton::clicked, [=] {emit editItem (rectangle,1);});
    					//rectangle->setIcon(1,QIcon("C:/Users/nadhir.abdellatif/Desktop/Code/3p.gif"));
     
    					QIcon editIcon(pathfoder+"/editer.png");
    					QIcon deleteIcon(pathfoder+"/supprimer.png");
    					QIcon renameIcon (pathfoder+"/renommer.png");
     
    					QPushButton *buttonEdit = new QPushButton(editIcon, "Editer");
    					buttonEdit->setToolTip("Editer la taille du connecteur");
    					QPushButton *buttonDelete = new QPushButton(deleteIcon, "Supprimer");
    					buttonDelete->setToolTip("Supprimer ce connecteur");
    					QPushButton *buttonRename = new QPushButton(renameIcon, "Renommer");
    					buttonRename->setToolTip("Renommer ce connecteur");
    					QLineEdit *lineEditOCR = new QLineEdit();
    					lineEditOCR->setToolTip("Reference");
     
    					if (xp==1)
    					lineEditOCR->setText("P21");
    					xp++;
     
    					buttonEdit->setIconSize(QSize(50,50));
    					buttonDelete->setIconSize(QSize(50,50));
    					buttonRename->setIconSize(QSize(50,50));
     
    					//	// Set style sheet.
    					//QFile file("C:/Users/nadhir.abdellatif/Desktop/mesProjets/OpenCV Projects/testCV/testCV/Resources/style-sheet.qss");
    					//file.open(QFile::ReadOnly);
    					//QString styleSheet = QLatin1String(file.readAll());
    					//
    					//buttonEdit->setStyleSheet(styleSheet);
    					//buttonDelete->setStyleSheet(styleSheet);
    					//buttonRename->setStyleSheet(styleSheet);
     
    					buttonEdit->setStyleSheet("Text-align:left");
    					buttonDelete->setStyleSheet("Text-align:left");
    					buttonRename->setStyleSheet("Text-align:left");
     
    					QLabel* buttonLabel = new QLabel("Reference:");
     
     
    					QTreeWidgetItem *childItemLineEdit = new QTreeWidgetItem();
    					QTreeWidgetItem *childItemEdit = new QTreeWidgetItem();
    					QTreeWidgetItem *childItemDelete = new QTreeWidgetItem();
    					QTreeWidgetItem *childItemRename = new QTreeWidgetItem();
    										QTreeWidgetItem *childItemLabel = new QTreeWidgetItem();
    										rectangle->addChild(childItemLabel);
    										rectangle->addChild(childItemLineEdit);
    					rectangle->addChild(childItemEdit);
    					rectangle->addChild(childItemRename);
    					rectangle->addChild(childItemDelete);
    					ui.treeWidget->setItemWidget(childItemLineEdit, 0, lineEditOCR);
    					ui.treeWidget->setItemWidget(childItemEdit, 0, buttonEdit);
    					ui.treeWidget->setItemWidget(childItemDelete, 0, buttonDelete);
     
    					ui.treeWidget->setItemWidget(childItemRename, 0, buttonRename);
    										ui.treeWidget->setItemWidget(childItemLabel, 0, buttonLabel);
    					connect(buttonEdit, &QPushButton::clicked, [=] {emit editItem (rectangle,0);});
    					connect(buttonDelete, &QPushButton::clicked, [=] {emit deleteRectTree (rectangle,0);});
    					connect(buttonRename, &QPushButton::clicked, [=] {emit renameRectTree (rectangle,0);});
    					rectangle->setFlags(rectangle->flags() | Qt::ItemIsEditable);
     
    					//int i;
    					//for i in reversed(range(parent.childCount())):
    					//      parent.removeChild(parent.child(i))
     
    					////QTreeWidget *treeWidget = new QTreeWidget; // cree u QtreeWidget
    					//QPushButton *button = new QPushButton("Button"); // cree un Widget Quelconque à ajouter dans l'abre, dans ce cas un bouton
    					//QPushButton *topLevelButton = new QPushButton("topLevelButton"); // // cree un autre Widget Quelconque à ajouter dans l'abre, dans ce cas un bouton
    					//QTreeWidgetItem *topLevelItem = new QTreeWidgetItem(); // cree un QtreeItem qui agit comme contenaire
    					//ui.treeWidget->addTopLevelItem(topLevelItem); // ajoute le contenaire dans l'abre
    					//QTreeWidgetItem *childItem = new QTreeWidgetItem(); // cree un autre contenaire
    					//topLevelItem->addChild(childItem); // ajoute un contenaire dans un autre contenaire 
    					//ui.treeWidget->setItemWidget(topLevelItem, 0, topLevelButton); //ajoute le widget dans le contenaire mere
    					//ui.treeWidget->setItemWidget(childItem, 0, button); // ajoute le second widget dans le contenaire fils
     
     
    					//scene_selection.addItem(itemselection);
    					//ui.graphicsView_selection->resize(monRect.width, monRect.height);
    				}
    				//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    				// Map
    				map.insert(rectangle, rect);
    				mapinverse.insert(rect, rectangle);
    				//rect = map.value(rectangle);
     
    				rect->setSelected(true);
     
     
    				rct.setRect(0, 0, 0, 0);
     
    				// tree item checkable
    				rectangle->setCheckState(0, Qt::Unchecked);
     
    			}
    			else
    			{
    				// Message d'erreur
    				QMessageBox msgBoxc;
    				msgBoxc.setWindowTitle("Ajout");
    				msgBoxc.setText("Collision entre les selections!");
    				msgBoxc.exec();
    			}
    		}
    		else
    		{
    			// Message d'erreur
    			QMessageBox msgBoxc;
    			msgBoxc.setWindowTitle("Ajout");
    			msgBoxc.setText("Out of boundaries!");
    			msgBoxc.exec();
    		}
    	}
     
     
    }
     
     
    void testCV::selectItem (QTreeWidgetItem * treeitem)
    {
    	if(map.contains(treeitem))
    	{
    		scene_original.clearSelection();
    		QGraphicsRectItem* recttoselect;
    		recttoselect = map.value(treeitem);
    		recttoselect->setSelected(true);
    	}
    	else
    	{
    		scene_original.clearSelection();
    		QGraphicsRectItem* recttoselect;
    		recttoselect = map.value(treeitem->parent());
    		recttoselect->setSelected(true);
    	}
    }
     
     
    void testCV::deleteRect()
    {
    	QList<QGraphicsItem *> listeitems = scene_original.selectedItems();
     
    	for (int i = 0; i < listeitems.size(); ++i) {
    		scene_original.removeItem(listeitems.at(i));
    		// enlever du tree
    		QTreeWidgetItem* treeitem = mapinverse.value((QGraphicsRectItem*)listeitems.at(i));
    		int x = ui.treeWidget->indexOfTopLevelItem(treeitem);
     
    		// ajouter l'index supprimé
     
    		int xx = mapindex.value(treeitem);
    		indexitemsfree.append(xx);
     
    		ui.treeWidget->takeTopLevelItem(x);
     
    		modificationItem = false;
    		ui.pb_add->setText("Add");
    	}
     
    }
     
     
    void testCV::changedselection()
    {
     
    	QList<QGraphicsItem *> listeitems = scene_original.selectedItems();
    	if(!(listeitems.size() == 0))
    	{
    		for (int i = 0; i < listeitems.size(); ++i) {
     
     
    			////changer de couleur de la selection
    			//QGraphicsRectItem* lerectangle = (QGraphicsRectItem*)listeitems.at(i);
    			//lerectangle->setPen(QPen(Qt::red));
    			// selectionner dans tree
    			QTreeWidgetItem* treeitem = mapinverse.value((QGraphicsRectItem*)listeitems.at(i));
    			ui.treeWidget->clearSelection();
    			treeitem->setSelected(true);
     
    			// cacher le reste et afficher l'item
    			QTreeWidgetItem* item;
    			for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
    			{
    				item = ui.treeWidget->topLevelItem(i);
    				item->setExpanded(false);
    			}
    			treeitem->setExpanded(true);
     
     
     
    		}
    	}
    	else
    	{
    		ui.treeWidget->clearSelection();
     
    		QTreeWidgetItem* item;
    		for (int i = 0; i < ui.treeWidget->topLevelItemCount(); i++)
    		{
    			item = ui.treeWidget->topLevelItem(i);
    			item->setExpanded(false);
    		}
    	}
     
     
     
    }
     
     
    void testCV::rup()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
     
    	QPoint topLeftf = rubberBand->pos();
     
    	if(!(rsize.isNull()))
    	{
    		topLeftf.setY(topLeftf.y()-pas);
    		rubberBand->move(topLeftf);
    		rubberBand->resize(rsize.width(),rsize.height()+pas);
    	}
    }
     
    void testCV::rdown()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
    	if(!(rsize.isNull()))
    	{
    		rubberBand->resize(rsize.width(),rsize.height()+pas);
    	}
    }
     
    void testCV::rleft()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
    	QPoint topLeftf = rubberBand->pos();
    	if(!(rsize.isNull()))
    	{
    		topLeftf.setX(topLeftf.x()-pas);
    		rubberBand->move(topLeftf);
    		rubberBand->resize(rsize.width()+pas,rsize.height());
    	}
     
    }
     
    void testCV::rright()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
    	if(!(rsize.isNull()))
    	{
    		rubberBand->resize(rsize.width()+pas,rsize.height());
    	}
    }
     
     
    void testCV::rrup()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
     
    	QPoint topLeftf = rubberBand->pos();
     
    	if(!(rsize.isNull()))
    	{
    		topLeftf.setY(topLeftf.y()+pas);
    		rubberBand->move(topLeftf);
    		rubberBand->resize(rsize.width(),rsize.height()-pas);
    	}
    }
     
    void testCV::rrdown()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
    	if(!(rsize.isNull()))
    	{
    		rubberBand->resize(rsize.width(),rsize.height()-pas);
    	}
    }
     
    void testCV::rrleft()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
    	QPoint topLeftf = rubberBand->pos();
    	if(!(rsize.isNull()))
    	{
    		topLeftf.setX(topLeftf.x()+pas);
    		rubberBand->move(topLeftf);
    		rubberBand->resize(rsize.width()-pas,rsize.height());
    	}
     
    }
     
    void testCV::rrright()
    {
     
    	int pas = 10;
    	QSize rsize = rubberBand->size();
    	if(!(rsize.isNull()))
    	{
    		rubberBand->resize(rsize.width()-pas,rsize.height());
    	}
    }
     
    void testCV::fullScreen()
    {	
    	QDialog *dlg = new QDialog(this);
    	QHBoxLayout *dlg_layout = new QHBoxLayout(dlg);
    	dlg_layout->setContentsMargins(0, 0, 0, 0);
    	QGraphicsView* viewFullScreen = new QGraphicsView(ui.graphicsView_original);
    	viewFullScreen->setScene(&scene_original);
    	dlg_layout->addWidget(viewFullScreen);
    	dlg->setLayout(dlg_layout);
    	dlg->showFullScreen();
    }
     
     
    void testCV::dragmode()
    {
     
    	if(ui.pb_drag->isChecked())
    	{
    		ui.graphicsView_original->setDragMode(QGraphicsView::ScrollHandDrag);
    	}
    	else
    	{
    		ui.graphicsView_original->setDragMode(QGraphicsView::NoDrag);
    	}
    }
     
     
    void testCV::zoomIn()
    {
    	// Zoom in
    	ui.graphicsView_original->scale(scaleFactor, scaleFactor);
    	currentScale *= scaleFactor;
    	if(!rct.isNull() && rubberBand->isVisible())
    	{
    		rubberBand->hide();
     
    		// cacher bouttons rubban
    		ui.pb_bas->hide();
    		ui.pb_haut->hide();
    		ui.pb_droite->hide();
    		ui.pb_gauche->hide();
    		ui.pb_bas_haut->hide();
    		ui.pb_haut_bas->hide();
    		ui.pb_droite_gauche->hide();
    		ui.pb_gauche_droite->hide();
    		ui.line0->hide();
    		ui.line1->hide();
    		ui.line2->hide();
    		ui.line3->hide();
    		ui.line4->hide();
    		ui.line5->hide();
    		ui.line6->hide();
    		ui.line7->hide();
    		ui.line8->hide();
    		ui.line9->hide();
    		ui.line10->hide();
    		ui.line11->hide();
    	}
    }
     
     
    void testCV::zoomOut()
    {
    	if (currentScale > scaleMin) {
    		// Zooming out
    		ui.graphicsView_original->scale(1.0 / scaleFactor, 1.0 / scaleFactor);
    		currentScale /= scaleFactor;
    	}
    	if(!rct.isNull() && rubberBand->isVisible())
    	{
    		rubberBand->hide();
     
    		// cacher bouttons rubban
    		ui.pb_bas->hide();
    		ui.pb_haut->hide();
    		ui.pb_droite->hide();
    		ui.pb_gauche->hide();
    		ui.pb_bas_haut->hide();
    		ui.pb_haut_bas->hide();
    		ui.pb_droite_gauche->hide();
    		ui.pb_gauche_droite->hide();
    		ui.line0->hide();
    		ui.line1->hide();
    		ui.line2->hide();
    		ui.line3->hide();
    		ui.line4->hide();
    		ui.line5->hide();
    		ui.line6->hide();
    		ui.line7->hide();
    		ui.line8->hide();
    		ui.line9->hide();
    		ui.line10->hide();
    		ui.line11->hide();
    	}
    }
     
     
    void testCV::editItem (QTreeWidgetItem * treeitem, int column)
    {
    	if (column == 0)
    	{
     
    		//QPushButton* bt = (QPushButton*)ui.treeWidget->itemWidget(treeitem, 1);
    		//if (bt->isDown())
    		//{
    		if(map.contains(treeitem))
    		{
    			scene_original.clearSelection();
    			QGraphicsRectItem* recttoselect;
    			recttoselect = map.value(treeitem);
     
    			if(!rct.isNull() && rubberBand->isVisible())
    			{
    				rubberBand->hide();
    			}
     
    			// Tracer Rubban
    			QRectF gr = recttoselect->rect();
    			rubberBand = new Resizable_rubber_band(ui.graphicsView_original);
     
    			QRect monRect = gr.toRect();		
     
     
    			//conversion view ->scene
     
    			QPointF topLeftf = ui.graphicsView_original->mapFromScene(monRect.topLeft());
    			QPointF bottomRightf = ui.graphicsView_original->mapFromScene(monRect.bottomRight());
    			QPoint topLeft, bottomRight;
    			topLeft.setX(topLeftf.x());
    			topLeft.setY(topLeftf.y());
    			bottomRight.setX(bottomRightf.x());
    			bottomRight.setY(bottomRightf.y());
     
    			QRect rr(topLeft, bottomRight);
     
    			rubberBand->setGeometry(rr);
    			rct = rubberBand->geometry();
     
    			rubberBand->show();
     
     
    			//Effacer ancien TODO
    			//scene_original.removeItem(recttoselect);
    			/*recttoselect->hide();*/
    			recttoselect->setPen(QPen(Qt::red));
    			// enlever du tree
    			//int x = ui.treeWidget->indexOfTopLevelItem(treeitem);
    			//QTreeWidgetItem * itemChild = treeitem->child(0);
    			//treeitem->removeChild(itemChild);
    			//ui.treeWidget->takeTopLevelItem(x);
    			QTreeWidgetItem* modificationItemTodo = mapinverse.value(itemEnModification);
    			if(modificationItem && (treeitem!=modificationItemTodo))
    			{
    			itemEnModification->setPen(QPen(Qt::green));
    			}
     
    			modificationItem = true;
    			ui.pb_add->setText("Edit");
     
     
    			ui.pb_bas->show();
    			ui.pb_haut->show();
    			ui.pb_droite->show();
    			ui.pb_gauche->show();
    			ui.pb_bas_haut->show();
    			ui.pb_haut_bas->show();
    			ui.pb_droite_gauche->show();
    			ui.pb_gauche_droite->show();
    			ui.line0->show();
    			ui.line1->show();
    			ui.line2->show();
    			ui.line3->show();
    			ui.line4->show();
    			ui.line5->show();
    			ui.line6->show();
    			ui.line7->show();
    			ui.line8->show();
    			ui.line9->show();
    			ui.line10->show();
    			ui.line11->show();
     
     
     
     
    			//Enregistrer item en modification
    			itemEnModification = recttoselect;
     
     
    		}
    		//}
    	}
    }
     
     
     
    void testCV::deleteRectTree (QTreeWidgetItem * treeitem,  int column)
    {
     
    		int x = ui.treeWidget->indexOfTopLevelItem(treeitem);
    		QGraphicsRectItem* itemToDelete = map.value(treeitem);
    		scene_original.removeItem(itemToDelete);
     
    		// ajouter l'index supprimé
     
    		int xx = mapindex.value(treeitem);
    		indexitemsfree.append(xx);
     
    		ui.treeWidget->takeTopLevelItem(x);
    		modificationItem = false;
    		ui.pb_add->setText("Add");
     
    }
     
     
    void testCV::renameRectTree (QTreeWidgetItem * treeitem,  int column)
    {
    		ui.treeWidget->editItem(treeitem,0);
    }
     
     
     
    void testCV::precedent ()
    {
    	hide();
     
    	cosDialog *cos = new cosDialog();
    	//	// Set style sheet.
    	//QFile file(pathfoder+"/style-sheet.qss");
    	//file.open(QFile::ReadOnly);
    	//QString styleSheet = QLatin1String(file.readAll());
    	//cos->setStyleSheet(styleSheet);
    	cos->show();	
     
    	//ChoixDeLapplichoixDeLappli_2;
     
    	//choixDeLappli_2.setModal(false);
     
    	//choixDeLappli_2.exec();
    }
     
    void testCV::suivant ()
    {
    	bool areChecked = true;
    	int treeItemNumber = ui.treeWidget->topLevelItemCount();
    	for(int i=0; i<treeItemNumber; i++)
    	{
    		int isChecked = ui.treeWidget->topLevelItem(i)->checkState(0);
    		if(isChecked == 0)
    		{
    			areChecked = false;
    		}
     
    	}
    	if(!areChecked)
    	{
    		// Message d'erreur
    		QMessageBox msgBoxc;
    		msgBoxc.setWindowTitle("Validation");
    		msgBoxc.setText("Valider tous les connecteurs!");
    		msgBoxc.exec();
    	}
    	else if (treeItemNumber == 0)
    	{
    		// Message d'erreur
    		QMessageBox msgBoxc;
    		msgBoxc.setWindowTitle("Creation");
    		msgBoxc.setText("Ajouter d'abord des connecteurs!");
    		msgBoxc.exec();
    	}
    	else
    	{
    		// Message d'erreur
    		QMessageBox msgBoxc;
    		msgBoxc.setWindowTitle("Suite");
    		msgBoxc.setText("En construction!");
    		msgBoxc.exec();
    	}
    }
     
     
     
    testCV::~testCV()
    {
     
    }

  4. #4
    Expert éminent
    Homme Profil pro
    Ingénieur développement matériel électronique
    Inscrit en
    Décembre 2015
    Messages
    1 564
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur développement matériel électronique
    Secteur : High Tech - Électronique et micro-électronique

    Informations forums :
    Inscription : Décembre 2015
    Messages : 1 564
    Points : 7 640
    Points
    7 640
    Par défaut
    Bonjour,

    Ce type d'erreur correspond souvent à un cas de corruption mémoire, comme le dépassement d'utilisation d'un tableau alloué dynamiquement. Il peut se comporter différemment sur 2 PC. Les versions debug et release n'ont pas le même comportement pour ces cas. Il faudrait utiliser des outils de trace des allocations (valgrind ... ) et déjà voir si le problème existe sur ton PC.

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2017
    Messages
    37
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2017
    Messages : 37
    Points : 29
    Points
    29
    Par défaut
    Pas le même comportement, tu veux dire qu'il peut ne pas marcher en debug et marcher en release?
    Malheureusement le problème n'existe pas sur mon PC. J'ai donc du mal à trouver et comprendre la source du problème..
    Comme tu as pu le voir dans le code, je ne pense pas avoir de dépassement!

Discussions similaires

  1. Debug Assertion Failed ! File: dbgheap.c
    Par jacques_henry dans le forum MFC
    Réponses: 9
    Dernier message: 15/04/2015, 11h29
  2. Debug Assertion Failed lors de l'éxécution
    Par Keweed dans le forum Ogre
    Réponses: 8
    Dernier message: 14/06/2008, 15h27
  3. debug assertion failed: dbgheap.c
    Par lolo le belge dans le forum Visual C++
    Réponses: 5
    Dernier message: 17/05/2007, 22h04
  4. debug assertion failed...
    Par BnY dans le forum MFC
    Réponses: 2
    Dernier message: 18/04/2006, 16h49
  5. Réponses: 3
    Dernier message: 07/12/2004, 22h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo