Mercurial > hg > aimc
comparison src/Modules/Output/Graphics/GraphAxisSpec.cc @ 118:18237d55e346
- A few changes to get graphics working. In progress.
author | tom@acousticscale.org |
---|---|
date | Sat, 16 Oct 2010 22:27:03 +0000 |
parents | c5ac2f0c7fc5 |
children | a9cb396529c2 |
comparison
equal
deleted
inserted
replaced
117:c5ac2f0c7fc5 | 118:18237d55e346 |
---|---|
18 #include "Support/Common.h" | 18 #include "Support/Common.h" |
19 #include <string.h> | 19 #include <string.h> |
20 #include <stdio.h> | 20 #include <stdio.h> |
21 | 21 |
22 #include "Modules/Output/Graphics/GraphAxisSpec.h" | 22 #include "Modules/Output/Graphics/GraphAxisSpec.h" |
23 | |
24 namespace aimc { | |
23 | 25 |
24 GraphAxisSpec::GraphAxisSpec(float fMin, float fMax, Scale::ScaleType iScale) { | 26 GraphAxisSpec::GraphAxisSpec(float fMin, float fMax, Scale::ScaleType iScale) { |
25 m_pScale = NULL; | 27 m_pScale = NULL; |
26 m_sLabel = NULL; | 28 m_sLabel = NULL; |
27 SetDisplayRange(fMin, fMax); | 29 SetDisplayRange(fMin, fMax); |
48 } | 50 } |
49 | 51 |
50 void GraphAxisSpec::SetDisplayScale(Scale::ScaleType iScale) { | 52 void GraphAxisSpec::SetDisplayScale(Scale::ScaleType iScale) { |
51 DELETE_IF_NONNULL(m_pScale); | 53 DELETE_IF_NONNULL(m_pScale); |
52 m_pScale = Scale::Create(iScale); | 54 m_pScale = Scale::Create(iScale); |
53 aimASSERT(m_pScale); | 55 AIM_ASSERT(m_pScale); |
54 m_pScale->FromLinearScaledExtrema(m_fMin, m_fMax); | 56 m_pScale->FromLinearScaledExtrema(m_fMin, m_fMax); |
55 } | 57 } |
56 | 58 |
57 bool GraphAxisSpec::Initialize(Parameters *parameters, | 59 bool GraphAxisSpec::Initialize(Parameters *parameters, |
58 const char *sPrefix, | 60 const char *sPrefix, |
59 float fMin, | 61 float fMin, |
60 float fMax, | 62 float fMax, |
61 Scale::ScaleType iScale) { | 63 Scale::ScaleType iScale) { |
62 AIM_ASSERT(pParam); | 64 AIM_ASSERT(parameters); |
63 AIM_ASSERT(sPrefix && sPrefix[0]!='\0'); | 65 AIM_ASSERT(sPrefix && sPrefix[0]!='\0'); |
64 char sParamName[Parameters::MaxParamNameLength]; | 66 char sParamName[Parameters::MaxParamNameLength]; |
65 | 67 |
66 //! The following parameters are recognized for each axis: | 68 //! The following parameters are recognized for each axis: |
67 //! - \c "<prefix>.min", the minimum value; a float or \c 'auto' | 69 //! - \c "<prefix>.min", the minimum value; a float or \c 'auto' |
68 snprintf(sParamName, sizeof(sParamName)/sizeof(sParamName[0]), | 70 snprintf(sParamName, sizeof(sParamName)/sizeof(sParamName[0]), |
69 "%s.min", | 71 "%s.min", |
70 sPrefix); | 72 sPrefix); |
71 if (pParam->IsSet(sParamName)) { | 73 if (parameters->IsSet(sParamName)) { |
72 if (strcmp(parameters->GetString(sParamName), "auto") == 0) | 74 if (strcmp(parameters->GetString(sParamName), "auto") == 0) |
73 m_fMin = fMin; | 75 m_fMin = fMin; |
74 else | 76 else |
75 m_fMin = parameters->GetFloat(sParamName); | 77 m_fMin = parameters->GetFloat(sParamName); |
76 } | 78 } |
77 | 79 |
78 //! - \c "<prefix>.max", the maximum value; a float or \c 'auto' | 80 //! - \c "<prefix>.max", the maximum value; a float or \c 'auto' |
79 snprintf(sParamName, sizeof(sParamName)/sizeof(sParamName[0]), | 81 snprintf(sParamName, sizeof(sParamName)/sizeof(sParamName[0]), |
80 "%s.max", | 82 "%s.max", |
81 sPrefix); | 83 sPrefix); |
82 if (pParam->IsSet(sParamName)) { | 84 if (parameters->IsSet(sParamName)) { |
83 if (strcmp(parameters->GetString(sParamName), "auto")==0) | 85 if (strcmp(parameters->GetString(sParamName), "auto")==0) |
84 m_fMax = fMax; | 86 m_fMax = fMax; |
85 else | 87 else |
86 m_fMax = parameters->GetFloat(sParamName); | 88 m_fMax = parameters->GetFloat(sParamName); |
87 } | 89 } |
92 //! - \c "<prefix>.scale", the scale; one of \c 'auto', | 94 //! - \c "<prefix>.scale", the scale; one of \c 'auto', |
93 //! \c 'linear', \c 'erb' or \c 'log' | 95 //! \c 'linear', \c 'erb' or \c 'log' |
94 snprintf(sParamName, sizeof(sParamName)/sizeof(sParamName[0]), | 96 snprintf(sParamName, sizeof(sParamName)/sizeof(sParamName[0]), |
95 "%s.scale", | 97 "%s.scale", |
96 sPrefix); | 98 sPrefix); |
97 if (pParam->IsSet(sParamName)) { | 99 if (parameters->IsSet(sParamName)) { |
98 // Scale change, we updated min/max values already so no need to | 100 // Scale change, we updated min/max values already so no need to |
99 Scale::ScaleType iThisScale; | 101 Scale::ScaleType iThisScale; |
100 const char *sVal = parameters->GetString(sParamName); | 102 const char *sVal = parameters->GetString(sParamName); |
101 if (strcmp(sVal, "auto")==0) | 103 if (strcmp(sVal, "auto")==0) |
102 iThisScale = iScale; | 104 iThisScale = iScale; |
105 else if (strcmp(sVal, "erb")==0) | 107 else if (strcmp(sVal, "erb")==0) |
106 iThisScale = Scale::SCALE_ERB; | 108 iThisScale = Scale::SCALE_ERB; |
107 else if (strcmp(sVal, "log")==0) | 109 else if (strcmp(sVal, "log")==0) |
108 iThisScale = Scale::SCALE_LOG; | 110 iThisScale = Scale::SCALE_LOG; |
109 else { | 111 else { |
110 AIM_ERROR(_T("Unrecognized scale type in parameter '%s': '%s'"), | 112 LOG_ERROR(_T("Unrecognized scale type in parameter '%s': '%s'"), |
111 sParamName, | 113 sParamName, |
112 sVal); | 114 sVal); |
113 return false; | 115 return false; |
114 } | 116 } |
115 SetDisplayScale(iThisScale); | 117 SetDisplayScale(iThisScale); |
122 if (parameters->IsSet(sParamName)) | 124 if (parameters->IsSet(sParamName)) |
123 m_sLabel = parameters->GetString(sParamName); // Assumes strings remains valid | 125 m_sLabel = parameters->GetString(sParamName); // Assumes strings remains valid |
124 | 126 |
125 return true; | 127 return true; |
126 } | 128 } |
129 } // namespace aimc |