<commit_before>/*
For more information, please see: http://software.sci.utah.edu

The MIT License

Copyright (c) 2015 Scientific Computing and Imaging Institute,
University of Utah.

License for the specific language governing rights and limitations under
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

#include <Interface/Modules/Render/ViewScenePlatformCompatibility.h>
#include <Interface/Modules/Render/ViewSceneControlsDock.h>
#include <Core/Logging/Log.h>
#include "qbrush.h"

using namespace SCIRun::Gui;
using namespace SCIRun::Render;


ViewSceneControlsDock::ViewSceneControlsDock(const QString& name, ViewSceneDialog* parent) : QDockWidget(parent)
{
  setupUi(this);

  setWindowTitle(name);
  setAllowedAreas(Qt::BottomDockWidgetArea);
  setFloating(true);
  setVisible(false);
  setEnabled(false);
  setStyleSheet(parent->styleSheet());
  
  setupObjectListWidget();

  parent->menuMouseControlChanged(mouseControlComboBox_->currentIndex());

  connect(orientationCheckBox_, SIGNAL(clicked(bool)), parent, SLOT(showOrientationChecked(bool)));
  connect(saveScreenShotOnUpdateCheckBox_, SIGNAL(stateChanged(int)), parent, SLOT(saveNewGeometryChanged(int)));
  connect(mouseControlComboBox_, SIGNAL(currentIndexChanged(int)), parent, SLOT(menuMouseControlChanged(int)));
  connect(setBackgroundColorPushButton_, SIGNAL(clicked()), parent, SLOT(assignBackgroundColor()));
  connect(contSortRadioButton_, SIGNAL(clicked(bool)), parent, SLOT(setTransparencySortTypeContinuous(bool)));
  connect(updateSortRadioButton_, SIGNAL(clicked(bool)), parent, SLOT(setTransparencySortTypeUpdate(bool)));
  connect(listSortRadioButton_, SIGNAL(clicked(bool)), parent, SLOT(setTransparencySortTypeLists(bool)));

  connect(objectListWidget_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotChanged(QListWidgetItem*)));
  connect(this, SIGNAL(itemUnselected(const QString&)), parent, SLOT(handleUnselectedItem(const QString&)));
  connect(this, SIGNAL(itemSelected(const QString&)), parent, SLOT(handleSelectedItem(const QString&)));

  setSampleColor(Qt::black);

  WidgetStyleMixin::tabStyle(tabWidget);


  /////Set unused widgets to be not visible
  ////Clipping tab
  tabWidget->removeTab(2);
  //ClippingTab->setVisible(false);
  //ClippingTab->setEnabled(false);
  //groupBox_3->setVisible(false);
  //groupBox_4->setVisible(false);
  //groupBox_5->setVisible(false);

  ///Object Tab
  //tabWidget->removeTab(1);

  ////View Tab
  //groupBox->setVisible(false);

  ////Render Tab
  //groupBox_6->setVisible(false);

}

void ViewSceneControlsDock::setSampleColor(const QColor& color)
{
  QString styleSheet = "QLabel{ background: rgb(" + QString::number(color.red()) + "," +
    QString::number(color.green()) + "," + QString::number(color.blue()) + "); }";

  currentBackgroundLabel_->setStyleSheet(styleSheet);
}

void ViewSceneControlsDock::addItem(const QString& name, bool checked)
{
  auto items = objectListWidget_->findItems(name, Qt::MatchExactly);
  if (items.count() > 1)
  {
    return;
  }

  QListWidgetItem* item = new QListWidgetItem(name, objectListWidget_);
  //item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);

  if (checked) item->setCheckState(Qt::Checked);
    //item->setData(Qt::Checked, Qt::CheckStateRole);
  else item->setCheckState(Qt::Unchecked);
    //item->setData(Qt::Unchecked, Qt::CheckStateRole);

  //items_.push_back(item);
  objectListWidget_->addItem(item);
}

void ViewSceneControlsDock::removeItem(const QString& name)
{
  auto items = objectListWidget_->findItems(name, Qt::MatchExactly);
  Q_FOREACH(QListWidgetItem* item, items)
  {
    objectListWidget_->removeItemWidget(item);
  }
  //items_.erase(std::remove_if(items_.begin(), items_.end(), [&](QListWidgetItem* item) { return item->text() == name; }), items_.end());
}

void ViewSceneControlsDock::removeAllItems()
{
  if (objectListWidget_->count() > 1)
  {
    LOG_DEBUG("ViewScene items cleared" << std::endl);
    objectListWidget_->clear();
    //items_.clear();
  }
}

void ViewSceneControlsDock::slotChanged(QListWidgetItem* item)
{
  if (item->checkState() == Qt::Unchecked)
  {
    LOG_DEBUG("Item " << item->text().toStdString() << " Unchecked!" << std::endl);
    Q_EMIT itemUnselected(item->text());
  }
  else if (item->checkState() == Qt::Checked)
  {<commit_msg>remove extraneous variable.<commit_after>/*
For more information, please see: http://software.sci.utah.edu

The MIT License

Copyright (c) 2015 Scientific Computing and Imaging Institute,
University of Utah.

License for the specific language governing rights and limitations under
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

#include <Interface/Modules/Render/ViewScenePlatformCompatibility.h>
#include <Interface/Modules/Render/ViewSceneControlsDock.h>
#include <Core/Logging/Log.h>
#include "qbrush.h"

using namespace SCIRun::Gui;
using namespace SCIRun::Render;


ViewSceneControlsDock::ViewSceneControlsDock(const QString& name, ViewSceneDialog* parent) : QDockWidget(parent)
{
  setupUi(this);

  setWindowTitle(name);
  setAllowedAreas(Qt::BottomDockWidgetArea);
  setFloating(true);
  setVisible(false);
  setEnabled(false);
  setStyleSheet(parent->styleSheet());
  
  setupObjectListWidget();

  parent->menuMouseControlChanged(mouseControlComboBox_->currentIndex());

  connect(orientationCheckBox_, SIGNAL(clicked(bool)), parent, SLOT(showOrientationChecked(bool)));
  connect(saveScreenShotOnUpdateCheckBox_, SIGNAL(stateChanged(int)), parent, SLOT(saveNewGeometryChanged(int)));
  connect(mouseControlComboBox_, SIGNAL(currentIndexChanged(int)), parent, SLOT(menuMouseControlChanged(int)));
  connect(setBackgroundColorPushButton_, SIGNAL(clicked()), parent, SLOT(assignBackgroundColor()));
  connect(contSortRadioButton_, SIGNAL(clicked(bool)), parent, SLOT(setTransparencySortTypeContinuous(bool)));
  connect(updateSortRadioButton_, SIGNAL(clicked(bool)), parent, SLOT(setTransparencySortTypeUpdate(bool)));
  connect(listSortRadioButton_, SIGNAL(clicked(bool)), parent, SLOT(setTransparencySortTypeLists(bool)));

  connect(objectListWidget_, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(slotChanged(QListWidgetItem*)));
  connect(this, SIGNAL(itemUnselected(const QString&)), parent, SLOT(handleUnselectedItem(const QString&)));
  connect(this, SIGNAL(itemSelected(const QString&)), parent, SLOT(handleSelectedItem(const QString&)));

  setSampleColor(Qt::black);

  WidgetStyleMixin::tabStyle(tabWidget);


  /////Set unused widgets to be not visible
  ////Clipping tab
  tabWidget->removeTab(2);
  //ClippingTab->setVisible(false);
  //ClippingTab->setEnabled(false);
  //groupBox_3->setVisible(false);
  //groupBox_4->setVisible(false);
  //groupBox_5->setVisible(false);

  ///Object Tab
  //tabWidget->removeTab(1);

  ////View Tab
  //groupBox->setVisible(false);

  ////Render Tab
  //groupBox_6->setVisible(false);

}

void ViewSceneControlsDock::setSampleColor(const QColor& color)
{
  QString styleSheet = "QLabel{ background: rgb(" + QString::number(color.red()) + "," +
    QString::number(color.green()) + "," + QString::number(color.blue()) + "); }";

  currentBackgroundLabel_->setStyleSheet(styleSheet);
}

void ViewSceneControlsDock::addItem(const QString& name, bool checked)
{
  auto items = objectListWidget_->findItems(name, Qt::MatchExactly);
  if (items.count() > 1)
  {
    return;
  }

  QListWidgetItem* item = new QListWidgetItem(name, objectListWidget_);

  if (checked) 
    item->setCheckState(Qt::Checked);
  else 
    item->setCheckState(Qt::Unchecked);

  objectListWidget_->addItem(item);
}

void ViewSceneControlsDock::removeItem(const QString& name)
{
  auto items = objectListWidget_->findItems(name, Qt::MatchExactly);
  Q_FOREACH(QListWidgetItem* item, items)
  {
    objectListWidget_->removeItemWidget(item);
  }
}

void ViewSceneControlsDock::removeAllItems()
{
  if (objectListWidget_->count() > 1)
  {
    LOG_DEBUG("ViewScene items cleared" << std::endl);
    objectListWidget_->clear();
  }
}

void ViewSceneControlsDock::slotChanged(QListWidgetItem* item)
{
  if (item->checkState() == Qt::Unchecked)
  {
    LOG_DEBUG("Item " << item->text().toStdString() << " Unchecked!" << std::endl);
    Q_EMIT itemUnselected(item->text());
  }
  else if (item->checkState() == Qt::Checked)
  {
{'fraction_non_alphanumeric': 0.1249265713726258, 'fraction_numerical': 0.002349716075974153, 'mean_word_length': 6.143356643356643, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2398619', 'n_tokens_mistral': 3074, 'n_tokens_neox': 2957, 'n_words': 754}