VAPOR3 3.9.4
PTMSLODInput.h
Go to the documentation of this file.
1#pragma once
2
3#include <QFileDialog>
4#include "vapor/ImageParams.h"
5#include "vapor/GeoImageTMS.h"
6#include "vapor/TMSUtils.h"
7#include "PGroup.h"
8#include "VComboBox.h"
9
10//
11// PWidget for selecting TMS file level-of-detail
12//
13
14class PTMSLODInput : public PLineItem {
15 Q_OBJECT
16 VComboBox *_vComboBox;
17
18public:
19 PTMSLODInput() : PLineItem("", "TMS level of detail", _vComboBox = new VComboBox({"0"}))
20 {
21 QString tooltip = "TMS images can be displayed at varying resolutions.\n"
22 "This setting allows for manual resolution selection.";
23 _vComboBox->setToolTip(tooltip);
24 connect(_vComboBox, &VComboBox::IndexChanged, this, &PTMSLODInput::dropdownIndexChanged);
25 }
26
27protected:
28 virtual void updateGUI() const override
29 {
30 VAPoR::ImageParams *rp = dynamic_cast<VAPoR::ImageParams *>(getParams());
31 VAssert(rp && "Params must be ImageParams");
32
33 std::string imageFile = rp->GetImagePath();
34 if (Wasp::TMSUtils::IsTMSFile(imageFile)) {
35 _vComboBox->setEnabled(true);
36 } else {
37 _vComboBox->setEnabled(false); // Disable if not using a TMS image
38 return;
39 }
40
41 std::vector<std::string> options{"default"};
42 int lods = rp->GetNumTMSLODs();
43 for (int i = 0; i < lods; i++) { options.push_back(std::to_string(i)); }
44 _vComboBox->SetOptions(options);
45 _vComboBox->SetIndex(rp->GetTMSLOD() + 1);
46 };
47
48private slots:
49 void dropdownIndexChanged(int i)
50 {
51 VAPoR::ImageParams *rp = dynamic_cast<VAPoR::ImageParams *>(getParams());
52 VAssert(rp && "Params must be ImageParams");
53 rp->SetTMSLOD(i - 1);
54 }
55};
#define VAssert(expr)
Definition: VAssert.h:9
virtual void updateGUI() const override
Definition: PTMSLODInput.h:28
void setToolTip(const QString &)=delete
VAPoR::ParamsBase * getParams() const
void SetTMSLOD(int val)
Definition: ImageParams.h:92
int GetNumTMSLODs() const
Definition: ImageParams.h:96
std::string GetImagePath() const
int GetTMSLOD() const
Definition: ImageParams.h:84
void IndexChanged(int index)
COMMON_API bool IsTMSFile(std::string path)