MoI discussion forum
MoI discussion forum

Full Version: Iso view

From: mattj (MATTJENN)
15 Nov 2017   [#1]
Hi All

I currently have and isometric view short cut key set up:

script:var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.projection = 'Parallel'; vp.setAngles( 90 - (Math.asin(Math.tan(30 * Math.PI/180)) * 180/Math.PI), 45 );

However I want to set some more short cuts up so I can view in isomentric from other view points without having to rotate the whole assembly. I copied this code from the resource website so i have no clue what the numbers do to achieve this.

It would be nice in the future to have a few more view icons along the bottom which put the 3D window into predefined 3D view iso front, iso back, iso lower etc.

Matt
From: Michael Gibson
15 Nov 2017   [#2] In reply to [#1]
Hi Matt, so the original post with the isometric setup is here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=1917.35

To set up different ones, you might try using Options > View > "3D view angles" which will pop up a dialog that lets you set view angles, similar to Spherical coordinates as described here:
https://en.wikipedia.org/wiki/Spherical_coordinate_system

The "Up down angle" will correspond to the Theta angle labeled in the wikipedia graphic and "Left right angle" will correspond to the rho angle for the eye point position. If you set up one with that dialog that you like, you can then make a shortcut key for it using this:

script: moi.ui.mainWindow.viewpanel.getViewport('3D').setAngles( updown, leftright, tilt );

Change the updown , leftright, and tilt to the numbers that you used in the dialog.

The angles will place the eye point relative to the current rotation pivot point, you can set the rotation pivot point to the center of a selected object by using "Reset" on the 3D viewport's bottom toolbar or to a specific point using the Zoom area button on that same toolbar.

Hope that helps, - Michael
From: mattj (MATTJENN)
16 Nov 2017   [#3] In reply to [#2]
hi micheal

Yes that helped, in the end i fiddled with the last number, (now 315) which rotates the point of view.

script:var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.projection = 'Parallel'; vp.setAngles( 90 - (Math.asin(Math.tan(30 * Math.PI/180)) * 180/Math.PI), 315 );

now i just need to set up 4 short cut keys to get all 4 viewing angles, or even better 4 small buttons in the view tab but that might be pushing it for me and my minuscule coding abilities!

regards

Matt
From: Michael Gibson
16 Nov 2017   [#4] In reply to [#3]
Hi matt, so for setting up buttons on the View tab in the side pane, you would need to edit the SidePane.htm file in a text editor like Notepad++ .

The existing view tab is this, do a find for "ViewTabContent":

code:
    <div id="ViewTabContent">
        <table>
            <tr>
                <td><moi:CommandButton icon="ViewReset.png" onclick="moi.view.resetAll();"><moi:Text textid="Reset all"/></moi:CommandButton></td>
                <td><moi:CommandButton icon="icons/ImageIcon.png" command="image"><moi:Text textid="Image"/></moi:CommandButton></td>
                <td><moi:CommandButton icon="icons/CPlaneIcon.png" onclick="if ( event.button == 2 ) { moi.view.resetCPlane(); } else { moi.view.setCPlaneInteractive(); }"><moi:Text textid="CPlane"/></moi:CommandButton></td>
            </tr>
            <tr>
                <td colspan="3" style="padding:0.1em 0.4em 0.2em 0.4em">
                    <moi:CheckButton style="text-align:left;" binding="value = moi.view.showHiddenLines"><moi:Text textid="Hidden lines checkbox"/></moi:CheckButton>
                </td>
            </tr>
        </table>
    </div>


So to add in a new row of buttons you'd need to add a new table row () and table cells (
) that have buttons in them (<moi:CommandButton). Which would look something like this - new lines added between the new stuff start and new stuff end markers and note the new stuff is added before the closing
:

code:
    <div id="ViewTabContent">
        <table>
            <tr>
                <td><moi:CommandButton icon="ViewReset.png" onclick="moi.view.resetAll();"><moi:Text textid="Reset all"/></moi:CommandButton></td>
                <td><moi:CommandButton icon="icons/ImageIcon.png" command="image"><moi:Text textid="Image"/></moi:CommandButton></td>
                <td><moi:CommandButton icon="icons/CPlaneIcon.png" onclick="if ( event.button == 2 ) { moi.view.resetCPlane(); } else { moi.view.setCPlaneInteractive(); }"><moi:Text textid="CPlane"/></moi:CommandButton></td>
            </tr>
            <tr>
                <td colspan="3" style="padding:0.1em 0.4em 0.2em 0.4em">
                    <moi:CheckButton style="text-align:left;" binding="value = moi.view.showHiddenLines"><moi:Text textid="Hidden lines checkbox"/></moi:CheckButton>
                </td>
            </tr>

            <!-- new stuff start -->
            <tr>
                <td><moi:CommandButton icon="SetView1.png" onclick="script:var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.projection = 'Parallel'; vp.setAngles( 90 - (Math.asin(Math.tan(30 * Math.PI/180)) * 180/Math.PI), 315 );">View1</moi:CommandButton></td>
                <td><moi:CommandButton icon="SetView2.png" onclick="script:var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.projection = 'Parallel'; vp.setAngles( 90 - (Math.asin(Math.tan(30 * Math.PI/180)) * 180/Math.PI), 315 );">View2</moi:CommandButton></td>
                <td><moi:CommandButton icon="SetView3.png" onclick="script:var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.projection = 'Parallel'; vp.setAngles( 90 - (Math.asin(Math.tan(30 * Math.PI/180)) * 180/Math.PI), 315 );">View3</moi:CommandButton></td>
                <td><moi:CommandButton icon="SetView4.png" onclick="script:var vp = moi.ui.mainWindow.viewpanel.getViewport('3D'); vp.projection = 'Parallel'; vp.setAngles( 90 - (Math.asin(Math.tan(30 * Math.PI/180)) * 180/Math.PI), 315 );">View4</moi:CommandButton></td>
            </tr>
            <!-- new stuff end -->

        </table>
    </div>


And also you'd need to add new images SetView1.png - SetView2.png in the icons folder if you want icons to show up there.

- Michael
From: mattj (MATTJENN)
16 Nov 2017   [#5] In reply to [#4]
Thanks! I will try
From: mattj (MATTJENN)
16 Nov 2017   [#6] In reply to [#4]
This worked perfectly :-)
When i update MOI will i lose the him changes?

Matt
From: Michael Gibson
16 Nov 2017   [#7] In reply to [#6]
Hi Matt, I'm glad that worked for you. Yes, when you get a new update it will come with the default SidePane.htm so you'll need to repeat this process again to get your customizations back. So you may want to keep a link to this thread so you can refer back to it then.

- Michael