taurus-org / taurus

Moved to https://gitlab.com/taurus-org/taurus
http://taurus-scada.org
43 stars 46 forks source link

Static image on TaurusWidget #1076

Closed Alexandre31415 closed 4 years ago

Alexandre31415 commented 4 years ago

Hello,

I have create an interface of TaurusWidget and i would like to add a static image (comming from a TaurusImageDialog) I can't find any solution to do it with another TaurusImageDialog, or other stuff. The only constrain is that i have to plot the static image in the same window than the TaurusImageDialog.

Is there a solution ?

Have a nice day, Alexandre

cpascual commented 4 years ago

Hi @Alexandre31415 , I am not sure of understanding what you want to do.

As far as I understand, you want to show two images side-to-side. One image is the value of a taurus Attribute and the other is static data. and now... which of the following is the case?

a) you want the 2 images shown in the same plot area of a single TaurusImage dialog b) you want one widget containing 2 TaurusImageDialog widgets, each showing one of the images c) none of the above and I missed the point completely ;)

Alexandre31415 commented 4 years ago

Hello,

Basically what i would like to do is case b) And my issue is only to showing the static data, everything else is go.

Thanks for you response, have a nice day, Alexandre.

cpascual commented 4 years ago

Basically what i would like to do is case b)

In that case, you just need to use the TaurusImageDialog as you would use a pure guiqwt.ImageDialog (i.e., not using the setModel API, but just adding an guiqwt.ImageItem). In fact, if you want, you could use a pure guiqwt.ImageDialoginstead of the TaurusImageDialog).

cpascual commented 4 years ago

As an example, you can use this snippet for showing an static image with TaurusImageDialog:

from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.extra_guiqwt import TaurusImageDialog
from guiqwt.image import ImageItem
import numpy

if __name__ == '__main__':
    import sys
    app = TaurusApplication(cmd_line_parser=None)

    w = TaurusImageDialog()

    img = ImageItem(numpy.arange(300*400).reshape((300, 400)))

    w.get_plot().add_item(img)

    w.show()
    sys.exit(app.exec_())
cpascual commented 4 years ago

Finally, just a comment: you can also use pyqtgraph instead of guiqwt:

In this case you would use pyqtgraph.PlotWidget widgets. For static data you would add a pyqtgraph.ImageItem and for taurus images you would use a taurus_pyqtgraph.TaurusImageItem.

See an example in https://github.com/taurus-org/taurus_pyqtgraph/blob/master/taurus_pyqtgraph/taurusimageitem.py

cpascual commented 4 years ago

Using pyqtgraph has the advantage that it makes it easier to e.g. link axes of two plots, or using subplots in the same widget...

See some inspiring examples of usage of pyqtgraph by doing: python3 -m pyqtgraph.examples

Alexandre31415 commented 4 years ago

Thanks for your help, it finally work has i wanted =) (i have use the solution)