Exemplo n.º 1
0
void FBox::layout()
      {
//      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
      Box::layout();
      }
Exemplo n.º 2
0
void AmeGradientButton::paintEvent(QPaintEvent *)
{
        QPainter painter(this);

        QColor outlineColor1(0x7e, 0x7e, 0x7e);
        QColor outlineColor2(0x97, 0x97, 0x97);

        QColor topColor, bottomColor;
        if (isDown()) {
                topColor = QColor(0xa3, 0xa3, 0xa3);
                bottomColor = QColor(0x95, 0x95, 0x95);
        } else {
                topColor = QColor(0xfb, 0xfb, 0xfb);
                bottomColor = QColor(0xee, 0xee, 0xee);
        }

        QRect r = painter.window();

        int left, right, h, w, x1, x2;
        h = (height() - 2) / 2;
        x1 = 1; x2 = 0;

        switch (gPos) {
                case LeftButton : {
                        w = width() - 1;
                        left=r.left() + 1;
                        right=r.right();
                        x1 = 2;
                        break;
                }
                case MidButton: {
                        w = width();
                        left = r.left();
                        right = r.right();
                        break;
                }
                case RightButton : {
                        w = width() - 2;
                        left = r.left();
                        right = r.right();
                        x2 = -1;
                        break;
                }
        }

        painter.setPen(QPen(outlineColor1, 0));
        painter.drawLine(QPoint(left, r.top()), QPoint(right, r.top()));


        int y1 = r.top() + 1;
        painter.setPen(QPen(outlineColor2, 0));
        painter.drawLine(QPoint(left, y1), QPoint(left, r.bottom()));
        painter.drawLine(QPoint(left, r.bottom()), QPoint(right, r.bottom()));

        if (gPos == RightButton)
                painter.drawLine(QPoint(right, y1), QPoint(right, r.bottom()));

        left ++;
        painter.fillRect(left, 1, w, h, topColor);
        painter.fillRect(left, h + 1, w, h, bottomColor);

        QStyleOptionFocusRect option;
        option.initFrom(this);
        option.rect.adjust(x1, 1, x2, -1);

        QPixmap pix = icon().pixmap(iconSize(),
                isEnabled() ? QIcon::Normal : QIcon::Disabled,
                isDown() ? QIcon::On : QIcon::Off);

        int pw = pix.width();
        int ph = pix.height();

        QPoint point(option.rect.x() + option.rect.width() / 2 - pw / 2,
                     option.rect.y() + option.rect.height() / 2 - ph / 2);

        painter.drawPixmap(style()->visualPos(layoutDirection(), option.rect, point), pix);

        if (hasFocus()) {
                option.backgroundColor = palette().color(QPalette::Background);
                style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this);
        }

}
Exemplo n.º 3
0
glm::quat Entity::LookAt(float x, float y, float z)
{
	glm::vec3 point(x, y, z);
	return glm::toQuat(glm::lookAt(position, point, glm::vec3{ 0.0f, 1.0f, 0.0f }));;
}
Exemplo n.º 4
0
Arquivo: Line.cpp Projeto: Tisuama/ACM
 point crosspoint(Line v)
 {
     double a1=(v.e-v.s)^(s-v.s);
     double a2=(v.e-v.s)^(e-v.s);
     return point((s.x*a2-e.x*a1)/(a2-a1),(s.y*a2-e.y*a1)/(a2-a1));
 }
void HitProtein::loadProteinInfo(string proteinLocation) {
	//open protein db file, read and store protein infomation
	string proteinFile(proteinLocation);
	proteinFile += proteinName;
	proteinFile += ".db";
	FILE* fptr = fopen((char*) proteinFile.c_str(), "r");
	if (fptr == NULL) {
		cout << "input file: " << proteinFile << " can't open" << endl;
	} else {
		int lineLength = 5000;
		char line[lineLength];
		while (fgets(line, lineLength, fptr) != NULL) {
			if ((strstr(line, ">Real Sequence Info:") != NULL)) {

				fgets(line, lineLength, fptr);

				int numberOfChars = 0;
				while (line[numberOfChars] != '\0') {

					numberOfChars++;
				}
				numberOfChars--;

				string _realSequenceInfo(line);

				setRealSequenceInfo(_realSequenceInfo);
				//cout << realSequenceInfo << endl;
				setRealSequenceLength(numberOfChars);
				//cout << realSequenceLength << endl;
			}
			if ((strstr(line, ">Ca XYZ:") != NULL)) {

				double Xs[realSequenceLength];
				double Ys[realSequenceLength];
				double Zs[realSequenceLength];

				double temp;
				for (int i = 0; i < realSequenceLength; i++) {
					fscanf(fptr, "%lf", &temp);
					Xs[i] = temp;
					//if (i % 10 == 0) {
					// cout << endl;
					// }
					// cout << Xs[i] << " ";
				}
				//cout << endl;

				for (int i = 0; i < realSequenceLength; i++) {
					fscanf(fptr, "%lf", &temp);
					Ys[i] = temp;
					//if (i % 10 == 0) {
					// cout << endl;
					// }
					// cout << Ys[i] << " ";
				}
				//cout << endl;
				for (int i = 0; i < realSequenceLength; i++) {
					fscanf(fptr, "%lf", &temp);
					Zs[i] = temp;
					//if (i % 10 == 0) {
					// cout << endl;
					// }
					// cout << Zs[i] << " ";
				}
				//cout << endl;
				CAlpha_XYZ = (Point*) malloc(
						sizeof(Point) * realSequenceLength);

				for (int i = 0; i < realSequenceLength; i++) {
					Point point(Xs[i], Ys[i], Zs[i]);
					CAlpha_XYZ[i] = point;
				}

			}
		}
	}

}
  void patchArrayCallback(const samplereturn_msgs::PatchArrayConstPtr& msg)
  {
    samplereturn_msgs::NamedPointArray points_out;
    points_out.header = msg->header;
    bool enable_debug = (pub_debug_image.getNumSubscribers() != 0);
    cv::Mat debug_image;
    if (enable_debug) {
      debug_image = cv::Mat::zeros(msg->cam_info.height,
          msg->cam_info.width, CV_8UC3);
    }
    for (size_t i = 0; i < msg->patch_array.size(); i++) {
      cv_bridge::CvImageConstPtr cv_ptr_mask, cv_ptr_img;
      sensor_msgs::ImageConstPtr msg_mask(&(msg->patch_array[i].mask), boost::serialization::null_deleter());
      sensor_msgs::ImageConstPtr msg_img(&(msg->patch_array[i].image), boost::serialization::null_deleter());
      try {
        cv_ptr_mask = cv_bridge::toCvShare(msg_mask, "mono8");
      }
      catch (cv_bridge::Exception& e) {
        ROS_ERROR("cv_bridge mask exception: %s", e.what());
      }
      try {
        cv_ptr_img = cv_bridge::toCvShare(msg_img, "rgb8");
      }
      catch (cv_bridge::Exception& e) {
        ROS_ERROR("cv_bridge image exception: %s", e.what());
      }
      if (enable_debug) {
        cv_ptr_img->image.copyTo(debug_image(cv::Rect(msg->patch_array[i].image_roi.x_offset,
                msg->patch_array[i].image_roi.y_offset,
                msg->patch_array[i].image_roi.width,
                msg->patch_array[i].image_roi.height)));
      }

      cv::Mat Lab;
      cv::cvtColor(cv_ptr_img->image, Lab, cv::COLOR_RGB2Lab);
      cv::Mat point(1,1,CV_32FC3);
      point = cv::mean(Lab, cv_ptr_mask->image);
      cv::Mat scaled_point = (point.reshape(1) - mean_)/std_;
      cv::Mat prediction;
      svm->predict(scaled_point, prediction, cv::ml::StatModel::RAW_OUTPUT);
      float distance = prediction.at<float>(0);

      if (enable_debug) {
          int x,y,h;
          x = msg->patch_array[i].image_roi.x_offset;
          y = msg->patch_array[i].image_roi.y_offset;
          //w = msg->patch_array[i].image_roi.width;
          h = msg->patch_array[i].image_roi.height;
          char edist[100];
          snprintf(edist, 100, "d:%3.2f", distance);
          cv::putText(debug_image,edist,cv::Point2d(x+70, y + h + 50*config_.debug_font_scale),
                  cv::FONT_HERSHEY_SIMPLEX, config_.debug_font_scale, cv::Scalar(255,0,0),4,cv::LINE_8);
      }

      bool is_sample = distance<0;

      if(!is_sample)
      {
          if(enable_debug)
          {
              // Nix region
              int x,y,w,h;
              x = msg->patch_array[i].image_roi.x_offset;
              y = msg->patch_array[i].image_roi.y_offset;
              w = msg->patch_array[i].image_roi.width;
              h = msg->patch_array[i].image_roi.height;
              cv::line(debug_image,
                      cv::Point2f(x, y),
                      cv::Point2f(x + w, y + h), cv::Scalar(255,0,0), 20);
              cv::line(debug_image,
                      cv::Point2f(x + w, y),
                      cv::Point2f(x, y + h), cv::Scalar(255,0,0), 20);
          }
          continue;
      }

      samplereturn_msgs::NamedPoint np_msg;

      if(config_.compute_grip_angle)
      {
          cv::RotatedRect griprect;
          if(samplereturn::computeGripAngle(cv_ptr_mask->image, &griprect, &np_msg.grip_angle) &&
                  enable_debug)
          {
              griprect.center += cv::Point2f(
                      msg->patch_array[i].image_roi.x_offset,
                      msg->patch_array[i].image_roi.y_offset);
              samplereturn::drawGripRect(debug_image, griprect);
          }
      }

      np_msg.header.stamp = msg->header.stamp;
      np_msg.header.frame_id = msg->patch_array[i].world_point.header.frame_id;
      np_msg.point = msg->patch_array[i].world_point.point;
      np_msg.sensor_frame = msg->header.frame_id;
      np_msg.name = "SVM";
      points_out.points.push_back(np_msg);
    }
    pub_named_points.publish(points_out);
    if (enable_debug) {
      sensor_msgs::ImagePtr debug_image_msg =
        cv_bridge::CvImage(msg->header,"rgb8",debug_image).toImageMsg();
      pub_debug_image.publish(debug_image_msg);
    }
  }
Exemplo n.º 7
0
Arquivo: Line.cpp Projeto: Tisuama/ACM
 point  operator -(const point &b)const{return point(x-b.x,y-b.y);}
Exemplo n.º 8
0
void QGL2PEXVertexArray::addClosingLine(int index)
{
    QPointF point(vertexArray.at(index));
    if (point != QPointF(vertexArray.last()))
        vertexArray.add(point);
}
Exemplo n.º 9
0
int vspen(char *s)
{
if (s==0) return(0);
if (!point((int)s)) return(0);
return(match(s, SPAN));
}
Exemplo n.º 10
0
void Marked_polyline::draw_lines() const
{
	Open_polyline::draw_lines();
	for (int i=0; i<number_of_points(); ++i)
		draw_mark(point(i),mark[i%mark.size()]);
}
Exemplo n.º 11
0
 point operator-(point p) { return point(x-p.x, y-p.y); }
Exemplo n.º 12
0
	point units_converter::from_device_units(const size& aExtents, const point& aValue) const
	{
		switch (units())
		{
		default:
		case UnitsPixels:
			return aValue;
		case UnitsPoints:
			return point(aValue) * point(72.0 / static_cast<dimension>(iContext.device_metrics().horizontal_dpi()), 72.0 / static_cast<dimension>(iContext.device_metrics().vertical_dpi()));
		case UnitsPicas:
			return point(aValue) * point(6.0 / static_cast<dimension>(iContext.device_metrics().horizontal_dpi()), 6.0 / static_cast<dimension>(iContext.device_metrics().vertical_dpi()));
		case UnitsEms:
			return point(aValue) * point((1.0 / static_cast<dimension>(iContext.device_metrics().em_size())) / static_cast<dimension>(iContext.device_metrics().horizontal_dpi()), (1.0 / static_cast<dimension>(iContext.device_metrics().em_size())) / static_cast<dimension>(iContext.device_metrics().vertical_dpi()));
		case UnitsMillimetres:
			return point(aValue) * point(25.4 / static_cast<dimension>(iContext.device_metrics().horizontal_dpi()), 25.4 / static_cast<dimension>(iContext.device_metrics().vertical_dpi()));
		case UnitsCentimetres:
			return point(aValue) * point(2.54 / static_cast<dimension>(iContext.device_metrics().horizontal_dpi()), 2.54 / static_cast<dimension>(iContext.device_metrics().vertical_dpi()));
		case UnitsInches:
			return point(aValue) * point(1.0 / static_cast<dimension>(iContext.device_metrics().horizontal_dpi()), 1.0 / static_cast<dimension>(iContext.device_metrics().vertical_dpi()));
		case UnitsPercentage:
			return point(aValue) / point(aExtents) * point(100.0, 100.0);
		}
	}
Exemplo n.º 13
0
bool RichTextLabel::insideActiveArea(int x, int y)
{
    QPoint point(x - getX(), y - getY());
    return text->anchorAt(point) != ""; // && text -> inText(point);
}
Exemplo n.º 14
0
std::shared_ptr<Surface> LoadMesh(const char *file_name, float scale, const Vector3f& offset) {
	std::shared_ptr<Group> pMesh(new Group());

	FILE *fp;
	errno_t err = fopen_s(&fp, file_name, "r");
	char line[MESH_LINE_MAX];
	char delims[] = " ";
	char *type = NULL;
	char *param1 = NULL;
	char *param2 = NULL;
	char *param3 = NULL;
	char *next = NULL;

	float minX = std::numeric_limits<float>::infinity();
	float maxX = -std::numeric_limits<float>::infinity();
	float minY = std::numeric_limits<float>::infinity();
	float maxY = -std::numeric_limits<float>::infinity();
	float minZ = std::numeric_limits<float>::infinity();
	float maxZ = -std::numeric_limits<float>::infinity();

	if (err == 0) {
		std::vector<Point3f> positionList;

		while (fgets(line, MESH_LINE_MAX, fp) != NULL) {
			if (strlen(line) == 0 || line[0] == '#') {
				continue;
			}

			type = strtok_s(line, delims, &next);
			param1 = strtok_s(NULL, delims, &next);
			param2 = strtok_s(NULL, delims, &next);
			param3 = strtok_s(NULL, delims, &next);

			if (strcmp(type, "v") == 0) {          // A vertex
				float p1 = static_cast<float>(atof(param1)) * scale;
				float p2 = static_cast<float>(atof(param2)) * scale;
				float p3 = static_cast<float>(atof(param3)) * scale;

				p1 += offset.x;
				p2 += offset.y;
				p3 += offset.z;

				if (p1 < minX) minX = p1;
				if (p1 > maxX) maxX = p1;
				if (p2 < minY) minY = p2;
				if (p2 > maxY) maxY = p2;
				if (p3 < minZ) minZ = p3;
				if (p3 > maxZ) maxZ = p3;

				Point3f point(p1, p2, p3);
				positionList.push_back(point);
			}
			else if (strcmp(type, "f") == 0) {     // A face
				std::string face_str_1(param1);
				std::string face_str_2(param2);
				std::string face_str_3(param3);

				int vertexIndex1 = GetVertexIndexFromString(face_str_1);
				int vertexIndex2 = GetVertexIndexFromString(face_str_2);
				int vertexIndex3 = GetVertexIndexFromString(face_str_3);

				std::shared_ptr<Triangle> tri(new Triangle(positionList[vertexIndex1], positionList[vertexIndex2], positionList[vertexIndex3]));
				pMesh->AddObject(tri);
			}
			else {
				// Just ignore.
			}
		}

		// End of the file has been reached.
		fclose(fp);
	}
	else {
		perror("Error opening the mesh file");
		return nullptr;
	}

	Point3f center((minX + maxX) / 2.0f, (minY + maxY) / 2.0f, (minZ + maxZ) / 2.0f);
	float radius = (maxX - minX) > (maxY - minY) && (maxX - minX) > (maxZ - minZ) ? (maxX - minX) / 2.0f :
		(maxY - minY) > (maxZ - minZ) ? (maxY - minY) / 2.0f : (maxZ - minZ) / 2.0f;
	radius += 0.001f;

	pMesh->SetEnclosingSphere(center, radius);

	return pMesh;
}