-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNavigator_Tool.cc
1870 lines (1667 loc) · 48.4 KB
/
Navigator_Tool.cc
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
/* Navigator_Tool
HiROC CVS ID: $Id: Navigator_Tool.cc,v 1.77 2012/06/15 01:16:07 castalia Exp $
Copyright (C) 2009-2011 Arizona Board of Regents on behalf of the
Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
the University of Arizona.
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License, version 2.1,
as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*******************************************************************************/
#include "Navigator_Tool.hh"
#include "HiView_Config.hh"
#include "Drawn_Line.hh"
#include "Icon_Button.hh"
#include "HiView_Utilities.hh"
#include <QWidget>
#include <QColor>
#include <QSplitter>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QFrame>
#include <QLabel>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QPushButton>
#include <QComboBox>
#include <QPalette>
#include <QRubberBand>
#include <QMouseEvent>
#include <QPixmap>
#include <QResizeEvent>
#if defined (DEBUG_SECTION)
/* DEBUG_SECTION controls
DEBUG_SECTION report selection options.
Define any of the following options to obtain the desired debug reports:
*/
#define DEBUG_OFF 0
#define DEBUG_ALL -1
#define DEBUG_CONSTRUCTORS (1 << 0)
#define DEBUG_INITIALIZE (1 << 1)
#define DEBUG_MANIPULATORS (1 << 2)
#define DEBUG_HELPERS (1 << 3)
#define DEBUG_SLOTS (1 << 4)
#define DEBUG_SIGNALS (1 << 5)
#define DEBUG_EVENTS (1 << 6)
#define DEBUG_OVERVIEW (1 << 7)
#define DEBUG_SPECIAL (1 << 30)
#define DEBUG_DEFAULT (DEBUG_ALL & ~DEBUG_EVENTS)
#if (DEBUG_SECTION +0) == 0
#undef DEBUG_SECTION
#define DEBUG_SECTION DEBUG_OVERVIEW
#endif
#include <iostream>
#include <iomanip>
using std::clog;
using std::endl;
using std::boolalpha;
using std::hex;
using std::dec;
#endif // DEBUG_SECTION
namespace UA
{
namespace HiRISE
{
/*==============================================================================
Constants
*/
const char* const
Navigator_Tool::ID =
"UA::HiRISE::Navigator_Tool ($Revision: 1.77 $ $Date: 2012/06/15 01:16:07 $)";
#ifndef NAVIGATOR_TOOL_IMAGE_MIN_WIDTH
#define NAVIGATOR_TOOL_IMAGE_MIN_WIDTH 250
#endif
#ifndef NAVIGATOR_TOOL_IMAGE_MIN_HEIGHT
#define NAVIGATOR_TOOL_IMAGE_MIN_HEIGHT 100
#endif
const QSize
Navigator_Tool::IMAGE_MIN_SIZE
(NAVIGATOR_TOOL_IMAGE_MIN_WIDTH, NAVIGATOR_TOOL_IMAGE_MIN_HEIGHT);
/*==============================================================================
Application configuration parameters
*/
#define Panel_Frame_Style \
HiView_Config::Panel_Frame_Style
#define Panel_Frame_Width \
HiView_Config::Panel_Frame_Width
#define Label_Frame_Style \
HiView_Config::Label_Frame_Style
#define Label_Frame_Width \
HiView_Config::Label_Frame_Width
#define Label_Frame_Margin \
HiView_Config::Label_Frame_Margin
#define Heading_Line_Weight \
HiView_Config::Heading_Line_Weight
#define DISPLAY_BAND_NAMES \
HiView_Config::DISPLAY_BAND_NAMES
#define DISPLAY_BAND_COLORS \
HiView_Config::DISPLAY_BAND_COLORS
#define Shift_Region_Cursor \
HiView_Config::Shift_Region_Cursor
#define Reset_Button_Icon \
HiView_Config::Reset_Button_Icon
/*==============================================================================
Defaults
*/
#ifndef NAVIGATOR_SHOW_ALL_REGION_ORIGINS
#define NAVIGATOR_SHOW_ALL_REGION_ORIGINS false
#endif
bool
Navigator_Tool::Default_Show_All_Region_Origins =
NAVIGATOR_SHOW_ALL_REGION_ORIGINS;
#ifndef NAVIGATOR_SHOW_ALL_SCALINGS
#define NAVIGATOR_SHOW_ALL_SCALINGS false
#endif
bool
Navigator_Tool::Default_Show_All_Scalings =
NAVIGATOR_SHOW_ALL_SCALINGS;
#ifndef NAVIGATOR_DEFAULT_SCALING_X_Y_DISTINCT
#define NAVIGATOR_DEFAULT_SCALING_X_Y_DISTINCT false
#endif
bool
Navigator_Tool::Default_Scaling_X_Y_Distinct =
NAVIGATOR_DEFAULT_SCALING_X_Y_DISTINCT;
#ifndef NAVIGATOR_IMMEDIATE_MODE
#define NAVIGATOR_IMMEDIATE_MODE true
#endif
bool
Navigator_Tool::Default_Immediate_Mode =
NAVIGATOR_IMMEDIATE_MODE;
QErrorMessage
*Navigator_Tool::Error_Message = NULL;
/*==============================================================================
Local constants
*/
enum Changes_Pending_Flags
{
REGION_ORIGIN = (1 << 0),
SCALING = (1 << 1),
BAND_MAPPING = (1 << 2)
};
enum Apply_When_Modes
{
DEFERRED_MODE = 0,
IMMEDIATE_MODE = 1
};
/*==============================================================================
Constructors
*/
Navigator_Tool::Navigator_Tool
(
QWidget* parent
)
: QDockWidget (tr ("Navigator"), parent),
Image_View (NULL),
Band_Map_Reset_Button (NULL),
Changes_Pending (0),
Received_Knowledge (false),
Region_Overlay (NULL),
Region_Drag_Offset (-1, -1)
{
setObjectName ("Navigator_Tool");
#if ((DEBUG_SECTION) & (DEBUG_CONSTRUCTORS | DEBUG_INITIALIZE))
clog << ">>> Navigator_Tool: " << object_pathname (this) << endl;
#endif
setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
QSplitter
*split_panel = new QSplitter (Qt::Vertical, this);
split_panel->setObjectName (windowTitle () + " Splitter");
split_panel->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
split_panel->setChildrenCollapsible (true);
// Enable keyboard focus on the tool.
setFocusPolicy (Qt::StrongFocus);
QWidget
*image_widget,
*info_widget;
// Overview image.
image_widget = image_panel ();
image_widget->setObjectName (windowTitle () + " Image_Panel");
#if ((DEBUG_SECTION) & (DEBUG_CONSTRUCTORS | DEBUG_INITIALIZE))
clog << " image_panel sizeHint = " << image_widget->sizeHint () << endl;
#endif
split_panel->addWidget (image_widget);
// Info panel.
info_widget = info_panel ();
info_widget->setObjectName (windowTitle () + " Info_Panel");
#if ((DEBUG_SECTION) & (DEBUG_CONSTRUCTORS | DEBUG_INITIALIZE))
clog << " info_panel sizeHint = " << info_widget->sizeHint () << endl;
#endif
split_panel->addWidget (info_widget);
/*
QSize
minimum_size (QDockWidget::sizeHint ());
minimum_size -= split_panel->sizeHint (); // Margins size.
minimum_size += info_widget->sizeHint ();
minimum_size.rheight () += IMAGE_MIN_SIZE.height ();
#if ((DEBUG_SECTION) & (DEBUG_CONSTRUCTORS | DEBUG_INITIALIZE))
clog << " QDockWidget sizeHint = " << QDockWidget::sizeHint () << endl
<< " split_panel sizeHint = " << split_panel->sizeHint () << endl
<< " IMAGE_MIN_SIZE = " << IMAGE_MIN_SIZE << endl
<< " minimum_size = " << minimum_size << endl;
#endif
setMinimumSize (minimum_size);
*/
split_panel->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred);
image_widget->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Expanding);
QList<int>
relative_sizes;
relative_sizes << 10000 << 10;
split_panel->setSizes (relative_sizes);
setWidget (split_panel);
// Image loaded.
connect (Image_View,
SIGNAL (image_loaded (bool)),
SLOT (image_loaded (bool)));
// Image pixel value.
connect (Image_View,
SIGNAL (image_pixel_value
(const Plastic_Image::Triplet&, const Plastic_Image::Triplet&)),
SLOT (image_pixel_value
(const Plastic_Image::Triplet&, const Plastic_Image::Triplet&)));
// Image cursor location.
connect (Image_View,
SIGNAL (image_cursor_moved (const QPoint&, const QPoint&)),
SLOT (nav_image_cursor_moved (const QPoint&, const QPoint&)));
// Overview image scrolling and scaling tracking.
connect (Image_View,
SIGNAL (image_moved (const QPoint&, int)),
SLOT (overview_image_moved (const QPoint&, int)));
connect (Image_View,
SIGNAL (image_scaled (const QSizeF&, int)),
SLOT (overview_image_scaled (const QSizeF&, int)));
// Band mapping.
connect (this,
SIGNAL (bands_mapped (const unsigned int*)),
Image_View,
SLOT (map_bands (const unsigned int*)));
#if ((DEBUG_SECTION) & (DEBUG_CONSTRUCTORS | DEBUG_INITIALIZE))
clog << "<<< Navigator_Tool" << endl;
#endif
}
Navigator_Tool::~Navigator_Tool ()
{
#if ((DEBUG_SECTION) & DEBUG_CONSTRUCTORS)
clog << ">-< ~Navigator_Tool: @ " << (void*)this << endl;
#endif
}
/*==============================================================================
Accessors
*/
void
Navigator_Tool::image_name
(
const QString& name
)
{
if (name.isEmpty ())
{
Source_Name->clear ();
Source_Name->setVisible (false);
}
else
{
QString
text (name);
int
index = text.lastIndexOf ('/');
if (index >= 0)
text.remove (0, ++index);
text.insert (0, "<b>"); // Bold text.
Source_Name->setText (text);
Source_Name->setVisible (true);
}
}
QString
Navigator_Tool::image_name () const
{return Source_Name->text ().mid (3);}
void
Navigator_Tool::immediate_mode
(
bool enabled
)
{Apply_When->setCurrentIndex (enabled ? IMMEDIATE_MODE : DEFERRED_MODE);}
bool
Navigator_Tool::immediate_mode () const
{return Apply_When->currentIndex () == IMMEDIATE_MODE;}
QSize
Navigator_Tool::minimumSizeHint () const
{return minimumSize ();}
QSize
Navigator_Tool::sizeHint () const
{return minimumSize ();}
/*==============================================================================
GUI elements
*/
QWidget*
Navigator_Tool::image_panel ()
{
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << ">>> Navigator_Tool::image_panel" << endl;
#endif
Image_View = new Image_Viewer (this);
Image_View->setMinimumSize (IMAGE_MIN_SIZE);
// Temporary size policy during setup.
Image_View->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
// Region overlay.
Region_Overlay =
new QRubberBand (QRubberBand::Rectangle, Image_View->image_display ());
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << "<<< Navigator_Tool::image_panel" << endl;
#endif
return Image_View;
}
QWidget*
Navigator_Tool::info_panel ()
{
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << ">>> Navigator_Tool::info_panel" << endl;
#endif
if (Reset_Button_Icon)
{
Band_Map_Reset_Button = new Icon_Button (*Reset_Button_Icon);
Band_Map_Reset_Button->setToolTip (tr ("Reset to default band selections"));
}
QFrame
*panel = new QFrame;
QGridLayout
*layout = new QGridLayout (panel);
panel->setFrameStyle (Panel_Frame_Style);
panel->setLineWidth (Panel_Frame_Width);
panel->setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum);
QLabel
*label;
int
band,
row = -1,
display_band_row,
source_band_row,
source_value_row,
display_value_row,
col,
label_col = 0, // Labels
X_col = 1, // X/Width/First values
X_adjust_col = 2,
Y_col = 3, // Y/Height/Second values
Y_adjust_col = 4,
Z_col = 5, // Third values
Z_adjust_col = 6,
spacer_col = 7, // Fill (quad left) space
/*
HACK !!!
The correct solution to determine the width of the numeric value
fields to line up with the values in the edit fields of the spin
boxes has not been found. This hack is based on trial-and-error to
come up with values that seem to work; but they may not work on
all platforms and with all styles.
*/
value_width = QLabel ("999").sizeHint ().width () * 2;
layout->setColumnStretch (label_col, 1);
layout->setColumnStretch (X_col, 1);
layout->setColumnMinimumWidth (X_col, value_width);
layout->setColumnStretch (X_adjust_col, 1);
layout->setColumnMinimumWidth (X_adjust_col, 10);
layout->setColumnStretch (Y_col, 1);
layout->setColumnMinimumWidth (Y_col, value_width);
layout->setColumnStretch (Y_adjust_col, 1);
layout->setColumnMinimumWidth (Y_adjust_col, 10);
layout->setColumnStretch (Z_col, 1);
layout->setColumnMinimumWidth (Z_col, value_width);
layout->setColumnStretch (Z_adjust_col, 1);
layout->setColumnMinimumWidth (Z_adjust_col, 10);
layout->setColumnStretch (spacer_col, 100);
layout->setColumnMinimumWidth (spacer_col,
(Band_Map_Reset_Button ? Band_Map_Reset_Button->iconSize ().width () : 1));
layout->setVerticalSpacing (1);
//------------------------------------------------------------------------------
// Source Name
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Separator" << endl;
#endif
layout->addWidget (new Drawn_Line (Heading_Line_Weight),
row, 0, 1, -1, Qt::AlignTop);
layout->setRowMinimumHeight (row, 10);
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Image source name" << endl;
#endif
Source_Name = new QLabel;
Source_Name->setWordWrap (true);
Source_Name->setToolTip (tr ("Image source name"));
layout->addWidget (Source_Name,
row, 0, 1, -1, Qt::AlignLeft | Qt::AlignVCenter);
//------------------------------------------------------------------------------
// Bands
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Separator" << endl;
#endif
layout->addWidget (new Drawn_Line (Heading_Line_Weight),
row, 0, 1, -1, Qt::AlignBottom);
layout->setRowMinimumHeight (row, 10);
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Bands" << endl;
#endif
layout->addWidget (new QLabel (tr ("<b>Bands</b>")),
row, 0, 1, -1, Qt::AlignLeft | Qt::AlignVCenter);
display_band_row = ++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Band/Pixel labels -" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Display:")),
display_band_row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Displayed image bands"));
source_band_row = ++row;
layout->addWidget (Source_Bands = new QLabel (tr ("Source:")),
source_band_row, label_col, Qt::AlignRight | Qt::AlignVCenter);
Source_Bands->setToolTip (tr ("Source image bands"));
//------------------------------------------------------------------------------
// Pixel Values
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Separator" << endl;
#endif
layout->addWidget (new Drawn_Line (1),
row, 0, 1, -1, Qt::AlignBottom);
layout->setRowMinimumHeight (row, 10);
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Pixel Values" << endl;
#endif
layout->addWidget (new QLabel (tr ("<b>Pixel Values</b>")),
row, 0, 1, -1, Qt::AlignLeft | Qt::AlignVCenter);
display_value_row = ++row;
layout->addWidget (label = new QLabel (tr ("256 Display:")),
display_value_row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Displayed image value at cursor location"));
source_value_row = ++row;
layout->addWidget (Source_Values = new QLabel (tr ("Source:")),
source_value_row, label_col, Qt::AlignRight | Qt::AlignVCenter);
Source_Values->setToolTip (tr ("Source image value at cursor location"));
for (band = 0,
col = X_col;
band < 3;
band++,
col += 2)
{
// Band names.
label = new QLabel (tr (DISPLAY_BAND_NAMES[band]).prepend ("<b>"));
label->setAlignment (Qt::AlignLeft | Qt::AlignVCenter);
label->setFrameStyle (Label_Frame_Style);
label->setLineWidth (Label_Frame_Width);
label->setMargin (Label_Frame_Margin);
label->setPalette (QPalette
(QColor (DISPLAY_BAND_COLORS[band]).lighter ()));
label->setAutoFillBackground (true);
layout->addWidget (label,
display_band_row, col, 1, 2, Qt::AlignVCenter);
// Source bands map.
Image_Band[band] = new QSpinBox ();
Image_Band[band]->setKeyboardTracking (false);
Image_Band[band]->setAlignment (Qt::AlignRight);
Image_Band[band]->setFrame (false);
layout->addWidget (Image_Band[band],
source_band_row, col, 1, 2, Qt::AlignVCenter);
connect (Image_Band[band],
SIGNAL (valueChanged (int)),
SLOT (band_mapping_changed ()));
// Source values.
Source_Value[band] = new QLabel;
Source_Value[band]->setAlignment (Qt::AlignRight);
layout->addWidget (Source_Value[band],
source_value_row, col, Qt::AlignRight);
// Display values.
Display_Value[band] = new QLabel;
Display_Value[band]->setAlignment (Qt::AlignRight);
layout->addWidget (Display_Value[band],
display_value_row, col, Qt::AlignRight);
}
// Band map reset button
if (Band_Map_Reset_Button)
{
Band_Map_Reset_Button->setVisible (false);
Band_Map_Reset_Button->setFocusPolicy (Qt::NoFocus);
connect (Band_Map_Reset_Button,
SIGNAL (clicked ()),
SLOT (band_map_reset ()));
layout->addWidget (Band_Map_Reset_Button,
source_band_row, spacer_col, Qt::AlignLeft | Qt::AlignVCenter);
}
//------------------------------------------------------------------------------
// Geometry
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Separator" << endl;
#endif
layout->addWidget (new Drawn_Line (Heading_Line_Weight),
row, label_col, 1, -1, Qt::AlignBottom);
layout->setRowMinimumHeight (row, 10);
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Geometry" << endl;
#endif
layout->addWidget (new QLabel (tr ("<b>Geometry</b>")),
row, 0, 1, -1, Qt::AlignLeft | Qt::AlignVCenter);
// Column names
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Column names -" << endl;
#endif
layout->addWidget (new QLabel (tr ("<b>X</b>")),
row, X_col, Qt::AlignRight | Qt::AlignBottom);
layout->addWidget (new QLabel (tr ("<b>Y</b>")),
row, Y_col, Qt::AlignRight | Qt::AlignBottom);
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Column names underlines -" << endl;
#endif
layout->addWidget (new Drawn_Line,
row, X_col);
layout->addWidget (new Drawn_Line,
row, Y_col);
// Source Size
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Source Size" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Source Size:")),
row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Source image size"));
layout->addWidget (Source_Size_X = new QLabel,
row, X_col, Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget (Source_Size_Y = new QLabel,
row, Y_col, Qt::AlignRight | Qt::AlignVCenter);
// Region Size
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Region Size" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Region Size:")),
row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Source image region size in the display viewport"));
layout->addWidget (Region_Size_X = new QLabel,
row, X_col, Qt::AlignRight | Qt::AlignVCenter);
Region_Size_X->setAlignment (Qt::AlignRight);
layout->addWidget (Region_Size_Y = new QLabel,
row, Y_col, Qt::AlignRight | Qt::AlignVCenter);
Region_Size_Y->setAlignment (Qt::AlignRight);
// Region Origin
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << '-' << (row + 2) << ": Region Origin" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Region Origin:")),
row, 0, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Source image location at the display viewport origin"));
Show_All_Region_Origins = Default_Show_All_Region_Origins;
for (band = 0;
band < 3;
band++,
row++)
{
Region_Origin_X[band] = new QSpinBox;
Region_Origin_X[band]->setKeyboardTracking (false);
Region_Origin_X[band]->setAlignment (Qt::AlignRight);
Region_Origin_X[band]->setAccelerated (true);
Region_Origin_X[band]->setFrame (false);
layout->addWidget (Region_Origin_X[band],
row, X_col, 1, 2, Qt::AlignVCenter);
connect (Region_Origin_X[band],
SIGNAL (valueChanged (int)),
SLOT (region_origin_changed ()));
Region_Origin_Y[band] = new QSpinBox;
Region_Origin_Y[band]->setKeyboardTracking (false);
Region_Origin_Y[band]->setAlignment (Qt::AlignRight);
Region_Origin_Y[band]->setAccelerated (true);
Region_Origin_Y[band]->setFrame (false);
layout->addWidget (Region_Origin_Y[band],
row, Y_col, 1, 2, Qt::AlignVCenter);
connect (Region_Origin_Y[band],
SIGNAL (valueChanged (int)),
SLOT (region_origin_changed ()));
if (band)
{
Region_Origin_X[band]->setVisible (Show_All_Region_Origins);
Region_Origin_Y[band]->setVisible (Show_All_Region_Origins);
}
}
// Source Location
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Source Location" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Source Location:")),
row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Source image cursor location"));
layout->addWidget (Source_Location_X = new QLabel,
row, X_col, Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget (Source_Location_Y = new QLabel,
row, Y_col, Qt::AlignRight | Qt::AlignVCenter);
// Display Location
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Display Location" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Display Location:")),
row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Display viewport cursor location"));
layout->addWidget (Display_Location_X = new QLabel,
row, X_col, Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget (Display_Location_Y = new QLabel,
row, Y_col, Qt::AlignRight | Qt::AlignVCenter);
// Display Size
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Display Size" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Display Size:")),
row, label_col, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Display viewport size"));
layout->addWidget (Display_Size_X = new QLabel,
row, X_col, Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget (Display_Size_Y = new QLabel,
row, Y_col, Qt::AlignRight | Qt::AlignVCenter);
// Spacing
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Gap" << endl;
#endif
layout->setRowMinimumHeight (row, 10);
// Image Scale
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << '-' << (row + 2) << ": Image Scale" << endl;
#endif
layout->addWidget (label = new QLabel (tr ("Image Scale:")),
row, 0, Qt::AlignRight | Qt::AlignVCenter);
label->setToolTip (tr ("Source image scaling factor"));
Show_All_Scalings = Default_Show_All_Scalings;
for (band = 0;
band < 3;
band++,
row++)
{
Scaling_X[band] = new QDoubleSpinBox;
Scaling_X[band]->setKeyboardTracking (false);
Scaling_X[band]->setAlignment (Qt::AlignRight);
Scaling_X[band]->setDecimals (3);
Scaling_X[band]->setRange
(Image_Viewer::min_scale (), Image_Viewer::max_scale ());
Scaling_X[band]->setSingleStep (Image_Viewer::scaling_minor_increment ());
Scaling_X[band]->setAccelerated (true);
Scaling_X[band]->setFrame (false);
layout->addWidget (Scaling_X[band],
row, X_col, 1, 2, Qt::AlignVCenter);
connect (Scaling_X[band],
SIGNAL (valueChanged (double)),
SLOT (image_scaling_changed ()));
Scaling_Y[band] = new QDoubleSpinBox;
Scaling_Y[band]->setKeyboardTracking (false);
Scaling_Y[band]->setAlignment (Qt::AlignRight);
Scaling_Y[band]->setDecimals (3);
Scaling_Y[band]->setRange
(Image_Viewer::min_scale (), Image_Viewer::max_scale ());
Scaling_Y[band]->setSingleStep (Image_Viewer::scaling_minor_increment ());
Scaling_Y[band]->setAccelerated (true);
Scaling_Y[band]->setFrame (false);
layout->addWidget (Scaling_Y[band],
row, Y_col, 1, 2, Qt::AlignVCenter);
connect (Scaling_Y[band],
SIGNAL (valueChanged (double)),
SLOT (image_scaling_changed ()));
Scaling_X_Y_Distinct[band] = Default_Scaling_X_Y_Distinct;
if (band)
{
Scaling_X[band]->setVisible (Show_All_Scalings);
Scaling_Y[band]->setVisible
(Show_All_Scalings && Scaling_X_Y_Distinct[band]);
}
else
Scaling_Y[band]->setVisible (Scaling_X_Y_Distinct[band]);
}
//------------------------------------------------------------------------------
// Apply actions
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Separator" << endl;
#endif
layout->addWidget (new Drawn_Line (Heading_Line_Weight),
row, label_col, 1, -1);
layout->setRowMinimumHeight (row, 10);
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Apply actions" << endl;
#endif
QHBoxLayout
*accept_actions_layout = new QHBoxLayout;
Apply = new QPushButton (tr ("Apply"));
Apply->setToolTip (tr ("Apply changed settings"));
Apply->setEnabled (false);
connect (Apply,
SIGNAL (clicked (bool)),
SLOT (apply ()));
accept_actions_layout->addWidget (Apply);
Apply_When = new QComboBox;
Apply_When->setToolTip (tr ("When to apply changed settings"));
Apply_When->setEditable (false);
Apply_When->addItem (tr ("Deferred"));
Apply_When->addItem (tr ("Immediate"));
Apply_When->setCurrentIndex
(Default_Immediate_Mode ? IMMEDIATE_MODE : DEFERRED_MODE);
connect (Apply_When,
SIGNAL (currentIndexChanged (int)),
SLOT (apply_when_changed (int)));
accept_actions_layout->addWidget (Apply_When);
accept_actions_layout->addStretch (100);
layout->addLayout (accept_actions_layout,
row, label_col, 1, -1);
// Bottom space
++row;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " " << row << ": Spacer" << endl;
#endif
//layout->setRowMinimumHeight (row, 10);
layout->setRowStretch (row, 100);
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << " sizeHint = " << panel->sizeHint () << endl
<< "<<< Navigator_Tool::info_panel" << endl;
#endif
return panel;
}
void
Navigator_Tool::reset_info ()
{
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << ">>> Navigator_Tool::reset_info" << endl;
#endif
// Prevent change signals during reset.
Received_Knowledge = true;
// The Source_Name is set when the image is loaded.
int
source_bands = Image_View->image_bands (),
source_values = 1 << Image_View->image_data_precision (),
source_width = Image_View->image_width (),
source_height = Image_View->image_height ();
// Source bands
Source_Bands->setVisible (source_bands);
Source_Bands->setText (QString::number (source_bands) + tr (" Source:"));
const unsigned int
*band_map = Image_View->image ()->source_band_map ();
Initial_Band_Map [0] = band_map[0];
Initial_Band_Map [1] = band_map[1];
Initial_Band_Map [2] = band_map[2];
// Total source values
Source_Values->setText (QString::number (source_values) += tr (" Source:"));
// Image Size
Source_Size_X->setNum (source_width);
Source_Size_Y->setNum (source_height);
// Region Size is set by the displayed_image_region_resized slot.
for (int
band = 0;
band < 3;
++band)
{
// Region Origin
if (band)
{
Region_Origin_X[band]->setVisible
((band < source_bands) && Show_All_Region_Origins);
Region_Origin_Y[band]->setVisible
((band < source_bands) && Show_All_Region_Origins);
}
Region_Origin_X[band]->setRange (0, source_width - 1);
Region_Origin_X[band]->setValue (0);
Region_Origin_Y[band]->setRange (0, source_height - 1);
Region_Origin_Y[band]->setValue (0);
/*
Scaling is set by a signal from the main Image_Viewer
when the image is loaded.
*/
// Image Band/Pixel Value
Image_Band[band]->setVisible (source_bands);
Image_Band[band]->setRange
(HiView_Utilities::band_index_to_number (0),
HiView_Utilities::band_index_to_number (source_bands - 1));
Image_Band[band]->setValue
(HiView_Utilities::band_index_to_number (band_map[band]));
}
Changes_Pending = 0;
Apply->setEnabled (false);
Received_Knowledge = false;
#if ((DEBUG_SECTION) & DEBUG_INITIALIZE)
clog << "<<< Navigator_Tool::reset_info" << endl;
#endif
}
void
Navigator_Tool::refresh_band_numbers ()
{
#if ((DEBUG_SECTION) & (DEBUG_INITIALIZE | DEBUG_SLOTS))
clog << ">>> Navigator_Tool::refresh_band_numbers" << endl;
#endif
int
source_bands = Image_View->image_bands ();
#if ((DEBUG_SECTION) & (DEBUG_INITIALIZE | DEBUG_SLOTS))
clog << " band range = " << HiView_Utilities::band_index_to_number (0)
<< " - " << HiView_Utilities::band_index_to_number (source_bands - 1)
<< endl;
#endif
const unsigned int
*band_map = Image_View->image ()->source_band_map ();
bool
blocked;
for (int
band = 0;
band < 3;
++band)
{
#if ((DEBUG_SECTION) & (DEBUG_INITIALIZE | DEBUG_SLOTS))
clog << " band " << band << "->" << band_map[band]
<< " number "
<< HiView_Utilities::band_index_to_number (band_map[band]) << endl;
#endif
blocked = Image_Band[band]->blockSignals (true);
Image_Band[band]->setRange
(HiView_Utilities::band_index_to_number (0),
HiView_Utilities::band_index_to_number (source_bands - 1));
Image_Band[band]->setValue
(HiView_Utilities::band_index_to_number (band_map[band]));
Image_Band[band]->blockSignals (blocked);
}
#if ((DEBUG_SECTION) & (DEBUG_INITIALIZE | DEBUG_SLOTS))
clog << ">>> Navigator_Tool::refresh_band_numbers" << endl;
#endif
}
void
Navigator_Tool::show_all_region_origins
(
bool enabled
)
{
Show_All_Region_Origins = enabled;
int
source_bands = Image_View->image_bands ();
for (int
band = 0;
band < 3;
band++)
{
if (band)
{
Region_Origin_X[band]->setVisible
((band < source_bands) && Show_All_Region_Origins);
Region_Origin_Y[band]->setVisible
((band < source_bands) && Show_All_Region_Origins);
}
}
}
void
Navigator_Tool::show_all_scalings
(
bool enabled
)
{
Show_All_Scalings = enabled;
int
source_bands = Image_View->image_bands ();
for (int
band = 0;
band < 3;
band++)
{
if (band)
{
Scaling_X[band]->setVisible
((band < source_bands) && Show_All_Scalings);