8000 Trying out the new macos image from appveyor by adam-urbanczyk · Pull Request #101 · CadQuery/CQ-editor · GitHub
[go: up one dir, main page]

Skip to content

Trying out the new macos image from appveyor #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 35 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d312cae
Trying out the new macos image from appveyor
adam-urbanczyk Nov 26, 2019
1e11977
Do not use apt on macOS
adam-urbanczyk Nov 26, 2019
81cc2e2
Bash syntax fix
adam-urbanczyk Nov 26, 2019
3b2fb95
Try another syntax
adam-urbanczyk Nov 26, 2019
c165d71
Use curl i.s.o. wget
adam-urbanczyk Jan 9, 2020
a1d9aac
Donwload correct miniconda on mac
adam-urbanczyk Jan 9, 2020
ec38380
Different curl invocation
adam-urbanczyk Jan 9, 2020
c7494da
Try a different miniconda installer for mac
adam-urbanczyk Jan 14, 2020
5b27d5e
Trying different image
adam-urbanczyk Jan 14, 2020
2782012
Inspect backtrace on failures
adam-urbanczyk Jan 14, 2020
0a45cec
More backtrace related stuff
adam-urbanczyk Jan 14, 2020
31e3f41
Started working on an OCP widget
adam-urbanczyk Apr 11, 2020
ff05b3d
Basic mouse interaction
adam-urbanczyk Apr 11, 2020
4393bd7
OCCT widget simplification
adam-urbanczyk Apr 13, 2020
0ee7a42
Added graphical selection
adam-urbanczyk Apr 13, 2020
a381d43
Switched to OCP
adam-urbanczyk Apr 13, 2020
86c7725
Wireframe/shaded fix
adam-urbanczyk Apr 13, 2020
308c96a
Enable AA and simplify initialization
adam-urbanczyk Apr 19, 2020
4b1fe7b
Update requirements to use OCP
adam-urbanczyk Apr 20, 2020
9bcff28
Be verbose during testing
adam-urbanczyk Apr 20, 2020
88981bb
Try xvfb-run
adam-urbanczyk Apr 20, 2020
6f55884
Enable ssh on appveyor
adam-urbanczyk Apr 21, 2020
ff2bcbb
Enable AA differently
adam-urbanczyk Apr 22, 2020
266c2a8
More elaborate xvfb-run config
adam-urbanczyk Apr 22, 2020
2d97fb2
Disable ssh
adam-urbanczyk Apr 22, 2020
f7644ff
Enable RDP
adam-urbanczyk Apr 22, 2020
61e0d23
Fix platform name for win
adam-urbanczyk Apr 22, 2020
1305d7a
Merge branch 'OCP' into adam-urbanczyk-appveyor-macos
adam-urbanczyk Apr 23, 2020
ea84939
Enable ssh on failure
adam-urbanczyk Apr 23, 2020
f6d52ea
Enable only ssh
adam-urbanczyk Apr 23, 2020
44b8021
Use on_finish
adam-urbanczyk Apr 23, 2020
e10e8d7
configure ssh properly
adam-urbanczyk Apr 23, 2020
9408b24
URL fix
adam-urbanczyk Apr 23, 2020
921b64c
Go back to older miniconda for mac
adam-urbanczyk Apr 23, 2020
dbcd058
Enable ssh before testing
adam-urbanczyk Apr 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
shallow_clone: false

image:
- macOS-mojave
- macOS
- Ubuntu
- Ubuntu1804
- Visual Studio 2015
- Visual Studio 2015

environment:
matrix:
Expand All @@ -13,12 +15,12 @@ environment:
MINICONDA_DIRNAME: C:\FreshMiniconda

install:
- sh: sudo apt update
- sh: sudo apt -y --force-yes install libglu1-mesa xvfb libgl1-mesa-dri mesa-common-dev libglu1-mesa-dev
- sh: wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- sh: if [[ $APPVEYOR_BUILD_WORKER_IMAGE != "macOS"* ]]; then sudo apt update; sudo apt -y --force-yes install libglu1-mesa xvfb libgl1-mesa-dri mesa-common-dev libglu1-mesa-dev; fi
- sh: if [[ $APPVEYOR_BUILD_WORKER_IMAGE != "macOS"* ]]; then curl -o miniconda.sh curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; fi
- sh: if [[ $APPVEYOR_BUILD_WORKER_IMAGE == "macOS"* ]]; then curl -o miniconda.sh curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-4.7.10-MacOSX-x86_64.sh; fi
- sh: bash miniconda.sh -b -p $HOME/miniconda
- sh: source $HOME/miniconda/bin/activate
- cmd: appveyor DownloadFile https://repo.continuum.io/miniconda/Miniconda3-latest-Windows-x86_64.exe
- cmd: appveyor DownloadFile https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
- cmd: Miniconda3-latest-Windows-x86_64.exe /S /InstallationType=JustMe /D=%MINICONDA_DIRNAME%
- cmd: set "PATH=%MINICONDA_DIRNAME%;%MINICONDA_DIRNAME%\\Scripts;%PATH%"
- cmd: activate
Expand All @@ -30,18 +32,32 @@ install:
- cmd: activate cqgui
- conda list
- conda install -c conda-forge pytest=5.2.0 pluggy pytest-qt
- pip install pytest-xvfb pytest-mock pytest-cov pytest-repeat codecov pyvirtualdisplay==0.2.1
- pip install pytest-mock pytest-cov pytest-repeat codecov pyvirtualdisplay==0.2.1

build: false

before_test:
- ulimit -c unlimited -S
- sudo rm -f /cores/core.*

test_script:
- sh: export PYTHONPATH=$(pwd)
- cmd: set PYTHONPATH=%cd%
- pytest -s --cov=cq_editor
- sh: export APPVEYOR_SSH_BLOCK=true
- sh: curl -sflL 'https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-ssh.sh' | bash -e -
- sh: if [[ $APPVEYOR_BUILD_WORKER_IMAGE != "macOS"* ]]; then xvfb-run -s '-screen 0 1920x1080x24 +iglx' pytest -v --cov=cq_editor; fi
- sh: if [[ $APPVEYOR_BUILD_WORKER_IMAGE == "macOS"* ]]; then pytest -v --cov=cq_editor; fi
- cmd: pytest -v --cov=cq_editor

on_success:
- codecov

#on_finish:
#on_failure:
# - qtdiag
# - ls /cores/core.*
# - lldb --core `ls /cores/core.*` --batch --one-line "bt"

on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
# - sh: curl -sflL 'https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-ssh.sh' | bash -e -
# - sh: export APPVEYOR_SSH_BLOCK=true
- sh: curl -sflL 'https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-ssh.sh' | bash -e -
4 changes: 2 additions & 2 deletions cq_editor/cq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from imp import reload
from types import SimpleNamespace

from OCC.Core.AIS import AIS_ColoredShape
from OCC.Core.Quantity import \
from OCP.AIS import AIS_ColoredShape
from OCP.Quantity import \
Quantity_TOC_RGB as TOC_RGB, Quantity_Color

from PyQt5.QtGui import QColor
Expand Down
4 changes: 2 additions & 2 deletions cq_editor/widgets/cq_object_inspector.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAction
from PyQt5.QtCore import Qt, pyqtSlot, pyqtSignal

from OCC.Core.AIS import AIS_ColoredShape
from OCC.Core.gp import gp_Ax3
from OCP.AIS import AIS_ColoredShape
from OCP.gp import gp_Ax3

from cadquery import Vector

Expand Down
6 changes: 3 additions & 3 deletions cq_editor/widgets/object_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import cadquery as cq

from OCC.Core.AIS import AIS_Line
from OCC.Core.Geom import Geom_CylindricalSurface, Geom_Plane, Geom_Circle,\
from OCP.AIS import AIS_Line
from OCP.Geom import Geom_CylindricalSurface, Geom_Plane, Geom_Circle,\
Geom_TrimmedCurve, Geom_Axis1Placement, Geom_Axis2Placement, Geom_Line
from OCC.Core.gp import gp_Trsf, gp_Vec, gp_Ax3, gp_Dir, gp_Pnt, gp_Ax1
from OCP.gp import gp_Trsf, gp_Vec, gp_Ax3, gp_Dir, gp_Pnt, gp_Ax1

from ..mixins import ComponentMixin
from ..icons import icon
Expand Down
171 changes: 171 additions & 0 deletions cq_editor/widgets/occt_widget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
from sys import platform


from PyQt5.QtWidgets import QWidget, QApplication
from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt, QEvent

import OCP

from OCP.Aspect import Aspect_DisplayConnection, Aspect_TypeOfTriedronPosition
from OCP.OpenGl import OpenGl_GraphicDriver
from OCP.V3d import V3d_Viewer
from OCP.AIS import AIS_InteractiveContext, AIS_DisplayMode
from OCP.Quantity import Quantity_Color


ZOOM_STEP = 0.9


class OCCTWidget(QWidget):

sigObjectSelected = pyqtSignal(list)

def __init__(self,parent=None):

super(OCCTWidget,self).__init__(parent)

self.setAttribute(Qt.WA_NativeWindow)
self.setAttribute(Qt.WA_PaintOnScreen)
self.setAttribute(Qt.WA_NoSystemBackground)

self._initialized = False
self._needs_update = False

#OCCT secific things
self.display_connection = Aspect_DisplayConnection()
self.graphics_driver = OpenGl_GraphicDriver(self.display_connection)

self.viewer = V3d_Viewer(self.graphics_driver)
self.view = self.viewer.CreateView()
self.context = AIS_InteractiveContext(self.viewer)

#Trihedorn, lights, etc
self.prepare_display()

def prepare_display(self):

view = self.view

params = view.ChangeRenderingParams()
params.NbMsaaSamples = 8
params.IsAntialiasingEnabled = True

view.TriedronDisplay(
Aspect_TypeOfTriedronPosition.Aspect_TOTP_RIGHT_LOWER,
Quantity_Color(), 0.1)

viewer = self.viewer

viewer.SetDefaultLights()
viewer.SetLightOn()

ctx = self.context

ctx.SetDisplayMode(AIS_DisplayMode.AIS_Shaded, True)
ctx.DefaultDrawer().SetFaceBoundaryDraw(True)

def wheelEvent(self, event):

delta = event.angleDelta().y()
factor = ZOOM_STEP if delta<0 else 1/ZOOM_STEP

self.view.SetZoom(factor)

def mousePressEvent(self,event):

pos = event.pos()

A3E2
if event.button() == Qt.LeftButton:
self.view.StartRotation(pos.x(), pos.y())
elif event.button() == Qt.RightButton:
self.view.StartZoomAtPoint(pos.x(), pos.y())

self.old_pos = pos

def mouseMoveEvent(self,event):

pos = event.pos()
x,y = pos.x(),pos.y()

if event.buttons() == Qt.LeftButton:
self.view.Rotation(x,y)

elif event.buttons() == Qt.MiddleButton:
self.view.Pan(x - self.old_pos.x(),
self.old_pos.y() - y, theToStart=True)

elif event.buttons() == Qt.RightButton:
self.view.ZoomAtPoint(self.old_pos.x(), y,
x, self.old_pos.y())

self.old_pos = pos

def mouseReleaseEvent(self,event):

if event.button() == Qt.LeftButton:
pos = event.pos()
x,y = pos.x(),pos.y()

self.context.MoveTo(x,y,self.view,True)

self._handle_selection()

def _handle_selection(self):

self.context.Select(True)
self.context.InitSelected()

selected = []
if self.context.HasSelectedShape():
selected.append(self.context.SelectedShape())

self.sigObjectSelected.emit(selected)

def paintEngine(self):

return None

def paintEvent(self, event):

if not self._initialized:
self._initialize()
else:
self.view.Redraw()

def showEvent(self, event):

super(OCCTWidget,self).showEvent(event)

def resizeEvent(self, event):

super(OCCTWidget,self).resizeEvent(event)

self.view.MustBeResized()

def _initialize(self):

wins = {
'darwin' : self._get_window_osx,
'linux' : self._get_window_linux,
'win32': self._get_window_win
}

self.view.SetWindow(wins[platform](self.winId()))

self._initialized = True

def _get_window_win(self,wid):

from OCP.WNT import WNT_Window

return WNT_Window(wid.ascapsule())

def _get_window_linux(self,wid):

from OCP.Xw import Xw_Window

return Xw_Window(self.display_connection,int(wid))

def _get_window_osx(self,wid):

raise NotImplementedError()
Loading
0