From 897ccdd3754490c1687249c40dca2765b5093bd8 Mon Sep 17 00:00:00 2001 From: Person Date: Mon, 8 Mar 2021 08:20:35 -0700 Subject: [PATCH] --User changes -Make Shift+F keys select the flames in the file, and Shift +/- cycle through them. --- Source/EmberCL/IterOpenCLKernelCreator.cpp | 1 + Source/Fractorium/Fractorium.cpp | 51 ++++++++++++++++++---- Source/Fractorium/Fractorium.h | 2 +- Source/Fractorium/FractoriumLibrary.cpp | 13 +++++- 4 files changed, 55 insertions(+), 12 deletions(-) diff --git a/Source/EmberCL/IterOpenCLKernelCreator.cpp b/Source/EmberCL/IterOpenCLKernelCreator.cpp index 79c7a9f..c301c73 100755 --- a/Source/EmberCL/IterOpenCLKernelCreator.cpp +++ b/Source/EmberCL/IterOpenCLKernelCreator.cpp @@ -589,6 +589,7 @@ string IterOpenCLKernelCreator::CreateIterKernelString(const Ember& ember, #else os << + "\n" " firstPoint = secondPoint;\n";//For testing, using straight rand flam4/fractron style instead of cuburn. #endif os << diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index 9d7dddc..cdd2ccd 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -372,6 +372,8 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) static int commacount = 0; static int periodcount = 0; static int lcount = 0; + const bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier); + const bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier); if (o == ui.GLParentScrollArea && e->type() == QEvent::Resize) { @@ -393,7 +395,12 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) { const int val = ke->key() - (int)Qt::Key_F1; - if (val < combo->count()) + if (shift) + { + if (val < ui.LibraryTree->topLevelItem(0)->childCount()) + m_Controller->SetEmber(val, true); + } + else if (val < combo->count()) combo->setCurrentIndex(val); fcount = 0; @@ -407,7 +414,7 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) //Require shift for deleting to prevent it from triggering when the user enters delete in the edit box. if (ke->key() == Qt::Key_Delete && e->type() == QEvent::KeyRelease && shift) { - auto v = GetCurrentEmberIndex(); + auto v = GetCurrentEmberIndex(false); if (ui.LibraryTree->topLevelItem(0)->childCount() > 1) OnDelete(v); @@ -428,16 +435,26 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) !focusedctrlCombo && !QGuiApplication::keyboardModifiers().testFlag(Qt::AltModifier))//Must exclude these because otherwise, typing a minus key in any of the spinners will switch the xform. Also exclude alt. { - unsigned int index = combo->currentIndex(); + unsigned int index; double vdist = 0.01; double hdist = 0.01; double zoom = 1; double rot = 1; double grow = 0.01; - const bool shift = QGuiApplication::keyboardModifiers().testFlag(Qt::ShiftModifier); - const bool ctrl = QGuiApplication::keyboardModifiers().testFlag(Qt::ControlModifier); bool pre = true; + if (shift) + { + auto v = GetCurrentEmberIndex(true); + + if (v.size() > 0) + index = v[0].first; + else + index = 0; + } + else + index = combo->currentIndex(); + if (const auto r = m_Controller->Renderer()) { hdist = std::abs(r->UpperRightX() - r->LowerLeftX()) * 0.01 * m_Controller->AffineScaleLockedToCurrent(); @@ -471,7 +488,12 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) if (xfupcount >= times) { xfupcount = 0; - combo->setCurrentIndex((index + 1) % combo->count()); + + if (shift) + m_Controller->SetEmber((index + 1) % ui.LibraryTree->topLevelItem(0)->childCount(), true); + else + combo->setCurrentIndex((index + 1) % combo->count()); + //qDebug() << "global arrow plus key press: " << ke->key() << " " << o->metaObject()->className() << " " << o->objectName(); } @@ -485,10 +507,21 @@ bool Fractorium::eventFilter(QObject* o, QEvent* e) { xfdncount = 0; - if (index == 0) - index = combo->count(); + if (shift) + { + if (index == 0) + index = ui.LibraryTree->topLevelItem(0)->childCount(); + + m_Controller->SetEmber((index - 1) % ui.LibraryTree->topLevelItem(0)->childCount(), true); + } + else + { + if (index == 0) + index = combo->count(); + + combo->setCurrentIndex((index - 1) % combo->count()); + } - combo->setCurrentIndex((index - 1) % combo->count()); //qDebug() << "global arrow minus key press: " << ke->key() << " " << o->metaObject()->className() << " " << o->objectName(); } diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index afd2641..a908f81 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -436,7 +436,7 @@ private: //Library. void SelectLibraryItem(size_t index); - vector> GetCurrentEmberIndex(); + vector> GetCurrentEmberIndex(bool isChecked); void SyncSequenceSettings(); //Params. diff --git a/Source/Fractorium/FractoriumLibrary.cpp b/Source/Fractorium/FractoriumLibrary.cpp index e2be177..704c295 100644 --- a/Source/Fractorium/FractoriumLibrary.cpp +++ b/Source/Fractorium/FractoriumLibrary.cpp @@ -85,8 +85,9 @@ void Fractorium::SelectLibraryItem(size_t index) /// /// Get the index of the currently selected ember in the library tree. /// +/// Whether to search for items that are checked or items that are only selected /// A pair containing the index of the item clicked and a pointer to the item -vector> Fractorium::GetCurrentEmberIndex() +vector> Fractorium::GetCurrentEmberIndex(bool isChecked) { int index = 0; QTreeWidgetItem* item = nullptr; @@ -100,7 +101,15 @@ vector> Fractorium::GetCurrentEmberIndex() item = top->child(index); if (item && item->isSelected()) - v.push_back(make_pair(index, item)); + { + if (isChecked) + { + if (item->checkState(0) == Qt::Checked) + v.push_back(make_pair(index, item)); + } + else + v.push_back(make_pair(index, item)); + } index++; }