PDA

View Full Version : Zooming in but not out



nitriles
5th October 2007, 09:12
I have i graph in which i can succesfully zoom (left mouse button) but when i want to zoom out (right mouse button) i get a whole new graph plot and my previous graph is gone. Like it replots a graph on top of it.
This is my code:


class GraphPlot(Qwt.QwtPlot):

def __init__(self, *args):
Qwt.QwtPlot.__init__(self, *args)
#self.plot = Qwt.QwtPlot(self)

# make a QwtPlot widget
self.setTitle("Graph Plot")
#self.__initTracking()
self.__initZooming()
...
...
def __initZooming(self):
self.replot()
self.zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom,
Qwt.QwtPlot.yLeft,
Qwt.QwtPicker.DragSelection,
Qwt.QwtPicker.AlwaysOff,
self.canvas())
self.zoomer.setRubberBandPen(qt.QPen(qt.Qt.black))
self.replot()

#end __initZooming


thanks a lot!

nitriles
5th October 2007, 09:54
Wohoo i fixed it, never mind!
dont place it in the class, place it here:



def main(args):
app = qt.QApplication(args)
demo = make()
app.setMainWidget(demo)

zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom,
Qwt.QwtPlot.yLeft,
Qwt.QwtPicker.DragSelection,
Qwt.QwtPicker.AlwaysOff,
demo.canvas())
zoomer.setRubberBandPen(qt.QPen(qt.Qt.green))
picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom,
Qwt.QwtPlot.yLeft,
Qwt.QwtPicker.NoSelection,
Qwt.QwtPlotPicker.CrossRubberBand,
Qwt.QwtPicker.AlwaysOn,
demo.canvas())
picker.setTrackerPen(qt.QPen(qt.Qt.red))

sys.exit(app.exec_loop())

# main()