void ImpressionistUI::cb_paintlyStyleChoice(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	int type = (int)v;
	pDoc->setPaintlyStyle(type);
}
void ImpressionistUI::cb_paintlyLayersSlider(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	int val = int(((Fl_Slider *)o)->value());
	pDoc->setPaintlyLayers(val);
}
void ImpressionistUI::cb_paintlyJvSlider(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	double val = double(((Fl_Slider *)o)->value());
	pDoc->setPaintlyJv(val);
}
void TriangleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;
	int size = pDoc->getSize();

	glPointSize((float)size);

	// rand size start
	if(dlg->getIsPaint() && dlg->getIsRandSize()){
		size = rand() % pDoc->getSize() + 1;
	}
	// rand size end

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_TRIANGLES);
	SetColor(source);

	glVertex2d(target.x, target.y + sqrt(0.75 * size * size) / 2);
	glVertex2d(target.x - 0.5 * size, target.y - sqrt(0.75 * size * size) / 2);
	glVertex2d(target.x + 0.5 * size, target.y - sqrt(0.75 * size * size) / 2);

	glEnd();
}
void ScatteredTriangleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;
	int size = pDoc->getSize();

	glPointSize((float)size);

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}
	for (int i = 0; i < rand() % 6 + 2; i++){

		// rand size start
		if(dlg->getIsPaint() && dlg->getIsRandSize()){
			size = rand() % pDoc->getSize() + 1;
		}
		// rand size end
		
		int randx = target.x - size / 2 + irand(size);
		int randy = target.y - size / 2 + irand(size);
		glBegin(GL_TRIANGLES);
		SetColor(source);
		glVertex2d(randx, randy + sqrt(0.75 * size * size) / 2);
		glVertex2d(randx - 0.5 * size, randy - sqrt(0.75 * size * size) / 2);
		glVertex2d(randx + 0.5 * size, randy - sqrt(0.75 * size * size) / 2);
		glEnd();
	}
}
Esempio n. 6
0
void LineBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("LineBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_LINES);

	float radius = ((float)dlg->getSize() / 2);
	Point point = { target.x, target.y };

	int counter = strcmp(BrushName(), "Scattered Lines") != 0 ? 1 : (float)dlg->getSize();

	for (int i = 0; i < counter; i++) {
		SetColor(point);

		glVertex2d(point.x - radius, point.y);
		glVertex2d(point.x + radius, point.y);

		if (counter != 1) {
			do {
				point = { Math::rand_range(target.x - radius, target.x + radius), Math::rand_range(target.y - radius, target.y + radius) };
			} while (fabs(Math::distance(point.x, point.y, target.x, target.y) - radius) > 0.05f);
		}
	}

	glEnd();
}
void ImpressionistUI::cb_strokeDirectionChoice(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI*)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();

	int type = (int)v;
	pDoc->setStrokeDirectionType(type);
}
void ImpressionistUI::cb_another_view(Fl_Menu_* o, void* v)
{
	ImpressionistUI *pUI = whoami(o);
	ImpressionistDoc *pDoc = pUI->getDocument();
	if (pDoc->m_ucAnother)
		pUI->m_origView->viewMode = OriginalView::ANOTHER_MODE;
	pUI->m_origView->refresh();
}
void ImpressionistUI::cb_filter_size_check(Fl_Widget* o, void* v)
{
	ImpressionistUI* db = (ImpressionistUI*)o->user_data();
	int w = atoi((db->m_filterWidth->value()));
	int h = atoi((db->m_filterHeight->value()));
	w = w > 1 ? w : 1;
	h = h > 1 ? h : 1;
	db->ShowFilterEntry(w, h);
	db->m_filterSizeWindow->hide();
}
Esempio n. 10
0
//---The light button callback for edge clipping---------------------
void ImpressionistUI::cb_EdgeClipping(Fl_Widget* o, void* v)
{
	ImpressionistUI *pUI = ((ImpressionistUI*)(o->user_data()));

	if (pUI->m_bEdgeClipping == TRUE) pUI->m_bEdgeClipping = FALSE;
	else {
		pUI->m_bEdgeClipping = TRUE;
		ImpressionistDoc* pDoc = pUI->getDocument();
		pDoc->CalculateEdgeMap(pUI->m_nEdgeThreshold);
	}
}
void ImpressionistUI::cb_applyFilterKernal(Fl_Widget *o, void *v) {
    ImpressionistUI *pUI = (ImpressionistUI*)o->user_data();
    pUI->m_dFilterKernal = new double[pUI->m_nFilterWidth * pUI->m_nFilterHeight];
    for (int j = 0; j < pUI->m_nFilterHeight; j++) {
        for (int i = 0; i < pUI->m_nFilterWidth; i++) {
            printf(pUI->m_filterKernalEntries[i + j * pUI->m_nFilterHeight]->value());
            pUI->m_dFilterKernal[i + j * pUI->m_nFilterHeight] = atof(pUI->m_filterKernalEntries[i + j * pUI->m_nFilterHeight]->value());
        }
    }
    pUI->getDocument()->applyFilterKernal();
}
Esempio n. 12
0
void ImpressionistUI::cb_paintlyStrokeChoice(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	int type = (int)v;
	switch (type)
	{
	case STROKE_CIRCLEBRUSH:
		pDoc->setPaintlyStroke(type);
		pDoc->setBrushType(BRUSH_CIRCLES); cout << "here" << endl;
		break;
	case STROKE_CURVEDBRUSH:
		pDoc->setPaintlyStroke(type);
		break;
	}
}
Esempio n. 13
0
void ImpressionistUI::cb_applyFilter(Fl_Widget* o, void* v)
{
	ImpressionistUI* db = (ImpressionistUI*)o->user_data();
	double* kernel = new double[db->m_nKernelH * db->m_nKernelW];
	for (int i = 0; i < db->m_nKernelH; ++i)
	{
		for (int j = 0; j < db->m_nKernelW; ++j)
		{
			int pixel = i * db->m_nKernelW + j;
			double weight = atof(db->m_EntryInputs[pixel]->value());
			//cout << weight << endl;
			kernel[pixel] = weight;
		}
	}
	
	db->getDocument()->applyCustomFilter(kernel, db->m_nKernelW, db->m_nKernelH);
	db->m_paintView->refresh();
}
void ScatteredLineBrush::BrushEnd(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;
	int strokeDirChoice = dlg->m_StrokeDirChoice->value();

	// values useful for the right mouse drag
	int dx = target.x - source.x;
	int dy = target.y - source.y;
	int size = sqrt(dx*dx + dy*dy);
	int angle = -(int)(atan2(dy, dx)*57.32) % 360;

	switch (strokeDirChoice){
		//  slider/right mouse mode
	case 0:
		if (isRightMouse){
			dlg->setAngle(angle);
			dlg->setSize(size);
		}
		break;

		// gradient mode: do nothing
	case 1:
		if (isRightMouse){
			dlg->setSize(size);
		}
		break;

		// brush direction mode
	case 2:
		if (!isRightMouse){
			prev.x = -1;
			prev.y = -1;
			current.x = -1;
			current.y = -1;
		}
		break;

	default:
		break;

	}
}
Esempio n. 15
0
void CircleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("CircleBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_TRIANGLE_FAN);
	
	float theta, pos_x, pos_y = 0.0f;
	float radius = ((float)dlg->getSize() / 2);
	Point center = { target.x, target.y };
	Point _center_;
	int counter = strcmp(BrushName(), "Scattered Circles")!=0 ? 1 : 3;

	for (int i = 0; i < counter; i++) {
		
		SetColor(center);
		
		for (int j = 0; j < 360; j++)
		{
			theta = 2 * M_PI * j / 360;
			pos_x = center.x + cos(theta) * radius;
			pos_y = center.y + sin(theta) * radius;
			glVertex2f(pos_x, pos_y);
		}

		if (counter!=1) {
			do {
				_center_ = { Math::rand_range(center.x - radius, center.x + radius), Math::rand_range(center.y - radius, center.y + radius) };
			} while (fabs(Math::distance(center.x, center.y, _center_.x, _center_.y) - radius) > 0.05f);
			center = _center_;
		}
	}

	glEnd();
}
void ScatteredPointBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}

	int size = dlg->getSize();
	double radius = size / 2.0;
	for (int i = (target.x - radius); i < target.x + radius; i++){
		for (int j = (target.y - radius); j < target.y + radius; j++){

			int random = rand() % 5;
			if (random == 0){
				glBegin(GL_POINTS);
				SetColor(Point(i,j));
				glVertex2d(i, j);
				glEnd();
				//ImpBrush::c_pBrushes[BRUSH_POINTS]->BrushMove(source, Point(i, j));
			}

		}

	}
	//DrawPoint(source);
	//printf("source = ( %d, %d )  target = ( %d, %d ) \n", source.x, source.y, target.x, target.y);
	//glBegin(GL_POINTS);
	//glColor3f(1.0f, 0.0f, 0.0f);

	//glVertex2d(source.x, source.y);
	//SetColor(source);

	//glVertex2d(target.x, target.y);

	//glEnd();
}
void ScatteredLineBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("PointBrush::BrushMove  document is NULL\n");
		return;
	}
	int size = dlg->getSize();
	double radius = size / 2.0;
	for (int i = (target.x - radius); i < target.x + radius; i++){
		for (int j = (target.y - radius); j < target.y + radius; j++){

			int random = rand() % 200;
			if (random == 0){
				ImpBrush::c_pBrushes[BRUSH_LINES]->BrushMove(source, Point(i, j));
			}

		}

	}

	/*
	//setPrevPoint(target);
	int angleType = dlg->getSelectedAngleType();
	int size = dlg->getSize();
	double angle = (dlg->getLineAngle()*M_PI) / 180;
	double radius = size / 2.0;
	double changeOfX = radius *cos(angle);
	double changeOfY = radius *sin(angle);
	glLineWidth(dlg->getLineWidth());
	//glLineWidth(10);
	//printf("%d", dlg->getLineWidth());
	glBegin(GL_LINES);

	SetColor(source);
	//angle type == slider
	if (angleType == 0){

		glVertex2d(target.x + changeOfX, target.y + changeOfY);
		glVertex2d(target.x - changeOfX, target.y - changeOfY);
	}
	//angle type == gradient
	else if (angleType == 1){

	}
	//angle type == brush direction
	else if (angleType == 2){
		Point prevPoint = getPrevPoint();
		double diffX = target.x - prevPoint.x;
		double diffY = target.y - prevPoint.y;
		double angleOfPrev;
		if (diffX != 0){
			angleOfPrev = atan(diffY / diffX) * 180 / M_PI;
			changeOfX = radius *cos(angleOfPrev);
			changeOfY = radius *sin(angleOfPrev);
			glVertex2d(target.x + changeOfX, target.y + changeOfY);
			glVertex2d(target.x - changeOfX, target.y - changeOfY);
		}
		else{
			glVertex2d(target.x, target.y + radius);
			glVertex2d(target.x, target.y - radius);
		}

	}
	glEnd();
	setPrevPoint(target);

	*/
}
void ImpressionistUI::cb_strokeDirection(Fl_Widget *o, void *v) {
    ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
    ImpressionistDoc* pDoc = pUI->getDocument();
    int direction = (int)v;
    pDoc->setBrushStrokeDirection(direction);
}
void ImpressionistUI::cb_doItButton(Fl_Widget *o, void *v) {
    ImpressionistUI *pUI = ((ImpressionistUI*)(o->user_data()));
    pUI->getDocument()->createEdgeImage();
    pUI->getDocument()->switchEdgeImage();
}
Esempio n. 20
0
void ImpressionistUI::cb_paintlyApply(Fl_Widget* o, void* v)
{
	ImpressionistUI* pUI = ((ImpressionistUI *)(o->user_data()));
	ImpressionistDoc* pDoc = pUI->getDocument();
	pUI->m_paintView->TriggerPaintly();
}
Esempio n. 21
0
void ImpressionistUI::cb_start_collage(Fl_Menu_* o, void* v)
{
	ImpressionistUI *pUI = whoami(o);
	ImpressionistDoc * pDoc = pUI->getDocument();
	pDoc->StartCollage();
}