Hi Nathan,
nscott@xxxxxxxxxx wrote:
>> Regarding the horizontal splitting, you're close to it ;-) I've a
>> working prototype that load a row option for each chart and load it to a
>> corresponding horizontal QSplitter that is child of the vertical
>> splitter. This let user split each row by an arbitrary number. Chart
>> addition/deletion is now working great. The row is actually a number,
>> but I'll try to make it text to simplify usage and loading of multiple
>> views.
>>
>> I've not worked on the time axis for the moment.
>>
>
> Hmm. It does seem to me that vertical-inside-of-horizontal is a better way
> to go than horizontal-inside-of-vertical ... but it will be good to have a
> look
> at your prototype and try it out, as its much easier to get a feel for
> these sort
> of things when you can interact with the thing.
>
Well actually the design is an array of horizontal qsplitters inside a
vertical qsplitter. This enable to split rows differently, but becomes
more tricky regarding the timeline...
If we have 4 rows with different number of graphs, should I add 4 rows
of timelines at the bottom? This seems not practical.
I will try with grids...
Attached, a patch that add a label containing value and time at the
pointer when a graph is clicked. The label is below the timeline.
Bye
Olivier
diff --git a/src/chart/chart.cpp b/src/chart/chart.cpp
index c5f8b08..d8394cc 100644
--- a/src/chart/chart.cpp
+++ b/src/chart/chart.cpp
@@ -948,14 +948,20 @@ void Chart::setYAxisTitle(char *p)
void Chart::selected(const QwtDoublePoint &p)
{
console->post("Chart::selected chart=%p x=%f y=%f",
- this, (float)p.x(), (float)p.y());
+ this, p.x(), p.y());
my.tab->setCurrent(this);
+ QString string;
+ string.sprintf("Value: %.2f %s at %s", (float)p.y(),
pmUnitsStr(&my.units), timeHiResString(p.x()));
+ kmchart->chartValueLabel->setText(string);
}
void Chart::moved(const QwtDoublePoint &p)
{
- console->post("Chart::moved chart=%p x=%f y=%f",
- this, (float)p.x(), (float)p.y());
+ console->post("Chart::moved chart=%p x=%f y=%f ",
+ this, p.x(), p.y() );
+ QString string;
+ string.sprintf("Value: %.2f %s at %s", (float)p.y(),
pmUnitsStr(&my.units), timeHiResString(p.x()));
+ kmchart->chartValueLabel->setText(string);
}
bool Chart::legendVisible()
diff --git a/src/chart/kmchart.cpp b/src/chart/kmchart.cpp
index f4902d8..8b5895a 100644
--- a/src/chart/kmchart.cpp
+++ b/src/chart/kmchart.cpp
@@ -71,6 +71,7 @@ KmChart::KmChart() : QMainWindow(NULL)
setIconSize(QSize(22, 22));
dateLabel->setFont(globalFont);
+ chartValueLabel->setFont(globalFont);
}
void KmChart::languageChange()
diff --git a/src/chart/kmchart.ui b/src/chart/kmchart.ui
index 47e80a5..e72abb1 100644
--- a/src/chart/kmchart.ui
+++ b/src/chart/kmchart.ui
@@ -168,6 +168,37 @@
</widget>
</item>
<item>
+ <layout class="QHBoxLayout" >
+ <property name="spacing" >
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="chartValueLabel" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QLabel" name="dateLabel" >
<property name="sizePolicy" >
<sizepolicy>
@@ -197,6 +228,8 @@
</layout>
</item>
</layout>
+ </item>
+ </layout>
</widget>
</item>
</layout>
diff --git a/src/chart/main.cpp b/src/chart/main.cpp
index 8fa39e0..7d80009 100644
--- a/src/chart/main.cpp
+++ b/src/chart/main.cpp
@@ -104,6 +104,21 @@ char *timeString(double seconds)
return s;
}
+// return a string containing hour and milliseconds
+char *timeHiResString(double time)
+{
+ static char s[16];
+ char m[8];
+ time_t secs = (time_t)time;
+ struct tm *t;
+
+ sprintf(m, "%.3f", time - floor(time));
+ t = localtime(&secs);
+ sprintf(s, "%02d:%02d:%02d.%s", t->tm_hour, t->tm_min, t->tm_sec, m+2);
+ s[strlen(s)-1] = '\0';
+ return s;
+}
+
double KmTime::secondsToUnits(double value, KmTime::DeltaUnits units)
{
switch (units) {
diff --git a/src/chart/main.h b/src/chart/main.h
index 0d2df57..dc75b2f 100644
--- a/src/chart/main.h
+++ b/src/chart/main.h
@@ -82,7 +82,7 @@ extern double tosec(struct timeval);
extern double torange(struct timeval, int);
extern void fromsec(double, struct timeval *);
extern char *timeString(double);
-
+extern char *timeHiResString(double);
extern void nomem(void);
#endif // MAIN_H
|