MCPcopy Create free account
hub / github.com/CloudCompare/CloudCompare / importScale

Method importScale

libs/CCPluginAPI/src/ccColorScaleEditorDlg.cpp:843–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841}
842
843void ccColorScaleEditorDialog::importScale()
844{
845 //persistent settings
846 QSettings settings;
847 settings.beginGroup(ccPS::LoadFile());
848 QString currentPath = settings.value(ccPS::CurrentPath(), ccFileUtils::defaultDocPath()).toString();
849
850 //ask for a filename
851 QString filename = QFileDialog::getOpenFileName(this,"Select color scale file",currentPath,"*.xml");
852 if (filename.isEmpty())
853 {
854 //process cancelled by user
855 return;
856 }
857
858 //save last loading parameters
859 settings.setValue(ccPS::CurrentPath(),QFileInfo(filename).absolutePath());
860 settings.endGroup();
861
862 //try to load the file
863 ccColorScale::Shared scale = ccColorScale::LoadFromXML(filename);
864 if (scale)
865 {
866 assert(m_manager);
867 if (m_manager)
868 {
869 ccColorScale::Shared otherScale = m_manager->getScale(scale->getUuid());
870 if (otherScale)
871 {
872 QString message = "A color scale with the same UUID";
873 if (otherScale->getName() == scale->getName())
874 message += QString(" and the same name (%1)").arg(scale->getName());
875 message += " is already in store!";
876 message += "\n";
877 message += "Do you want to force the importation of this new scale? (a new UUID will be generated)";
878
879 if (QMessageBox::question (this,
880 "UUID conflict",
881 message,
882 QMessageBox::Yes,
883 QMessageBox::No) == QMessageBox::No)
884 {
885 ccLog::Warning("[ccColorScaleEditorDialog::importScale] Importation cancelled due to a conflicting UUID (color scale may already be in store)");
886 return;
887 }
888 //generate a new UUID
889 scale->setUuid(QUuid::createUuid().toString());
890 }
891 //now we can import the scale
892 m_manager->addScale(scale);
893 ccLog::Print(QString("[ccColorScaleEditorDialog::importScale] Color scale '%1' successfully imported").arg(scale->getName()));
894 }
895
896 updateMainComboBox();
897
898 setActiveScale(scale);
899 }
900}

Callers

nothing calls this directly

Calls 11

LoadFileFunction · 0.85
CurrentPathFunction · 0.85
defaultDocPathFunction · 0.85
addScaleMethod · 0.80
QStringClass · 0.50
toStringMethod · 0.45
valueMethod · 0.45
isEmptyMethod · 0.45
setValueMethod · 0.45
getScaleMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected