diff MessageOrganiser.mm @ 27:27cdf475aa4b

more fiddling
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Wed, 29 Oct 2014 15:38:38 +0000
parents 8eb530e0601b
children 953db6518738
line wrap: on
line diff
--- a/MessageOrganiser.mm	Tue Oct 28 19:15:28 2014 +0000
+++ b/MessageOrganiser.mm	Wed Oct 29 15:38:38 2014 +0000
@@ -7,6 +7,38 @@
     
     onlyChangeCandidateOnTrigger = true;
 }
+
+
+void MessageOrganiser::setupDefaultMapping(controlPanelType whichInterfaceAreWeUsing){
+    vector<int> mappingIDsForChangeableParams = getMappingIDsFromSynths();
+    vector<controllerType> elemList;
+    
+    if (whichInterfaceAreWeUsing == ALL_SLIDERS){
+        
+        for(int i = 0; i < TOTAL_NUM_PARAMS; i++){
+            elemList.push_back(SLIDER);
+            
+        }
+    }else if (whichInterfaceAreWeUsing == LEAP6DOF){
+        elemList.push_back(LEAP6D);
+    }
+    vector<UIElement*> UIElemHandles = controlPanel->generateControls(elemList, whichInterfaceAreWeUsing);
+    
+    mapSlidersToParams(UIElemHandles, mappingIDsForChangeableParams);
+    
+}
+
+
+//----------------------------------------------------------------------------------------
+vector<int> MessageOrganiser::getMappingIDsFromSynths(){
+    vector<int> index;
+    for(int i = 0; i < TOTAL_NUM_PARAMS; i++){
+        index.push_back(i);
+    }
+    vector<int> mids = candidateSynth.getMappingIDForIndices(index);
+    
+    return mids;
+}
 // could template for ui element type??
 void MessageOrganiser::mapButtonToAction(UIElement* control, int mappingID){
     UICallbackFunction callbackF;
@@ -17,7 +49,7 @@
 
 
 void MessageOrganiser::setControlPanel(SliderPanel* p){ // a bit specific??
-    panel = p;
+    controlPanel = p;
     
 };
 void MessageOrganiser::setBottomPanel(ButtonPanel * ntb){
@@ -28,9 +60,7 @@
 void MessageOrganiser::setIconPanel(IconPanel * ip){
     presetIconPanel = ip;
 }
-void MessageOrganiser::setBox(Leap6DBox * box){
-    box6D = box;
-}
+
 void MessageOrganiser::setInstructionPanel(TextPanel * ip){
     instructionPanel = ip;
     instructionPanel->show();
@@ -42,13 +72,13 @@
     presetIconPanel->hide();
     instructionPanel->hide();
     bottomPanel->hide();
-    panel->hide();
+    controlPanel->hide();
 }
 void MessageOrganiser::showMyPanels(){
     presetIconPanel->show();
     instructionPanel->show();
     bottomPanel->show();
-    panel->show();
+    controlPanel->show();
 }
 
 void MessageOrganiser::triggerCandidateSound(){
@@ -57,7 +87,7 @@
     candidateSynth.trigger();
     eventLogger.logEvent(CANDIDATE_PLAYED);
     // flash panel?
-    panel->flash();
+    controlPanel->flash();
 }
 
 void MessageOrganiser::paramChangeCallback(int mappingID, int value){
@@ -91,22 +121,20 @@
     // theXY->setValueAndScale(candidateSynth.getParamValueForID(mids[i]), candidateSynth.getParamValueForID(mids[i+1]));
     UIElement* elem;
     // get the element
-    if(panel->subElements.size() <= index){
+    if(controlPanel->subElements.size() <= index){
         cout << "ERROR: index out of range for num sliders" << endl;
         return;
     }
-    elem = panel->subElements[index];
+    elem = controlPanel->subElements[index];
     if ( elem->getType() == SLIDER){
         ButtronSlider* theSlider = (ButtronSlider*)elem;
         theSlider->setValueAndScale(value);
         
-    }else{
-        cout << "ERROR ERROR: ui type not handled by setUIToParam!" << endl;
+    }else if ( elem->getType() == LEAP6D){
+        Leap6DBox* theBox = (Leap6DBox*)elem;
+        theBox->setValueAndScale(index, value);
     }
-    if (box6D->isShowing()){
-        box6D->setValueAndScale(index, value);
-    }
-    
+
 };