void PageBoundary::drawClipped ( Canvas* c, Coord l, Coord b, Coord r, Coord t, Graphic* gs ) { Coord x0, y0, x1, y1, x2, y2; BoxObj clipBox(l, b, r, t); transform(0, 0, x0, y0, gs); transform(border, pageheight, x1, y1, gs); transform(pagewidth, border, x2, y2, gs); BoxObj lbox(x0, y0, x1, y1); BoxObj bbox(x0, y0, x2, y2); transform(pagewidth - border, 0, x0, y0, gs); transform(0, pageheight - border, x1, y1, gs); transform(pagewidth, pageheight, x2, y2, gs); BoxObj rbox(x0, y0, x2, y2); BoxObj tbox(x1, y1, x2, y2); update(gs); if (lbox.Intersects(clipBox)) { pFillRect(c, 0, 0, border, pageheight); } if (bbox.Intersects(clipBox)) { pFillRect(c, 0, 0, pagewidth, border); } if (rbox.Intersects(clipBox)) { pFillRect(c, pagewidth - border, 0, pagewidth, pageheight); } if (tbox.Intersects(clipBox)) { pFillRect(c, 0, pageheight - border, pagewidth, pageheight); } }
void register_textbox(py::module &m) { py::class_<TextBox, Widget, ref<TextBox>, PyTextBox> tbox(m, "TextBox", D(TextBox)); tbox .def(py::init<Widget *, const std::string &>(), py::arg("parent"), py::arg("value") = std::string("Untitled"), D(TextBox, TextBox)) .def("editable", &TextBox::editable, D(TextBox, editable)) .def("setEditable", &TextBox::setEditable, D(TextBox, setEditable)) .def("spinnable", &TextBox::spinnable, D(TextBox, spinnable)) .def("setSpinnable", &TextBox::setSpinnable, D(TextBox, setSpinnable)) .def("value", &TextBox::value, D(TextBox, value)) .def("setValue", &TextBox::setValue, D(TextBox, setValue)) .def("defaultValue", &TextBox::defaultValue, D(TextBox, defaultValue)) .def("setDefaultValue", &TextBox::setDefaultValue, D(TextBox, setDefaultValue)) .def("alignment", &TextBox::alignment, D(TextBox, alignment)) .def("setAlignment", &TextBox::setAlignment, D(TextBox, setAlignment)) .def("units", &TextBox::units, D(TextBox, units)) .def("setUnits", &TextBox::setUnits, D(TextBox, setUnits)) .def("unitsImage", &TextBox::unitsImage, D(TextBox, unitsImage)) .def("setUnitsImage", &TextBox::setUnitsImage, D(TextBox, setUnitsImage)) .def("format", &TextBox::format, D(TextBox, format)) .def("setFormat", &TextBox::setFormat, D(TextBox, setFormat)) .def("callback", &TextBox::callback, D(TextBox, callback)) .def("setCallback", &TextBox::setCallback, D(TextBox, setCallback)); py::enum_<TextBox::Alignment>(tbox, "Alignment", D(TextBox, Alignment)) .value("Left", TextBox::Alignment::Left) .value("Center", TextBox::Alignment::Center) .value("Right", TextBox::Alignment::Right); py::class_<Int64Box, TextBox, ref<Int64Box>, PyInt64Box>(m, "IntBox", D(IntBox)) .def(py::init<Widget *, int64_t>(), py::arg("parent"), py::arg("value") = (int64_t) 0, D(IntBox, IntBox)) .def("value", &Int64Box::value, D(IntBox, value)) .def("setValue", (void (Int64Box::*)(int64_t)) &Int64Box::setValue, D(IntBox, setValue)) .def("setCallback", (void (Int64Box::*)(const std::function<void(int64_t)>&)) &Int64Box::setCallback, D(IntBox, setCallback)) .def("setValueIncrement", &Int64Box::setValueIncrement, D(IntBox, setValueIncrement)) .def("setMinValue", &Int64Box::setMinValue, D(IntBox, setMinValue)) .def("setMaxValue", &Int64Box::setMaxValue, D(IntBox, setMaxValue)) .def("setMinValue", &Int64Box::setMinMaxValues, D(IntBox, setMinMaxValues)); py::class_<DoubleBox, TextBox, ref<DoubleBox>, PyDoubleBox>(m, "FloatBox", D(FloatBox)) .def(py::init<Widget *, double>(), py::arg("parent"), py::arg("value") = 0.0) .def("value", &DoubleBox::value, D(FloatBox, value)) .def("setValue", (void (DoubleBox::*)(double)) &DoubleBox::setValue, D(FloatBox, setValue)) .def("setCallback", (void (DoubleBox::*)(const std::function<void(double)>&)) &DoubleBox::setCallback, D(FloatBox, setCallback)) .def("setValueIncrement", &DoubleBox::setValueIncrement, D(FloatBox, setValueIncrement)) .def("setMinValue", &DoubleBox::setMinValue, D(FloatBox, setMinValue)) .def("setMaxValue", &DoubleBox::setMaxValue, D(FloatBox, setMaxValue)) .def("setMinValue", &DoubleBox::setMinMaxValues, D(FloatBox, setMinMaxValues)); }
void AABBTree::sortTrianglesToVoxel(const vector<Triangle>& T, const SplittingPlane& p, const PlaneSide& pside, vector<Triangle>& TL, vector<Triangle>& TR) { for(int i=0; i<T.size(); ++i) { AABB tbox(T[i]); // the triangle is on the splitting plane exactly if(tbox.minPos(p.axis) == p.pe && tbox.maxPos(p.axis) == p.pe) { if(pside == PlaneSide::Left) TL.push_back(T[i]); else if(pside == PlaneSide::Right) TR.push_back(T[i]); } else { if(tbox.minPos(p.axis) < p.pe) TL.push_back(T[i]); if(tbox.maxPos(p.axis) > p.pe) TR.push_back(T[i]); } } }
int process(const tendrils& in, const tendrils& out) { cv::Mat R, T, K, depth; in.get<cv::Mat>("R").convertTo(R, CV_64F); in.get<cv::Mat>("T").convertTo(T, CV_64F); in.get<cv::Mat>("K").convertTo(K, CV_64F); depth = in.get<cv::Mat>("depth"); cv::Mat mask; if (!depth.empty()) { mask = cv::Mat::zeros(depth.size(), CV_8UC1); } else return ecto::OK; if (R.empty() || T.empty() || K.empty()) return 0; double fx, fy, cx, cy; fx = K.at<double>(0, 0); fy = K.at<double>(1, 1); cx = K.at<double>(0, 2); cy = K.at<double>(1, 2); box_mask.create(depth.size()); box_mask.setTo(cv::Scalar(0)); std::vector<cv::Point3f> box(8), tbox(8); box[0] = cv::Point3f(*x_crop, *y_crop, *z_min); box[1] = cv::Point3f(-*x_crop, *y_crop, *z_min); box[2] = cv::Point3f(-*x_crop, -*y_crop, *z_min); box[3] = cv::Point3f(*x_crop, -*y_crop, *z_min); box[4] = cv::Point3f(*x_crop, *y_crop, *z_crop); box[5] = cv::Point3f(-*x_crop, *y_crop, *z_crop); box[6] = cv::Point3f(-*x_crop, -*y_crop, *z_crop); box[7] = cv::Point3f(*x_crop, -*y_crop, *z_crop); cv::Mat RT(3, 4, CV_64F); cv::Mat _T(RT.colRange(3, 4)); cv::Mat _R(RT.colRange(0, 3)); R.copyTo(_R); T.copyTo(_T); cv::transform(box, tbox, RT); std::vector<cv::Point2f> projected, hull; cv::projectPoints(box, R, T, K, cv::Mat(4, 1, CV_64FC1, cv::Scalar(0)), projected); cv::convexHull(projected, hull, true); std::vector<cv::Point> points(hull.size()); std::copy(hull.begin(), hull.end(), points.begin()); cv::fillConvexPoly(box_mask, points.data(), points.size(), cv::Scalar::all(255)); cv::Matx<double, 3, 3> A_x; int width = mask.size().width; int height = mask.size().height; cv::Mat_<float_t>::iterator dit = depth.begin<float_t>(); cv::Mat_<uint8_t>::iterator it = mask.begin<uint8_t>(); cv::Mat_<uint8_t>::iterator mit = box_mask.begin(); cv::Matx<double, 3, 1> p, p_r, Tx(T); //Translation cv::Matx<double, 3, 3> Rx; //inverse Rotation Rx = cv::Mat(R.t()); // std::cout << cv::Mat(Rx) << "\n" << cv::Mat(Tx) << std::endl; // std::cout << fx << " " << fy << " " << cx << " " << cy << " " << std::endl; double z_min_ = *z_min, z_max_ = *z_crop, x_min_ = -*x_crop, x_max_ = *x_crop, y_min_ = -*y_crop, y_max_ = *y_crop; for (int v = 0; v < height; v++) { for (int u = 0; u < width; u++, ++it, ++mit, ++dit) { if (*mit == 0) continue; //calculate the point based on the depth p(2) = *dit; //depth value in meters p(0) = (u - cx) * p(2) / fx; p(1) = (v - cy) * p(2) / fy; p_r = Rx * (p - Tx); // std::cout <<"p=" << cv::Mat(p) << ",p_r="<< cv::Mat(p_r) << std::endl; if (p_r(2) > z_min_ && p_r(2) < z_max_ && p_r(0) > x_min_ && p_r(0) < x_max_ && p_r(1) > y_min_ && p_r(1) < y_max_) *it = 255; } } out["mask"] << mask; return ecto::OK; }
void loading() { int l_x=20,l_y=20,l_w=20; int dly=100; textcolor(7); tbox(l_x,l_y,l_w); gotoxy(l_x,l_y-1); delay(dly); printf("loading..."); delay(dly); textbackground(0); gotoxy(l_x,l_y); printf("%c",219); delay(dly); printf("%c",219); delay(dly); detectmouse ();//detecting and initializing mouse gotoxy(l_x+2,l_y); printf("%c",219); delay(dly); printf("%c",219); delay(dly); showmouse ();//assigning the flaag interrupt for showing mouse as true // curnt_fn=filmain; gotoxy(l_x+4,l_y); delay(dly); printf("%c",219); delay(dly); printf("%c",219); fp=fopen("settings.txt","r"); fscanf(fp,"%d %d %d %d %d",&read_flag.fil,&read_flag.name,&read_flag.name,&read_flag.price,&read_flag.st); fcloseall(); delay(dly); gotoxy(l_x+6,l_y); printf("%c",219); delay(dly); gotoxy(l_x+7,l_y); printf("%c",219); delay(dly); gotoxy(l_x+8,l_y); printf("%c",219); delay(dly); gotoxy(l_x+9,l_y); printf("%c",219); gotoxy(l_x+10,l_y); printf("%c",219); fopen ("File.txt","a"); gotoxy(l_x+11,l_y); printf("%c",219); gotoxy(l_x+12,l_y); printf("%c",219); if (!fopen("Psswd.txt","r")) { fp=fopen("Psswd.txt","w"); fprintf(fp," "); fcloseall(); } gotoxy(l_x+13,l_y); printf("%c",219); gotoxy(l_x+14,l_y); printf("%c",219); gotoxy(l_x+15,l_y); printf("%c",219); gotoxy(l_x+16,l_y); printf("%c",219); fcloseall(); gotoxy(l_x+17,l_y); printf("%c",219); delay(dly); gotoxy(l_x+18,l_y); printf("%c",219); gotoxy(l_x+19,l_y); printf("%c",219); //getch(); //if (fopen()) tbldisp();//initial display for the table of the bill curnt_fn=billmain;//assigning the current function as the main of the billing part //billmain contorlls the event hanling in the bill }