From ac2450378616835a171ef0383474e32c434b930d Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 12 Nov 2019 22:34:41 +0000 Subject: [PATCH] - use File open dialog for project - redraw current Training pattern and weights on project load git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@662 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- source/MainComponent.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/source/MainComponent.cpp b/source/MainComponent.cpp index 81cf1df..0998036 100644 --- a/source/MainComponent.cpp +++ b/source/MainComponent.cpp @@ -528,17 +528,23 @@ void MainComponent::buttonClicked (Button* buttonThatWasClicked) else if (buttonThatWasClicked == loadButton) { //[UserButtonCode_loadButton] -- add your button handler code here.. - m_stack = new Stack(m_file.getParentDirectory().getFullPathName().toStdString(), std::string(projectNameLabel->getText().getCharPointer())); - m_stack->load(this); - m_stack->loadWeights(); - m_rbmSelect->clear(dontSendNotification); - - for (int id=0; id < m_stack->numLayers(); id++) + ScopedPointerfc = new FileChooser("Open project", m_file.getParentDirectory().getFullPathName(), "*.prj"); + if (fc->browseForFileToOpen()) { - m_rbmSelect->addItem(String(id), id+1); - } - m_rbmSelect->setSelectedId(1, sendNotification); - loadTraining(); + m_file = fc->getResult(); + projectNameLabel->setText(m_file.getFileNameWithoutExtension(), NotificationType::dontSendNotification); + m_stack = new Stack(m_file.getParentDirectory().getFullPathName().toStdString(), std::string(projectNameLabel->getText().getCharPointer())); + m_stack->load(this); + m_stack->loadWeights(); + m_rbmSelect->clear(dontSendNotification); + + for (int id=0; id < m_stack->numLayers(); id++) + { + m_rbmSelect->addItem(String(id), id+1); + } + m_rbmSelect->setSelectedId(1, sendNotification); + loadTraining(); + } //[/UserButtonCode_loadButton] } else if (buttonThatWasClicked == saveButton) @@ -634,8 +640,8 @@ void MainComponent::sliderValueChanged (Slider* sliderThatWasMoved) else if (sliderThatWasMoved == WeightsSlider) { //[UserSliderCode_WeightsSlider] -- add your slider handling code here.. - int weightIndex = (int)sliderThatWasMoved->getValue(); - m_pLayer->redrawWeights(weightIndex); + m_weightIndex = (int)sliderThatWasMoved->getValue(); + m_pLayer->redrawWeights(m_weightIndex); //[/UserSliderCode_WeightsSlider] } else if (sliderThatWasMoved == numGibbsSlider) @@ -755,6 +761,8 @@ void MainComponent::comboBoxChanged (ComboBox* comboBoxThatHasChanged) int index = m_rbmSelect->getSelectedItemIndex(); m_pLayer = static_cast(m_stack->getLayer(index)); updateControls(); + m_pLayer->redrawWeights(m_weightIndex); + m_pLayer->setTrainingData(m_stack->trainingData().row(m_trainingIndex)); //[/UserComboBoxCode_m_rbmSelect] }