Exemplo n.º 1
0
void RenderingWidget::mousePressEvent(QMouseEvent *e)
{
	switch (e->button())
	{
	case Qt::LeftButton:
		ptr_arcball_->MouseDown(e->pos());
		if (op_mode_ == CHOOSEBASE)
		{
			CaptureVertex(e->pos());
		}
		else
		if (op_mode_ == CHOOSECEILING)
		{
			CaptureEdge(e->pos());
		}
		else
		{
			if (!CaptureVertex(e->pos()))
			{
				CaptureEdge(e->pos());
			}
		}
		break;
	case Qt::MidButton:
		current_position_ = e->pos();
		break;
	case Qt::RightButton:
		if (op_mode_ == CHOOSEBASE)
		{
			if (captured_verts_.size() > 0)
			{
				WF_vert *u = captured_verts_[captured_verts_.size() - 1];
				captured_verts_.pop_back();
				is_captured_vert_[u->ID()] = false;
			}
		}
		else
		if (op_mode_ == CHOOSECEILING)
		{
			if (captured_edges_.size() > 0)
			{
				WF_edge *e = captured_edges_[captured_edges_.size() - 1];
				captured_edges_.pop_back();
				is_captured_edge_[e->ID()] = false;
				is_captured_edge_[e->ppair_->ID()] = false;
			}
		}
		else
		{
		}
		break;
	default:
		break;
	}

	updateGL();
}
Exemplo n.º 2
0
void SeqAnalyzer::UpdateStructure(WF_edge *e)
{
	upd_struct_.Start();

	int dual_upd = ptr_dualgraph_->UpdateDualization(e);

	/* modify D0 */
	if (dual_upd != -1)
	{
		int Ns = ptr_dualgraph_->SizeOfFreeFace();
		D0_.conservativeResize(6 * Ns);

		/* set initiate value by neighbors */
		int orig_u = ptr_dualgraph_->v_orig_id(dual_upd);
		WF_edge *eu = ptr_frame_->GetNeighborEdge(orig_u);

		VX sum_D(6);
		sum_D.setZero();
		int sum = 0;

		while (eu != NULL)
		{
			WF_vert *v = eu->pvert_;
			int dual_v = ptr_dualgraph_->v_dual_id(v->ID());
			if (dual_v != -1 && !v->isFixed())
			{
				VX tmp_D(6);
				for (int i = 0; i < 6; i++)
				{
					tmp_D[i] = D0_[6 * dual_v + i];
				}
				sum_D += tmp_D;
				sum++;
			}
			eu = eu->pnext_;
		}

		if (sum != 0)
		{
			sum_D /= sum;
		}
		for (int i = 0; i < 6; i++)
		{
			D0_[6 * (Ns - 1) + i] = sum_D[i];
		}
	}

	upd_struct_.Stop();
}
Exemplo n.º 3
0
bool RenderingWidget::CaptureEdge(QPoint mouse)
{
	if (ptr_frame_ == NULL)
	{
		return 0;
	}

	double x = 0;
	double y = 0;
	double z = 0;
	CoordinatesTransform(mouse, &x, &y, &z);

	vector<WF_edge*> edges = *(ptr_frame_->GetEdgeList());
	int M = edges.size();
	for (size_t i = 0; i < M; i++)
	{
		if (edges[i]->ID() < edges[i]->ppair_->ID())
		{
			WF_vert	u = WF_vert(x, y, z);
			WF_vert *v1 = edges[i]->pvert_;
			WF_vert *v2 = edges[i]->ppair_->pvert_;

			double delta = ptr_frame_->ArcHeight(u.RenderPos(), v1->RenderPos(), v2->RenderPos());
			if (delta < 0.007)
			{
				if (op_mode_ == NORMAL)
				{
					captured_verts_.clear();
					fill(is_captured_vert_.begin(), is_captured_vert_.end(), false);
					captured_edges_.clear();
					fill(is_captured_edge_.begin(), is_captured_edge_.end(), false);
				}
	
				if (!is_captured_edge_[i])
				{
					captured_edges_.push_back(edges[i]);
					is_captured_edge_[i] = true;
					is_captured_edge_[edges[i]->ppair_->ID()] = true;
					emit(CapturedEdge(i + 1, edges[i]->Length()));
				}

				return true;
			}
		}
	}

	return false;
}