Hi all,
I have a ETO UI with a viewportControl. I need the viewportControl camera to be set programatically, similar to rhino’s savedView user experience…
I managed to set the viewportControl’s viewport’s camera (location, direction and lens values) but I can’t figure out how I can refresh the viewport. In other projects I have used the RhinoView’s Redraw() method, but since I’m working with viewportControl, there is no RhinoView for “redrawing”.
How can I “refresh” or “redraw” the viewport of a viewportControl?
def onRestoreItemClick(self,sender,e):
try:
selectedIndex = self.viewListBox.SelectedIndex
selectedView = self.viewModel.views[selectedIndex]
self.vp.Viewport.SetCameraLocation(selectedView.location,False)
self.vp.Viewport.SetCameraDirection(selectedView.direction,False)
self.vp.Viewport.Camera35mmLensLength = seletectedView.lens
self.vp.Refresh() #NO LUCK WITH REFRESH...THIS IS NO REDRAWING NOTHING
except Exception as e:
Rhino.RhinoApp.WriteLine(str(e))
thanks @stevebaer, UTO’s control class also have a Invalidate method, not sure is its function is the same as winforms, they certainly “look similar”
ETO: Invalidate(): Queues a repaint of the entire control on the screen and any of its children.
WINFORMS: Invalidate(): invalidates a specific region of the control and causes a paint message to be sent to the control.
Anyway, I tried Invalidate() but no success. I need to slightly move the camera by hand to see the restored camera position. I tried invalidating the MainForm and also invalidating the viewportControl itself without luck
No, unfortunately “viewportControl” is not child of RhinoView at the contrary of the “regular” viewport, so Redraw() method doesn’t apply it that case…
Efectively your code is working fine also here, so the problem seem to be in my code. Sorry, for not taken the time to make more test myself, like you did.
I’m using a tablelayout and the viewportControl is inside a Cell. Don’t know, but maybe is related with the fact that Invalidate() is not working in my code?
Hi @aitorleceta, i can repeat that here with a TableLayout. Somehow i have different problems when Controls are put into various containers. Eg. if i have a Eto.Forms.GridView having GridLines enabled, the lines appear as they should. As soon as i put this GridView into a Splitter, the thickness of the GridLines is more than doubled.
I hope @curtisw is reading this and can shed some light…