ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvTextureFileSelector.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 // Qt
11 #include <QComboBox>
12 #include <QHBoxLayout>
13 #include <QToolButton>
14 
16  QWidget* parent, QString defaultButtonIconPath /*=QString()*/)
17  : QFrame(parent), m_comboBox(new QComboBox()), m_button(new QToolButton()) {
18  setLayout(new QHBoxLayout());
19  layout()->setContentsMargins(0, 0, 0, 0);
20  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
21 
22  // combox box
23  if (m_comboBox) {
24  layout()->addWidget(m_comboBox);
25  }
26 
27  // tool button
28  if (m_button) {
29  m_button->setIcon(QIcon(defaultButtonIconPath));
30  layout()->addWidget(m_button);
31  }
32 }
33 
35  return !m_comboBox || m_comboBox->count() <= 0;
36 }
37 
39  const QMap<QString, QString>& texturePathMap) {
40  // fill combox box
41  if (m_comboBox) {
42  m_comboBox->disconnect(this);
43 
44  m_comboBox->clear();
45 
46  for (QMap<QString, QString>::const_iterator path =
47  texturePathMap.constBegin();
48  path != texturePathMap.constEnd(); ++path) {
49  m_comboBox->addItem(path.key(), path.value());
50  }
51 
52  connect(m_comboBox, SIGNAL(activated(int)), this,
53  SIGNAL(textureFileSelected(int)));
54  }
55  // advanced tool button
56  if (m_button) {
57  m_button->disconnect(this);
58  connect(m_button, SIGNAL(clicked()), this,
59  SIGNAL(textureFileEditorSummoned()));
60  }
61 }
62 
63 void ecvTextureFileSelector::addItem(const QString& textureFilename,
64  const QString& textureFilepath) {
65  if (m_comboBox && m_comboBox->findData(textureFilepath) < 0) {
66  m_comboBox->addItem(textureFilename, textureFilepath);
67  }
68 }
69 
71  if (!m_comboBox || index < 0 || index >= m_comboBox->count())
72  return QString();
73 
74  // get UUID associated to the combo-box item
75  return m_comboBox->itemData(index).toString();
76 }
77 
78 void ecvTextureFileSelector::setSelectedTexturefile(QString textureFilepath) {
79  if (!m_comboBox) return;
80 
81  // search right index by UUID
82  int pos = m_comboBox->findData(textureFilepath);
83  if (pos < 0) return;
84  m_comboBox->setCurrentIndex(pos);
85 
86  emit textureFileSelected(pos);
87 }
QString getTexturefilePath(int index) const
QToolButton * m_button
Spawn color scale editor button.
void setSelectedTexturefile(QString textureFilepath)
Sets selected combo box item (scale) by UUID.
void textureFileSelected(int)
Signal emitted when a texture file item is selected.
void addItem(const QString &textureFilename, const QString &textureFilepath)
QComboBox * m_comboBox
Color scales combo-box.
ecvTextureFileSelector(QWidget *parent, QString defaultButtonIconPath=QString())
Default constructor.
void init(const QMap< QString, QString > &texturePathMap)
Inits selector with the Empty texture file path.
Tensor Maximum(const Tensor &input, const Tensor &other)
Computes the element-wise maximum of input and other. The tensors must have same data type and device...
static const std::string path
Definition: PointCloud.cpp:59