Esempio n. 1
0
void hdSelectAreaTool::mouseDrag(hdMouseEvent &event)
{
	hdAbstractTool::mouseDrag(event);
	if(event.LeftIsDown())
	{
		drawSelectionRect(event.getView());
		int x = event.GetPosition().x, y = event.GetPosition().y;
		selectionRect.x = anchorX;
		selectionRect.y = anchorY;
		selectionRect.SetBottomRight(wxPoint(x, y));
		drawSelectionRect(event.getView());
		event.getView()->ScrollToMakeVisible(event.GetPosition());
	}
}
Esempio n. 2
0
void hdSelectAreaTool::mouseUp(hdMouseEvent &event)
{
	hdAbstractTool::mouseUp(event);
	hdGeometry g;
	//hack-fix for bug when selecting figures from right to left
	if(event.LeftUp())
	{
		if( selectionRect.width < 0 )
		{
			int tmp;
			tmp = selectionRect.width;
			selectionRect.x += tmp;
			selectionRect.width = g.ddabs(tmp);

		}
		if( selectionRect.height < 0 )
		{
			int tmp;
			tmp = selectionRect.height;
			selectionRect.y += tmp;
			selectionRect.height = g.ddabs(tmp);
		}
		//end hack-fix
		drawSelectionRect(event.getView());
		selectFiguresOnRect(event.ShiftDown(), event.getView());
		event.getView()->disableSelRectDraw();
	}
}
Esempio n. 3
0
void dumpWebViewAsPixelsAndCompareWithExpected(const char* /*currentTest*/, bool /*forceAllTestsToDumpPixels*/)
{
    RetainPtr<CGContextRef> context = getBitmapContextFromWebView();

#if PLATFORM(MAC)
    if (layoutTestController->testRepaint())
        repaintWebView(context.get(), layoutTestController->testRepaintSweepHorizontally());
    else 
        paintWebView(context.get());

    if (layoutTestController->dumpSelectionRect())
        drawSelectionRect(context.get(), getSelectionRect());
#endif

    // Compute the actual hash to compare to the expected image's hash.
    char actualHash[33];
    getMD5HashStringForBitmap(context.get(), actualHash);
    printf("\nActualHash: %s\n", actualHash);

    // FIXME: We should compare the actualHash to the expected hash here and
    // only set dumpImage to true if they don't match, but DRT doesn't have
    // enough information currently to find the expected checksum file.
    bool dumpImage = true;

    if (dumpImage) {
        RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(context.get()));
        printPNG(image.get());
    }

    printf("#EOF\n");
}
Esempio n. 4
0
// =============================================================================
// Nossa função de desenho :-)
// =============================================================================
void DesignerSurface::paintEvent(QPaintEvent* event)
{
    QPainter painter(this);
    painter.setClipRect(event->rect());

    //cout << "Repaint: " << event->rect() << endl;

    painter.fillRect(rect(), palette().color(QPalette::Normal, QPalette::Window));

    // só desenhamos a grade em modo de edição :P
    if (m_editMode && m_showGrid)
        drawGrid(painter);

    if (m_lowerWidget == this) {
        painter.setPen(Qt::red);
        painter.drawRect(rect().adjusted(0, 0, -1, -1));
    } else {
        drawParentBox(m_lowerWidget, painter);
    }

    // Desenha a caixa de seleção
    if (m_mouseState == Selecting)
        drawSelectionRect(painter);

    drawSelectionBoxes(painter);
    event->accept();
}
Esempio n. 5
0
void hdSelectAreaTool::mouseDown(hdMouseEvent &event)
{
	hdAbstractTool::mouseDown(event);
	if(!event.ShiftDown())
	{
		event.getView()->getDrawing()->clearSelection();
	}
	if(event.LeftDown())
	{
		int x = event.GetPosition().x, y = event.GetPosition().y;
		selectionRect.x = x;
		selectionRect.y = y;
		selectionRect.width = 0;
		selectionRect.height = 0;
		drawSelectionRect(event.getView());
	}
}
Esempio n. 6
0
void wxhdSelectAreaTool::mouseDown(wxhdMouseEvent& event)
{
	wxhdAbstractTool::mouseDown(event);
	if(!event.ShiftDown())
    {
		view->clearSelection();
	}
	if(event.LeftDown())
	{
		int x=event.GetPosition().x, y=event.GetPosition().y;
		selectionRect.x=x;
		selectionRect.y=y;
		selectionRect.width=0;
		selectionRect.height=0;
		drawSelectionRect();
	}
}
void OpenGLSceneViewCore::draw()
{
    ShaderProgram::resetProgram();

    float clearColor = 0.6f;
	glClearColor(clearColor, clearColor, clearColor, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glDisable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);

	setupViewportAndCamera();
    drawGrid(10, 2);
    drawManipulatedAndDisplatedForSelection(false);
    
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
    
    glColor3f(1.0f, 0.0f, 0.0f);
    
    glBegin(GL_POINTS);
    for (unsigned int i = 0; i < _vertexHints.size(); i++)
    {
        glVertex3f(_vertexHints[i].x, _vertexHints[i].y, _vertexHints[i].z);
    }
    glEnd();
    
    if (_vertexHints.size() > 1)
    {
        glBegin(GL_LINE_LOOP);
        for (unsigned int i = 0; i < _vertexHints.size(); i++)
        {
            glVertex3f(_vertexHints[i].x, _vertexHints[i].y, _vertexHints[i].z);
        }
        glEnd();
    }
    
    drawCurrentManipulator();
    
    drawOrthoDefaultManipulator();
    drawSelectionRect();
	
    glEnable(GL_DEPTH_TEST);
}
Esempio n. 8
0
void GraphWidget::draw()
{
	if (!valid()) {
		glMatrixMode(GL_PROJECTION);
		glLoadIdentity();
		glMatrixMode(GL_MODELVIEW);
		glLoadIdentity();

		glViewport(0, 0, w(), h());

		glClearColor(GRID_BACKGROUND_INTENSITY, GRID_BACKGROUND_INTENSITY, GRID_BACKGROUND_INTENSITY, 0.0);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	}

	glClear(GL_COLOR_BUFFER_BIT);

	glColor3d(0,0,0);
	glBegin(GL_POLYGON);
		glVertex2d( -w(), -h()  );
		glVertex2d( -w(),  h()  );
		glVertex2d(  w(),  h()  );
		glVertex2d(  w(), -h()  );
	glEnd();

/************************************************************************************/

	//The grid.. We're copying this from rulerwindow class.
	//Really to two should have a single reference function.
	double dRangeX = rightTime() - leftTime();
	double dRangeY = (rightTime() - leftTime());
	int iWindowWidth = w();
	int iWindowHeight = h();
	const int k_iAvgLongMarkLen = 15;

	int iLongMarkCountX = iWindowWidth / k_iAvgLongMarkLen;
	int iLongMarkCountY = iWindowHeight / k_iAvgLongMarkLen;

	if (iLongMarkCountX > 0 && iWindowWidth > 0) {
		// Computer the long mark length so that it's 10^i where i is an integer
		double dLongMarkLengthX = dRangeX / (double)iLongMarkCountX;
		double dLongMarkLengthPowX = log10(dLongMarkLengthX);
		int iLongMarkLengthPowX = (int)ceil(dLongMarkLengthPowX);
		dLongMarkLengthX = pow(10.0, (double)iLongMarkLengthPowX);

		double dLongMarkLengthY = dRangeY / (double)iLongMarkCountY;
		double dLongMarkLengthPowY = log10(dLongMarkLengthY);
		int iLongMarkLengthPowY = (int)ceil(dLongMarkLengthPowY);
		dLongMarkLengthY = pow(10.0, (double)iLongMarkLengthPowY);


		int iStartX = (int)ceil(leftTime() / dLongMarkLengthX);

		int iMarkX, iMarkY;
		double x,y;

		glColor3d(1,1,1);
		glPointSize(0.5);
		glBegin(GL_POINTS);

			do {
				iMarkX = 2*(int)(((double)iStartX * dLongMarkLengthX - leftTime()) / dRangeX * (double)iWindowWidth + 0.5) - w();
				x = (double)iMarkX / w();
				
				int iStartY = (int)ceil(leftTime() / dLongMarkLengthY);
				do{
					iMarkY = 2*(int)(((double)iStartY * dLongMarkLengthY - leftTime()) / dRangeY * (double)iWindowHeight + 0.5) - h();
					y = (double)iMarkY / h();

					glVertex2d(x,y);

					++iStartY;
				} while (iMarkY < iWindowHeight);
				
				++iStartX;
			} while (iMarkX < iWindowWidth);
		glEnd();
	}

/************************************************************************************/
	
	if (m_bHasEvent) {
		m_bHasEvent = false;

		switch (m_iEventToDo) {
			case LEFT_MOUSE_DOWN:
				selectAddCtrlPt(m_iMouseX, m_iMouseY);
				break;
			case LEFT_MOUSE_DRAG:
				dragCtrlPt(m_iMouseX, m_iMouseY);
				break;
			case LEFT_MOUSE_UP:
				break;

			case ALT_LEFT_DOWN:
				startCtrlPtSelection(m_iMouseX, m_iMouseY);
				break;
			case ALT_LEFT_DRAG:
				doCtrlPtSelection(m_iMouseX, m_iMouseY);
				break;
			case ALT_LEFT_UP:
				endCtrlPtSelection(m_iMouseX, m_iMouseY);
				break;

			case CTRL_LEFT_DOWN:
				selectCurrCurve(m_iMouseX, m_iMouseY);
				break;

			case SHIFT_LEFT_DOWN:
				removeCtrlPt(m_iMouseX, m_iMouseY);
				break;

			case RIGHT_MOUSE_DOWN:
				break;
			case RIGHT_MOUSE_DRAG:
				doZoom(m_iMouseDX, m_iMouseDY);
				break;
			case RIGHT_MOUSE_UP:
				break;

			case SHIFT_RIGHT_DOWN:
				break;
			case SHIFT_RIGHT_DRAG:
				m_bPanning = true;
				doPan(m_iMouseDX, m_iMouseDY);
				break;
			case SHIFT_RIGHT_UP:
				m_bPanning = false;
				break;

			case CTRL_RIGHT_DOWN:
				startZoomSelection(m_iMouseX, m_iMouseY);
				break;
			case CTRL_RIGHT_DRAG:
				doZoomSelection(m_iMouseX, m_iMouseY);
				break;
			case CTRL_RIGHT_UP:
				endZoomSelection(m_iMouseX, m_iMouseY);
				break;

			default:
				break;
		}

		do_callback();
	}
	drawTimeBar();
	drawActiveCurves();
	drawZoomSelectionMap();
	drawSelectionRect();
}
Esempio n. 9
0
void ListViewDelegate::paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
	QStyleOptionViewItemV4 opt = option;
	initStyleOption ( &opt, index );
	painter->save();
	painter->setClipRect ( opt.rect );

	opt.features |= QStyleOptionViewItem::WrapText;
	opt.text = index.data().toString();
	opt.textElideMode = Qt::ElideRight;
	opt.displayAlignment = Qt::AlignTop | Qt::AlignHCenter;

	QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();

	//const int iconSize =  style->pixelMetric(QStyle::PM_IconViewIconSize);
	const int iconSize = 48;
	QRect iconbox = opt.rect;
	const int textMargin = style->pixelMetric ( QStyle::PM_FocusFrameHMargin, 0, opt.widget ) + 1;
	QRect textRect = opt.rect;
	QRect textHighlightRect = textRect;
	// clip the decoration on top, remove width padding
	textRect.adjust ( textMargin,iconSize + textMargin + 5,-textMargin,0 );
	
	textHighlightRect.adjust ( 0,iconSize + 5,0,0 );

	// draw background
	{
		QSize textSize = viewItemTextSize ( &opt );
		QPalette::ColorGroup cg;
		QStyleOptionViewItemV4 opt2(opt);
		
		if((opt.widget && opt.widget->isEnabled()) || (opt.state & QStyle::State_Enabled))
		{
			if(! ( opt.state & QStyle::State_Active ))
				cg = QPalette::Inactive;
			else
				cg = QPalette::Normal;
		}
		else
		{
			cg = QPalette::Disabled;
		}
		opt2.palette.setCurrentColorGroup(cg);
		
		// fill in background, if any
		if ( opt.backgroundBrush.style() != Qt::NoBrush )
		{
			QPointF oldBO = painter->brushOrigin();
			painter->setBrushOrigin ( opt.rect.topLeft() );
			painter->fillRect ( opt.rect, opt.backgroundBrush );
			painter->setBrushOrigin ( oldBO );
		}
		
		if ( opt.showDecorationSelected )
		{
			drawSelectionRect(painter,opt2, opt.rect);
			drawFocusRect(painter,opt2, opt.rect);
			//painter->fillRect ( opt.rect, opt.palette.brush ( cg, QPalette::Highlight ) );
		}
		else
		{
			
			//if ( opt.state & QStyle::State_Selected )
			{
				//QRect textRect = subElementRect ( QStyle::SE_ItemViewItemText,  opt, opt.widget );
				//painter->fillRect ( textHighlightRect, opt.palette.brush ( cg, QPalette::Highlight ) );
				drawSelectionRect(painter,opt2, textHighlightRect);
				drawFocusRect(painter,opt2, textHighlightRect);
			}
		}
	}

	// draw the icon
	{
		QIcon::Mode mode = QIcon::Normal;
		if ( ! ( opt.state & QStyle::State_Enabled ) )
			mode = QIcon::Disabled;
		else if ( opt.state & QStyle::State_Selected )
			mode = QIcon::Selected;
		QIcon::State state = opt.state & QStyle::State_Open ? QIcon::On : QIcon::Off;

		iconbox.setHeight ( iconSize );
		opt.icon.paint ( painter, iconbox, Qt::AlignCenter, mode, state );
	}
	// set the text colors
	QPalette::ColorGroup cg = opt.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
	if ( cg == QPalette::Normal && ! ( opt.state & QStyle::State_Active ) )
		cg = QPalette::Inactive;
	if ( opt.state & QStyle::State_Selected )
	{
		painter->setPen ( opt.palette.color ( cg, QPalette::HighlightedText ) );
	}
	else
	{
		painter->setPen ( opt.palette.color ( cg, QPalette::Text ) );
	}

	// draw the text
	QTextOption textOption;
	textOption.setWrapMode ( QTextOption::WrapAtWordBoundaryOrAnywhere );
	textOption.setTextDirection ( opt.direction );
	textOption.setAlignment ( QStyle::visualAlignment ( opt.direction, opt.displayAlignment ) );
	QTextLayout textLayout;
	textLayout.setTextOption ( textOption );
	textLayout.setFont ( opt.font );
	textLayout.setText ( opt.text );

	qreal width, height;
	viewItemTextLayout ( textLayout, iconbox.width(), height, width );

	const int lineCount = textLayout.lineCount();

	const QRect layoutRect = QStyle::alignedRect ( opt.direction, opt.displayAlignment, QSize ( iconbox.width(), int ( height ) ), textRect );
	const QPointF position = layoutRect.topLeft();
	for ( int i = 0; i < lineCount; ++i )
	{
		const QTextLine line = textLayout.lineAt ( i );
		line.draw ( painter, position );
	}

	painter->restore();
}