soft001
soft001

Reputation: 58

Show logo in axis without image - Matlab

How it can be possible to display this logo on this graphical User Interface without using the functions of displaying images and without a jpg file, ... !!!

Download this GUI here.

Thank you

Upvotes: 1

Views: 354

Answers (2)

il_raffa
il_raffa

Reputation: 5190

In short:

it could be that the logo has been manually added after the creation of the GUI and without using the guide that, instead, seems the tool, used to create the whole GUI.

In details:

To show an image in a GUI it is necessary to first add an axes in the GUI to which then, to attach the image by using the imshow function.

In the case of a "logo", that is supposed to be diplayed as the GUI opens and not to be modified during the execution of the GUI, a possibility could be to insert the following code:

imshow('my_logo_image.jpg')

in the GUI's OpeningFcn which is executes just before hweufhef is made visible.

Looking at the .m file of your GUI unfortunately this is not the case.

It is difficult to understand how the whole GUI and in particular the logo have been built, nevertheless, some considerations can be made about the GUI.

Opening the GUI with the guide tool this is how it appears:

enter image description here

You can notice an axes in the lower left corner, this is the place in which the logo appears.

So far so good.

Now, double click on the axes to open the Property Inspector: you will notice something strange: the tag property of the axes is empty.

This is strange, because, guide automatically define a default Tag property for each item is added.

Now, AFTER HAVING MADE A BACKUP COPY OF THE GUI

  • double click on any point of the GUI not containing any uicontrol, this will open the Property Inspector for the Figure
  • go to the HandleVisibility property and set it to on
  • save the GUI
  • close the GUIDE tool

Now run the GUI form the CommandWindow (fsolveGUI) and then, again in the CommandWindow run the following:

gui_handels=guidata(gcf)

The function guidata will return the handels of the object in the GUI.

This is the output:

gui_handels = 

    figure1: [1x1 Figure]
      edit1: [1x1 UIControl]
 Untitled_1: [1x1 Menu]
     text11: [1x1 UIControl]
 Untitled_2: [1x1 Menu]
       File: [1x1 Menu]
pushbutton1: [1x1 UIControl]
      edit3: [1x1 UIControl]
      text8: [1x1 UIControl]
      text7: [1x1 UIControl]
      text3: [1x1 UIControl]
      edit2: [1x1 UIControl]
      text1: [1x1 UIControl]
     copyto: [1x1 Menu]
  pastefrom: [1x1 Menu]
      mfile: [1x1 Menu]
openResults: [1x1 Menu]
SaveResults: [1x1 Menu]
 loadeqfile: [1x1 Menu]
     output: [1x1 Figure]

You will notice something strange:

  • the GUI contains an axes
  • its property HandleVisibility is on (you can check it using guide)
  • nevertheless, it is not present in the list of the handles returned by guidata

You can get the handle of this misterious axes with this command:

logo_ax_handle=findobj(gcf,'type','axes')

now get access to the data plotted in the axes with this command

axes_data=logo_ax_handle.Children.CData;         

you will get a 54x192x3 unit8 matrix that is, actually the Logo.

You can verify it as follows:

figure
axes
imshow(axes_data)

Considering all this strannge thisngs, a possible answer to your question can be:

  • the GUI has been created without the axes and with the figure's HandleVisibilit on
  • an axes has been manually added to the GUI whithout using the guide tool
  • an image, the Logo, has been added to the axes
  • the GUI has been saved with the savefig function
  • the GUI has been opened with guide
  • the HandleVisibility properety of the figure has been set to callback

You can test this possibility as follows:

  • with guidem, create a GUI with, for example, just a pushbutton and an editbox, just to have "something" inside
  • set the HandleVisibility properety fo the figure to on
  • save the GUI (in the below example I've call it add_axes_manually and close guide

Then run the following code, e. g. from a script (Change the name of the image)

add_axes_manually
guidata(gcf)
axes('unit','normalized','position',[0.08 0.4 0.3 0.3])
imshow('Jupiter_New_Horizons.jpg')
savefig('add_axes_manually.fig')
add_axes_manually
guidata(gcf)

From the output of the two calls to guidata you will notice that:

  • the handle of the axes is not diplayd
  • the GUI now contains a Logo (a picture)
  • the Logo is embedded in the GUI so, apparently, there are neither a .jpeg file nor code to insert the logo in the .m file

The fact that the GUI has been saved "outside" the guide tool seems supported by the fact that when you open it, some equation are displayed, while they are not present in the .m file of the GUI.

Hope this helps,

Qapla'

Upvotes: 1

Rody Oldenhuis
Rody Oldenhuis

Reputation: 38032

There are basically two ways to construct GUIs in MATLAB:

  1. With GUIDE
  2. Programmatically

GUIDE allows you to create and position uicontrols and other objects in a graphical way. When the GUI is then deployed, GUIDE generates functions for the uicontrol callbacks in an M-file, and a FIG file to contain all the data for all the uicontrols and other graphics objects you may have included in the GUI. Use this for GUIs with simple lay-out and simple uicontol behavior (read: most GUIs you will ever create)

When doing things programmatically, you have to do everything yourself -- uicontrol positioning, callbacks, logo positioning and display, everything. There is no FIG file to help you (normally), only M files you wrote. Use this if you want/need absolute control over the uicontrol behaviors, multiple sub-GUIs, tabs, complex interactions between MATLAB and uicontrols, and whatnot. Much harder to do, but it gives you absolute control.

The GUI you linked to is apparently created with GUIDE. The PNG/JPG/whatever is embedded in the FIG file.

Upvotes: 0

Related Questions