invesalius / invesalius3

3D medical imaging reconstruction software
https://invesalius.github.io/
GNU General Public License v2.0
629 stars 287 forks source link

windows version, after import, panels not refresh #172

Closed mit10000 closed 5 years ago

mit10000 commented 5 years ago

First thanks for sharing! I follow steps here https://github.com/invesalius/invesalius3/wiki/Running-InVesalius-3-in-Windows

used: python3.7 Visual Studio (2017 community edition) the most recent commit

After run python app.py, everything was ok. I can open DICOM, after click "import", the 4 panels show up, but without images. I have to use mouse to click the scroll to make the panel show images.

The same commit on Ubuntu works fine and does not have this issue.

Could you please help on this ? Thanks.

tfmoraes commented 5 years ago

Thanks for the report. We know this problem is happening in windows with some gpus.. what is your?

mit10000 commented 5 years ago

Thanks for reply. My machine only have CPU, no GPU. CPU: Intel Core i5-3470 CPU @3.20G Hz

video card:

Display Devices

       Card name: Intel(R) HD Graphics
    Manufacturer: Intel Corporation
       Chip type: Intel(R) HD Graphics Family
vhosouza commented 5 years ago

Hi Thiago, I have a very similar problem, but in my case only the 3D panel does not show any surface after I create it using a certain mask. I don't have GPU, it's also an Intel HD Graphics. My specs are also similar to @mit10000 . Do you know what could be causing it?

tfmoraes commented 5 years ago

Hi @vhosouza , but the surface appears after you change the camera? I don't know what is causing this yet ... Try to update your driver using something like the Drive Booster.

mit10000 commented 5 years ago

@tfmoraes Thanks for you reply. I tried to figure out what caused the problem, and encounter a very confusing question, could you please help?

In order to debug, I try to do a very simple test: after "Import DICOM files", the bottom show Cancel Import Keep all slices Then click "Import", then we get the Axial slice, Coronal slice, Sagittal slice, Volumne

Here I try to simply display an image on the "Volume" window, and could never make it work.

Seems the "Volume" is an instance of VolumeViewerCover, which contains VolumeInteraction and VolumeToolPanel. and VolumeInteraction contains a p1, which is an instance of Viewer. What I did is: in file gui/default_viewers.py class VolumeInteraction(wx.Panel): function def __init_aui_manager(self): after: self.s1 = s1

add 2 sentences:

bmp= wx.StaticBitmap(p1, wx.ID_ANY,wx.Bitmap("xxx.jpg", wx.BITMAP_TYPE_ANY)) bmp.SetPosition((300, 300))

the 1st sentence just get a StaticBItmap from an image xxx.jpg for p1, and the 2nd sentence set the position. But the xxx,jpg image never show up on the Voume window.

Could you please help me? Thanks.

tfmoraes commented 5 years ago

I don't know if I've understood you correctly. You wan to display an image in the volume viewer? I tried to do that. The VTK renderer stays above the bitmap. If you remove the VTK renderer (interactor) from volume viewer the bitmap will be shown correctly. I think it's better to use VTK to show the image you want. You may also add CanvasRendererCTX inside the volume viewer and add a method to draw an image in it.

mit10000 commented 5 years ago

@tfmoraes Thanks for you reply, I roughly understand how to do that now. Please forgive me if I bother you too much. Now I try to draw a line on sagittal slice window, after user click Import. I use a similar way in https://vtk.org/Wiki/VTK/Examples/Python/DottedLine

What I did is: In file viewer_slice.py class Viewer(wx.Panel) add a function:

def __build_a_line(self):
    renderer = self.slice_data.overlay_renderer

    Line=vtk.vtkLineSource()
    Line.SetPoint1(-50,0,0)
    Line.SetPoint2(50,0,0)
    Line.SetResolution(100)
    self.oneline=Line

    Mapper=vtk.vtkPolyDataMapper()
    Mapper.SetInputConnection(Line.GetOutputPort())

    line_Actor=vtk.vtkActor()
    line_Actor.SetMapper(Mapper)

    line_Actor.GetProperty().SetColor(1,1,0)
    line_Actor.GetProperty().SetLineStipplePattern(0xf0f0)
    line_Actor.GetProperty().SetLineStippleRepeatFactor(1)
    line_Actor.GetProperty().SetPointSize(1)
    line_Actor.GetProperty().SetLineWidth(1.5)

    self.line_Actor = line_Actor
    renderer.AddActor(line_Actor)

Then in this function, at the end add 2 lines

def SetInput(self, mask_dict): .... self.SetInteractorStyle(const.STATE_DEFAULT) self.__build_a_line() self.line_Actor.SetVisibility(1)

By adding the line to the self.slice_data.overlay_renderer, and set Visibility to 1, I expect the Axial/Sagital/Coronal window should show a line, but nothing showed up.

Could you please help me what part was wrong? Thanks!

tfmoraes commented 5 years ago

Hi @mit10000 , I'd recommend you to use CanvasRendererCTX to draw line and other geometrical elements. I think it's simpler. Just create a new class with a method called draw_to_canvas (see measures.py). There you use just need to use the method draw_line from CanvasRendererCTX. Maybe you'll need to calculate the 2D position from 3D (just see measures.py). Then you just add the object from the class you created in the list self.canvas.draw_list from viewer_slice.

tfmoraes commented 5 years ago

@mit10000, the last commit should fix the problem. Please, could you test it?

mit10000 commented 5 years ago

@tfmoraes Just tested, the new commit works like a charm!!! Thanks for your wonderful work!!!

mit10000 commented 5 years ago

Hi @mit10000 , I'd recommend you to use CanvasRendererCTX to draw line and other geometrical elements. I think it's simpler. Just create a new class with a method called draw_to_canvas (see measures.py). There you use just need to use the method draw_line from CanvasRendererCTX. Maybe you'll need to calculate the 2D position from 3D (just see measures.py). Then you just add the object from the class you created in the list self.canvas.draw_list from viewer_slice.

@tfmoraes Based on your instruction, I can draw a line now. Appreciate your prompt and efficient help!