void dirty_clear() const noexcept { m_bounding_rect_old=boundingRectangle(); auto l=layers(); if(l!=nullptr) {(*l)[layerIndex()].dirty(false);} }
void DeviceStateWidget::paintEvent(QPaintEvent *) { qDebug() << "DeviceStateWidget::paintEvent"; QPainter painter(this); QPen myPen; QRectF boundingRectangle(0.0, 0.0, 30.0, 30.0); QPainterPath myPath; myPath.addEllipse(boundingRectangle); //QPainter painter(this); //painter.setBrush(myGradient); if (mPowerChanged) { painter.setBrush(PowerChangedColor); mPowerChanged = false; } else { switch (mDeviceState) { case DeviceManager::UnconnectedState: painter.setBrush(UnconnectedStateColor); break; case DeviceManager::HostLookupState: painter.setBrush(UnconnectedStateColor); break; case DeviceManager::ConnectingState: painter.setBrush(ConnectingStateColor); break; case DeviceManager::ConnectedState: painter.setBrush(ConnectedStateColor); break; case DeviceManager::WritingState: painter.setBrush(WritingStateColor); break; case DeviceManager:: WrittenState: painter.setBrush(WrittenStateColor); break; case DeviceManager::ReadingState: painter.setBrush(ReadingStateColor); break; case DeviceManager::ReadState: painter.setBrush(ReadStateColor); break; case DeviceManager::ErrorState: painter.setBrush(ErrorStateColor); break; case DeviceManager::ClosingState: painter.setBrush(ClosingStateColor); break; default: Q_ASSERT(false); // Logic error } } painter.setPen(myPen); painter.drawPath(myPath); }
double workpiece::quote() { double cost = 0; // Net cost counter rectangle* rects = (rectangle*)malloc(sizeof(rectangle) * (numArcs + 1)); // Array of bounding rectangles for (int i = 0; i < numSegments ; ++i) cost += lengthOfSegment(segments[i]) * machiningCost / maxCutterSpeed; // Add the cost of cutting line segments for (int i = 0; i < numArcs ; ++i) { cost += lengthOfArc(arcs[i]) * machiningCost * exp(1/radiusOfArc(arcs[i])) / maxCutterSpeed; // Add the cost of cutting circular arcs rects[i] = boundingRectangle(arcs[i]); // Compute bounding rectangle of arcs } rects[numArcs] = boundingRectangle(numSegments, segments); // Compute bounding rectangle of line segments // Add material cost of total boundign rectangle + padding cost += areaOfRectangle(boundingRectangle(numArcs + 1, rects), padding) * materialCost; return round(cost * 100) / 100; }
/*********************************************************************************************************************** * @BRIEF Process a single image frame * @PARAM[in] imageIn the input image frame * @PARAM[out] imageOut the processed image frame * @RETURN true if frame was processed successfully * @AUTHOR Christopher D. McMurrough **********************************************************************************************************************/ bool processFrame(const cv::Mat &imageIn, cv::Mat &imageOut) { // get the region of interest cv::Point p1(imageIn.cols / 2 - 50, imageIn.rows / 2 - 50); cv::Point p2(imageIn.cols / 2 + 50, imageIn.rows / 2 + 50); cv::Rect boundingRectangle(p1, p2); cv::Mat imageROI = imageIn(boundingRectangle); // compute the color label for the region of interest char color = labelColor(imageROI); // copy the input image frame to the ouput image imageIn.copyTo(imageOut); // annotate the output image switch(color) { case COLOR_RED: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 0, 255), 3); break; case COLOR_GREEN: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 255, 0), 3); break; case COLOR_BLUE: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(255, 0, 0), 3); break; case COLOR_YELLOW: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 255, 255), 3); break; case COLOR_ORANGE: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 128, 255), 3); break; case COLOR_WHITE: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(255, 255, 255), 3); break; default: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 0, 0), 3); break; } // return true on success return true; }
Surface& dirtyRectangleAdd(const Rectangle& rect) { m_dirty_rect=boundingRectangle(m_dirty_rect,rect); rect_clamp(); return *this; }