CAM: apply precommit

This commit is contained in:
Adrian Insaurralde Avalos
2024-09-03 14:54:36 -04:00
parent 261ef09348
commit a17a3cf6d7
337 changed files with 26842 additions and 25585 deletions

View File

@@ -39,24 +39,29 @@ namespace CAMSimulator
static const float MouseScrollDelta = 120.0f;
DlgCAMSimulator::DlgCAMSimulator(QWindow* parent)
: QWindow(parent) {
: QWindow(parent)
{
setSurfaceType(QWindow::OpenGLSurface);
mMillSimulator = new MillSimulation();
}
void DlgCAMSimulator::render(QPainter* painter) {
void DlgCAMSimulator::render(QPainter* painter)
{
Q_UNUSED(painter);
}
void DlgCAMSimulator::render() {
void DlgCAMSimulator::render()
{
mMillSimulator->ProcessSim((unsigned int)(QDateTime::currentMSecsSinceEpoch()));
}
void DlgCAMSimulator::renderLater() {
void DlgCAMSimulator::renderLater()
{
requestUpdate();
}
bool DlgCAMSimulator::event(QEvent* event) {
bool DlgCAMSimulator::event(QEvent* event)
{
switch (event->type()) {
case QEvent::UpdateRequest:
renderNow();
@@ -67,7 +72,8 @@ bool DlgCAMSimulator::event(QEvent* event) {
return QWindow::event(event);
}
void DlgCAMSimulator::exposeEvent(QExposeEvent* event) {
void DlgCAMSimulator::exposeEvent(QExposeEvent* event)
{
Q_UNUSED(event);
if (isExposed()) {
@@ -75,36 +81,42 @@ void DlgCAMSimulator::exposeEvent(QExposeEvent* event) {
}
}
void DlgCAMSimulator::mouseMoveEvent(QMouseEvent* ev) {
void DlgCAMSimulator::mouseMoveEvent(QMouseEvent* ev)
{
int modifiers = (ev->modifiers() & Qt::ShiftModifier) != 0 ? MS_KBD_SHIFT : 0;
modifiers |= (ev->modifiers() & Qt::ControlModifier) != 0 ? MS_KBD_CONTROL : 0;
modifiers |= (ev->modifiers() & Qt::AltModifier) != 0 ? MS_KBD_ALT : 0;
mMillSimulator->MouseMove(ev->x(), ev->y(), modifiers);
}
void DlgCAMSimulator::mousePressEvent(QMouseEvent* ev) {
void DlgCAMSimulator::mousePressEvent(QMouseEvent* ev)
{
mMillSimulator->MousePress(ev->button(), true, ev->x(), ev->y());
}
void DlgCAMSimulator::mouseReleaseEvent(QMouseEvent* ev) {
void DlgCAMSimulator::mouseReleaseEvent(QMouseEvent* ev)
{
mMillSimulator->MousePress(ev->button(), false, ev->x(), ev->y());
}
void DlgCAMSimulator::wheelEvent(QWheelEvent* ev) {
void DlgCAMSimulator::wheelEvent(QWheelEvent* ev)
{
mMillSimulator->MouseScroll((float)ev->angleDelta().y() / MouseScrollDelta);
}
void DlgCAMSimulator::resetSimulation() {
}
void DlgCAMSimulator::resetSimulation()
{}
void DlgCAMSimulator::addGcodeCommand(const char* cmd) {
void DlgCAMSimulator::addGcodeCommand(const char* cmd)
{
mMillSimulator->AddGcodeLine(cmd);
}
void DlgCAMSimulator::addTool(const std::vector<float>& toolProfilePoints,
int toolNumber,
float diameter,
float resolution) {
float resolution)
{
Q_UNUSED(resolution)
std::string toolCmd = "T" + std::to_string(toolNumber);
mMillSimulator->AddGcodeLine(toolCmd.c_str());
@@ -113,7 +125,8 @@ void DlgCAMSimulator::addTool(const std::vector<float>& toolProfilePoints,
}
}
void DlgCAMSimulator::hideEvent(QHideEvent* ev) {
void DlgCAMSimulator::hideEvent(QHideEvent* ev)
{
mMillSimulator->Clear();
doGlCleanup();
mAnimating = false;
@@ -122,7 +135,8 @@ void DlgCAMSimulator::hideEvent(QHideEvent* ev) {
mInstance = nullptr;
}
void DlgCAMSimulator::resizeEvent(QResizeEvent* event) {
void DlgCAMSimulator::resizeEvent(QResizeEvent* event)
{
if (!mContext) {
return;
}
@@ -139,7 +153,8 @@ void DlgCAMSimulator::resizeEvent(QResizeEvent* event) {
void DlgCAMSimulator::GetMeshData(const Part::TopoShape& tshape,
float resolution,
std::vector<Vertex>& verts,
std::vector<GLushort>& indices) {
std::vector<GLushort>& indices)
{
std::vector<int> normalCount;
int nVerts = 0;
for (auto& shape : tshape.getSubTopoShapes(TopAbs_FACE)) {
@@ -183,7 +198,8 @@ void DlgCAMSimulator::GetMeshData(const Part::TopoShape& tshape,
}
}
void DlgCAMSimulator::startSimulation(const Part::TopoShape& stock, float quality) {
void DlgCAMSimulator::startSimulation(const Part::TopoShape& stock, float quality)
{
mQuality = quality;
mNeedsInitialize = true;
show();
@@ -192,7 +208,8 @@ void DlgCAMSimulator::startSimulation(const Part::TopoShape& stock, float qualit
setAnimating(true);
}
void DlgCAMSimulator::initialize() {
void DlgCAMSimulator::initialize()
{
mMillSimulator->InitSimulation(mQuality);
const qreal retinaScale = devicePixelRatio();
@@ -200,7 +217,8 @@ void DlgCAMSimulator::initialize() {
glEnable(GL_MULTISAMPLE);
}
void DlgCAMSimulator::checkInitialization() {
void DlgCAMSimulator::checkInitialization()
{
if (!mContext) {
mLastContext = QOpenGLContext::currentContext();
mContext = new QOpenGLContext(this);
@@ -223,7 +241,8 @@ void DlgCAMSimulator::checkInitialization() {
}
}
void DlgCAMSimulator::doGlCleanup() {
void DlgCAMSimulator::doGlCleanup()
{
if (mLastContext != nullptr) {
mLastContext->makeCurrent(this);
}
@@ -233,7 +252,8 @@ void DlgCAMSimulator::doGlCleanup() {
}
}
void DlgCAMSimulator::renderNow() {
void DlgCAMSimulator::renderNow()
{
static unsigned int lastTime = 0;
static int frameCount = 0;
static int fps = 0;
@@ -260,7 +280,8 @@ void DlgCAMSimulator::renderNow() {
(void)fps;
}
void DlgCAMSimulator::setAnimating(bool animating) {
void DlgCAMSimulator::setAnimating(bool animating)
{
mAnimating = animating;
if (animating) {
@@ -268,7 +289,8 @@ void DlgCAMSimulator::setAnimating(bool animating) {
}
}
DlgCAMSimulator* DlgCAMSimulator::GetInstance() {
DlgCAMSimulator* DlgCAMSimulator::GetInstance()
{
if (mInstance == nullptr) {
QSurfaceFormat format;
format.setVersion(4, 1); // Request OpenGL 4.1 - for MacOS
@@ -287,14 +309,16 @@ DlgCAMSimulator* DlgCAMSimulator::GetInstance() {
return mInstance;
}
void DlgCAMSimulator::SetStockShape(const Part::TopoShape& shape, float resolution) {
void DlgCAMSimulator::SetStockShape(const Part::TopoShape& shape, float resolution)
{
std::vector<Vertex> verts;
std::vector<GLushort> indices;
GetMeshData(shape, resolution, verts, indices);
mMillSimulator->SetArbitraryStock(verts, indices);
}
void DlgCAMSimulator::SetBaseShape(const Part::TopoShape& tshape, float resolution) {
void DlgCAMSimulator::SetBaseShape(const Part::TopoShape& tshape, float resolution)
{
std::vector<Vertex> verts;
std::vector<GLushort> indices;
GetMeshData(tshape, resolution, verts, indices);
@@ -312,10 +336,12 @@ SimStock::SimStock(float px, float py, float pz, float lx, float ly, float lz, f
, mPz(pz + 0.005 * lz)
, mLx(lx)
, mLy(ly)
, mLz(1.01 * lz) {
, mLz(1.01 * lz)
{
(void)res;
}
SimStock::~SimStock() {}
SimStock::~SimStock()
{}
} // namespace CAMSimulator