Skip to content

Commit

Permalink
sorting out layout for lots of cylinders window, setting default ring…
Browse files Browse the repository at this point in the history
…s and slices to 20
  • Loading branch information
rerpha committed Jun 3, 2019
1 parent 105a9ee commit 8dc13eb
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cylinderwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ def createScene(self):
# Material
self.material = Qt3DExtras.QPhongMaterial(self.rootEntity)

def add_cylinder(self, radius, length, x, y, z):
def add_cylinder(self, radius, length, x, y, z, rings=5, slices=5):

cylinderEntity = Qt3DCore.QEntity(self.rootEntity)
cylinderMesh = Qt3DExtras.QCylinderMesh()
cylinderMesh.setRadius(radius)
cylinderMesh.setLength(length)
# cylinderMesh.setSlices(1)
# cylinderMesh.setRings(1)
cylinderMesh.setSlices(rings)
cylinderMesh.setRings(slices)
cylinderTransform = Qt3DCore.QTransform()
cylinderTransform.setTranslation(QVector3D(x, y, z))

Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from PySide2.QtGui import QWindow
from PySide2.QtWidgets import QApplication, QMainWindow, QDialog, QWidget, QPushButton
from PySide2 import QtCore
import sys
Expand Down Expand Up @@ -113,9 +112,10 @@ def add_cylinder(self):
i * translation_distance * 2,
j * translation_distance,
0,
int(self.ringslineedit.text()),
int(self.sliceslineedit.text()),
)

# self.window.add_cylinder()
print("Cylinder added.")


Expand Down
4 changes: 3 additions & 1 deletion spherewindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ def createScene(self):
# Material
self.material = Qt3DExtras.QPhongMaterial(self.rootEntity)

def add_sphere(self, radius, x, y, z):
def add_sphere(self, radius, x, y, z, rings=20, slices=20):

sphereEntity = Qt3DCore.QEntity(self.rootEntity)
sphereMesh = Qt3DExtras.QSphereMesh()
sphereMesh.setRadius(radius)
sphereMesh.setRings(rings)
sphereMesh.setSlices(slices)

sphereTransform = Qt3DCore.QTransform()
sphereTransform.setTranslation(QVector3D(x, y, z))
Expand Down
30 changes: 27 additions & 3 deletions ui/lotsofcylinders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Form implementation generated from reading ui file 'lotsofcylinders.ui',
# licensing of 'lotsofcylinders.ui' applies.
#
# Created: Fri May 31 15:44:11 2019
# Created: Fri May 31 16:09:45 2019
# by: pyside2-uic running on PySide2 5.12.1
#
# WARNING! All changes made in this file will be lost!
Expand All @@ -19,14 +19,38 @@ def setupUi(self, Dialog):
self.widget = QtWidgets.QWidget(Dialog)
self.widget.setObjectName("widget")
self.horizontalLayout.addWidget(self.widget)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.groupBox = QtWidgets.QGroupBox(Dialog)
self.groupBox.setObjectName("groupBox")
self.widget1 = QtWidgets.QWidget(self.groupBox)
self.widget1.setGeometry(QtCore.QRect(9, 26, 141, 74))
self.widget1.setObjectName("widget1")
self.formLayout = QtWidgets.QFormLayout(self.widget1)
self.formLayout.setContentsMargins(0, 0, 0, 0)
self.formLayout.setObjectName("formLayout")
self.label = QtWidgets.QLabel(self.widget1)
self.label.setObjectName("label")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label)
self.ringslineedit = QtWidgets.QLineEdit(self.widget1)
self.ringslineedit.setObjectName("ringslineedit")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.ringslineedit)
self.label_2 = QtWidgets.QLabel(self.widget1)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2)
self.sliceslineedit = QtWidgets.QLineEdit(self.widget1)
self.sliceslineedit.setObjectName("sliceslineedit")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.sliceslineedit)
self.pushButton = QtWidgets.QPushButton(self.widget1)
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.pushButton)
self.horizontalLayout.addWidget(self.groupBox)

self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtWidgets.QApplication.translate("Dialog", "Dialog", None, -1))
self.groupBox.setTitle(QtWidgets.QApplication.translate("Dialog", "rings and slices", None, -1))
self.label.setText(QtWidgets.QApplication.translate("Dialog", "rings", None, -1))
self.label_2.setText(QtWidgets.QApplication.translate("Dialog", "slices", None, -1))
self.pushButton.setText(QtWidgets.QApplication.translate("Dialog", "Add lots of cylinders", None, -1))

45 changes: 42 additions & 3 deletions ui/lotsofcylinders.ui
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,49 @@
<widget class="QWidget" name="widget" native="true"/>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Add lots of cylinders</string>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>rings and slices</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>9</x>
<y>26</y>
<width>141</width>
<height>74</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>rings</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="ringslineedit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>slices</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="sliceslineedit"/>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Add lots of cylinders</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 8dc13eb

Please sign in to comment.