Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 60 KiB |
@ -1,116 +1,225 @@ |
||||
/*
|
||||
============================================================================== |
||||
|
||||
ProgramSelector.cpp |
||||
Created: 29 Sep 2014 4:45:42pm |
||||
Author: Pascal Gauthier |
||||
|
||||
============================================================================== |
||||
*/ |
||||
#include "AlgoDisplay.h" |
||||
|
||||
/**
|
||||
* Algorithm arrangements, based on the DX1 display. |
||||
* |
||||
* Copyright (c) 2014 Pascal Gauthier. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software Foundation, |
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||||
* |
||||
*/ |
||||
static const char algoArr[][13] = { |
||||
// 1 2 3 4 5 6 7 8 9 A B C D
|
||||
{ 0, 0, 1, 3, 0, 0, 0, 2, 4, 0, 0, 5, -6 }, // 1
|
||||
{ 0, 0, 1, 3, 0, 0, 0, -2, 4, 0, 0, 5, 6 }, // 2
|
||||
{ 0, 0, 1, 4, 0, 0, 0, 2, 5, 0, 3, -6, 0 }, // 3
|
||||
{ 0, 0, 1, -4, 0, 0, 0, 2, -5, 0, 3, -6, 0 }, // 4
|
||||
{ 0, 1, 3, 5, 0, 0, 2, 4, -6, 0, 0, 0, 0 }, // 5
|
||||
{ 0, 1, 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5, 0, 0, 0, -6, 0, 0, 0, 0 }, // 25
|
||||
{ 0, 1, 2, 0, 4, 0, 0, 3, 5, -6, 0, 0, 0 }, // 26
|
||||
// 1 2 3 4 5 6 7 8 9 A B C D
|
||||
{ 0, 1, 2, 0, 4, 0, 0, -3, 5, 6, 0, 0, 0 }, // 27
|
||||
{ 0, 1, 3, 6, 0, 0, 2, 4, 0, 0, -5, 0, 0 }, // 28
|
||||
{ 0, 1, 2, 3, 5, 0, 0, 0, 4, -6, 0, 0, 0 }, // 29
|
||||
{ 0, 1, 2, 3, 6, 0, 0, 0, 4, 0, 0, -5, 0 }, // 30
|
||||
{ 1, 2, 3, 4, 5, 0, 0, 0, 0, -6, 0, 0, 0 }, // 31
|
||||
{ 1, 2, 3, 4, 5, -6, 0, 0, 0, 0, 0, 0, 0 } // 32
|
||||
}; |
||||
|
||||
#include "AlgoDisplay.h" |
||||
#include "DXLookNFeel.h" |
||||
|
||||
AlgoDisplay::AlgoDisplay() { |
||||
static char tmpAlgo = 0; |
||||
algo = &tmpAlgo; |
||||
} |
||||
|
||||
void AlgoDisplay::paint(Graphics &g) { |
||||
int alg; |
||||
|
||||
if ( *algo <= 31 ) { |
||||
alg = *algo; |
||||
} else { |
||||
alg = 31; |
||||
inline void displayOp(Graphics &g, char id, char x, char y, char link, char fb) { |
||||
const int LINE_SZ = 3; |
||||
String t(id); |
||||
|
||||
x *= 25; |
||||
y *= 21; |
||||
y += 5; |
||||
|
||||
g.setColour(Colours::white); |
||||
g.drawText(t, x, y, 16, 12, Justification::centred, true); |
||||
|
||||
g.setColour(DXLookNFeel::fillColour); |
||||
switch(link) { |
||||
case 0 : // LINE DOWN
|
||||
g.drawLine(x+8, y+12, x+8, y+21, LINE_SZ); |
||||
break; |
||||
case 1: // ARROW TO RIGHT
|
||||
g.drawLine(x+8, y+12, x+8, y+18, LINE_SZ); |
||||
g.drawLine(x+7, y+18, x+32, y+18, LINE_SZ); |
||||
break; |
||||
case 2: // ARROW TO LEFT
|
||||
g.drawLine(x+8, y+12, x+8, y+18, LINE_SZ); |
||||
g.drawLine(x-16, y+18, x+10, y+18, LINE_SZ); |
||||
break; |
||||
case 3: // LINE
|
||||
g.drawLine(x+8, y+12, x+8, y+18, LINE_SZ); |
||||
g.drawLine(x, y+18, x+26, y+18, LINE_SZ); |
||||
break; |
||||
case 4: // LEFT * 2
|
||||
g.drawLine(x+8, y+12, x+8, y+18, LINE_SZ); |
||||
g.drawLine(x-16, y+18, x+25, y+18, LINE_SZ); |
||||
default : |
||||
break; |
||||
} |
||||
const char *arr = algoArr[alg]; |
||||
|
||||
g.setColour (Colours::black.withAlpha(0.1f)); |
||||
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f); |
||||
|
||||
for(int i=0;i<13;i++) { |
||||
int target = arr[i]; |
||||
if ( target == 0 ) |
||||
continue; |
||||
|
||||
if ( i < 6 ) { |
||||
drawOp(g, i, 3, target); |
||||
continue; |
||||
} |
||||
|
||||
if ( i < 10 ){ |
||||
drawOp(g, (i-6)+1, 2, target); |
||||
continue; |
||||
} |
||||
|
||||
if ( i < 12 ) { |
||||
drawOp(g, (i-10)+2, 1, target); |
||||
continue; |
||||
} |
||||
|
||||
// last one
|
||||
drawOp(g, (i-12)+3, 0, target); |
||||
if ( fb ) { |
||||
g.drawLine(x+7, y, x+8, y-4, LINE_SZ); |
||||
g.drawLine(x+8, y-4, x+20, y-4, LINE_SZ); |
||||
g.drawLine(x+19, y-4, x+19, y+15, LINE_SZ); |
||||
g.drawLine(x+18, y+15, x+19, y+15, LINE_SZ); |
||||
g.drawLine(x+8, y+15, x+19, y+15, LINE_SZ); |
||||
} |
||||
|
||||
String algoTxt; |
||||
algoTxt << (alg+1); |
||||
g.drawText(algoTxt, 5, 1, 21, 14, Justification::left, true); |
||||
} |
||||
|
||||
void AlgoDisplay::drawOp(Graphics &g, int x, int y, int num) { |
||||
String txt; |
||||
txt << abs(num); |
||||
|
||||
int offx = 24; |
||||
int offy = 17; |
||||
|
||||
g.setColour(Colour(0xFF0FC00F)); |
||||
g.fillRect(x*offx+4, y*offy+3, offx-2, offy-1); |
||||
g.setColour(Colour(0xFFFFFFFF)); |
||||
g.drawText(txt, x*offx+3, y*offy+2, offx+2, offy+2, Justification::centred, true); |
||||
if ( num < 0 ) { |
||||
g.setColour(Colour(0xFFFFFFFF)); |
||||
int x1 = (x*offx) + 24; |
||||
g.drawLine(x1+1, y*offy+3, x1+1, y*offy+offy+2, 3); |
||||
void AlgoDisplay::paint(Graphics &g) { |
||||
|
||||
switch(*algo) { |
||||
case 0: |
||||
displayOp(g, 6, 3, 0, 0, 1); |
||||
displayOp(g, 5, 3, 1, 0, 0); |
||||
displayOp(g, 4, 3, 2, 0, 0); |
||||
displayOp(g, 3, 3, 3, 2, 0); |
||||
displayOp(g, 2, 2, 2, 0, 0); |
||||
displayOp(g, 1, 2, 3, 1, 0); |
||||
break; |
||||
case 1: |
||||
displayOp(g, 6, 3, 0, 0, 0); |
||||
displayOp(g, 5, 3, 1, 0, 0); |
||||
displayOp(g, 4, 3, 2, 0, 0); |
||||
displayOp(g, 3, 3, 3, 2, 0); |
||||
displayOp(g, 2, 2, 2, 0, 1); |
||||
displayOp(g, 1, 2, 3, 1, 0); |
||||
break; |
||||
|
||||
case 2: |
||||
displayOp(g, 6, 3, 1, 0, 1); |
||||
displayOp(g, 5, 3, 2, 0, 0); |
||||
displayOp(g, 4, 3, 3, 2, 0); |
||||
displayOp(g, 3, 2, 1, 0, 0); |
||||
displayOp(g, 2, 2, 2, 0, 0); |
||||
displayOp(g, 1, 2, 3, 1, 0);
|
||||
break; |
||||
case 3: //
|
||||
displayOp(g, 6, 3, 1, 0, 0); |
||||
displayOp(g, 5, 3, 2, 0, 0); |
||||
displayOp(g, 4, 3, 3, 2, 0); |
||||
displayOp(g, 3, 2, 1, 0, 0); |
||||
displayOp(g, 2, 2, 2, 0, 0); |
||||
displayOp(g, 1, 2, 3, 1, 0);
|
||||
break; |
||||
|
||||
case 4: |
||||
displayOp(g, 6, 3, 2, 0, 1); |
||||
displayOp(g, 5, 3, 3, 2, 0); |
||||
displayOp(g, 4, 2, 2, 0, 0); |
||||
displayOp(g, 3, 2, 3, 3, 0); |
||||
displayOp(g, 2, 1, 2, 0, 0); |
||||
displayOp(g, 1, 1, 3, 1, 0);
|
||||
break; |
||||
case 5: //
|
||||
displayOp(g, 6, 3, 2, 0, 0); |
||||
displayOp(g, 5, 3, 3, 2, 0); |
||||
displayOp(g, 4, 2, 2, 0, 0); |
||||
displayOp(g, 3, 2, 3, 3, 0); |
||||
displayOp(g, 2, 1, 2, 0, 0); |
||||
displayOp(g, 1, 1, 3, 1, 0);
|
||||
break; |
||||
|
||||
case 6: |
||||
displayOp(g, 6, 3, 1, 0, 1); |
||||
displayOp(g, 5, 3, 2, 2, 0); |
||||
displayOp(g, 4, 2, 2, 0, 0); |
||||
displayOp(g, 3, 2, 3, 2, 0); |
||||
displayOp(g, 2, 1, 2, 0, 0); |
||||
displayOp(g, 1, 1, 3, 1, 0); |
||||
break; |
||||
case 7:
|
||||
displayOp(g, 6, 3, 1, 0, 0); |
||||
displayOp(g, 5, 3, 2, 2, 0); |
||||
displayOp(g, 4, 2, 2, 0, 1); |
||||
displayOp(g, 3, 2, 3, 2, 0); |
||||
displayOp(g, 2, 1, 2, 0, 0); |
||||
displayOp(g, 1, 1, 3, 1, 0); |
||||
break; |
||||
case 8:
|
||||
displayOp(g, 6, 3, 1, 0, 0); |
||||
displayOp(g, 5, 3, 2, 2, 0); |
||||
displayOp(g, 4, 2, 2, 0, 0); |
||||
displayOp(g, 3, 2, 3, 2, 0); |
||||
displayOp(g, 2, 1, 2, 0, 1); |
||||
displayOp(g, 1, 1, 3, 1, 0); |
||||
break; |
||||
|
||||
case 9:
|
||||
displayOp(g, 6, 2, 2, 0, 0); |
||||
displayOp(g, 5, 1, 2, 1, 0); |
||||
displayOp(g, 4, 2, 3, 1, 0); |
||||
displayOp(g, 3, 3, 1, 0, 1); |
||||
displayOp(g, 2, 3, 2, 2, 0); |
||||
displayOp(g, 1, 3, 3, 2, 0); |
||||
break; |
||||
case 10:
|
||||
displayOp(g, 6, 2, 2, 0, 1); |
||||
displayOp(g, 5, 1, 2, 1, 0); |
||||
displayOp(g, 4, 2, 3, 1, 0); |
||||
displayOp(g, 3, 3, 1, 0, 0); |
||||
displayOp(g, 2, 3, 2, 2, 0); |
||||
displayOp(g, 1, 3, 3, 2, 0); |
||||
break; |
||||
|
||||
case 11:
|
||||
displayOp(g, 6, 2, 2, 0, 1); |
||||
displayOp(g, 5, 1, 2, 1, 0); |
||||
displayOp(g, 4, 0, 2, 1, 0); |
||||
displayOp(g, 3, 1, 3, 1, 0); |
||||
displayOp(g, 2, 3, 2, 0, 0); |
||||
displayOp(g, 1, 3, 3, 2, 0); |
||||
break; |
||||
|
||||
case 12:
|
||||
displayOp(g, 6, 2, 2, 0, 0); |
||||
displayOp(g, 5, 1, 2, 1, 0); |
||||
displayOp(g, 4, 0, 2, 1, 0); |
||||
displayOp(g, 3, 1, 3, 1, 0); |
||||
displayOp(g, 2, 3, 2, 0, 0); |
||||
displayOp(g, 1, 3, 3, 2, 0); |
||||
break; |
||||
|
||||
case 13: |
||||
displayOp(g, 6, 3, 1, 0, 1); |
||||
displayOp(g, 5, 3, 2, 1, 0); |
||||
displayOp(g, 4, 3, 3, 2, 0); |
||||
displayOp(g, 3, 2, 1, 0, 0); |
||||
displayOp(g, 2, 2, 2, 0, 0); |
||||
displayOp(g, 1, 2, 3, 1, 0);
|
||||
break; |
||||
case 14:
|
||||
displayOp(g, 6, 3, 1, 0, 0); |
||||
displayOp(g, 5, 3, 2, 1, 0); |
||||
displayOp(g, 4, 3, 3, 2, 0); |
||||
displayOp(g, 3, 2, 1, 0, 0); |
||||
displayOp(g, 2, 2, 2, 0, 0); |
||||
displayOp(g, 1, 2, 3, 1, 0);
|
||||
break; |
||||
|
||||
case 30: |
||||
displayOp(g, 6, 4, 2, 0, 1); |
||||
displayOp(g, 5, 4, 3, 2, 0); |
||||
displayOp(g, 4, 3, 3, 3, 0); |
||||
displayOp(g, 3, 2, 3, 3, 0); |
||||
displayOp(g, 2, 1, 3, 3, 0); |
||||
displayOp(g, 1, 0, 3, 1, 0);
|
||||
break; |
||||
case 31: |
||||
displayOp(g, 6, 5, 3, 2, 1); |
||||
displayOp(g, 5, 4, 3, 3, 0); |
||||
displayOp(g, 4, 3, 3, 3, 0); |
||||
displayOp(g, 3, 2, 3, 3, 0); |
||||
displayOp(g, 2, 1, 3, 3, 0); |
||||
displayOp(g, 1, 0, 3, 1, 0);
|
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
|