On 22/05/14 21:03, Jens Steinhauser wrote:
> ---
> pv/mainwindow.cpp | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp
> index 95d2d56..b6f2706 100644
> --- a/pv/mainwindow.cpp
> +++ b/pv/mainwindow.cpp
> @@ -44,6 +44,7 @@
>
> #include "devicemanager.h"
> #include "device/device.h"
> +#include "device/file.h"
> #include "dialogs/about.h"
> #include "dialogs/connect.h"
> #include "dialogs/storeprogress.h"
> @@ -62,6 +63,7 @@
> #include <glib.h>
> #include <libsigrok/libsigrok.h>
>
> +using boost::dynamic_pointer_cast;
> using boost::shared_ptr;
> using std::list;
>
> @@ -473,7 +475,19 @@ void MainWindow::run_stop()
>
> void MainWindow::capture_state_changed(int state)
> {
> - _sampling_bar->set_capture_state((pv::SigSession::capture_state)state);
> + pv::SigSession::capture_state s = (pv::SigSession::capture_state)state;
> +
> + _sampling_bar->set_capture_state(s);
> +
> + // Zoom fit if we opened a capture file
> + //
> + // It would be better to set the zoom level before loading the file,
> + // but until that is possible this does the job (see bug #236).
> + if (pv::SigSession::Stopped == s) {
> + if
> (dynamic_pointer_cast<pv::device::File>(_session.get_device())) {
> + _view->zoom_fit();
> + }
> + }
> }
>
> } // namespace pv
>
The problem with this is that it resizes the screen every time you
reload the file by clicking "Run". This will be more important for the
FPGA Simulation VCD file use case. In this case you might be zoomed in
on some detail, and then reloading will take you back to the global
view. Als we might want to use inotify to detect when the file gets
rewritten by the simulator, or even just if the user presses "Run" to do
the reload manually.
We really only want it to auto scale the first load.
I think the best solution may be to define a new signal handler slot in
MainWindow: "on_file_first_loaded" or similar. Then connect this signal
when MainWindow::load_file is called, and disconnect the signal when
MainWindow::on_file_first_loaded first triggers. This way you get a
single event notification when the file is first loaded, and you can set
the zoom in there.
Doing it this way means there's no need for an extra boolean member
variable to indicate whether we're doing the first load, and it also
means there's no need for dynamic_pointer_cast.
The only problem with this is that I'm not sure what the best thing to
trigger this signal would be. It could be triggered in
MainWindow::capture_state_changed, but we'd still need a
dynamic_pointer_cast in the case.
Joel
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel