Exemple #1
0
void axVolumeMeter::OnPaint()
{
    axGC* gc = GetGC();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);
    
    gc->SetColor(*_currentColor, _bgAlpha);
    gc->DrawRectangle(rect0);
    
    double nSeparation = 25.0;
    

    for(int i = 0; i < int(nSeparation); i++)
    {
        if(i > (1.0 - _value) * nSeparation)
        {
            // Red part.
            if(i < 7)
            {
                gc->SetColor(axColor(1.0 - (i-5.0) / 7.0, i / 7.0, 0.0, 0.6));
                gc->DrawRectangle(axRect(axPoint(1, i * rect.size.y / nSeparation), axSize(rect.size.x - 2, rect.size.y / nSeparation)));
            }
            // Green part.
            else
            {
                gc->SetColor(axColor(0.0, 1.0, 0.0, 0.6));
                gc->DrawRectangle(axRect(axPoint(1, i * rect.size.y / nSeparation), axSize(rect.size.x - 2, rect.size.y / nSeparation)));
            }
        }
    }
    
    gc->SetColor(_info.contourColor, _bgAlpha);
    gc->DrawRectangleContour(rect0);
}
Exemple #2
0
void MidiPartitionTrack::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(axColor("#AAAAAA"), 1.0);
	gc->DrawRectangle(rect0);

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);

	int delta = rect0.size.y / double(_nPart + 1.0);
	int y = delta;

	for(int i = 0; i < _nPart; i++)
	{
		gc->DrawCircle(axPoint(rect0.size.x * 0.5 - 1, y), 
			   		   rect0.size.x * 0.5 - 2, 10);

		y += delta;
	}


	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(rect0);
}
Exemple #3
0
void MenuState::draw()
{
	sf::RenderWindow& window = *getContext().window;
	window.setView(window.getDefaultView());
	sf::Texture& texture0 = getContext().textures->get(Textures::TitleScreen0);
	sf::Texture& texture1 = getContext().textures->get(Textures::TitleScreen1);
	sf::Texture& texture2 = getContext().textures->get(Textures::TitleScreen2);

	sf::IntRect rect0(0, 0, 426, getContext().window->getSize().y);
	sf::IntRect rect1(426, 0, 426, getContext().window->getSize().y);
	sf::IntRect rect2(852, 0, 428, getContext().window->getSize().y);

	mBackgroundSprite0 = sf::Sprite(texture0, rect0);
	mBackgroundSprite1 = sf::Sprite(texture1, rect1);
	mBackgroundSprite2 = sf::Sprite(texture2, rect2);

	mBackgroundSprite0 = sf::Sprite(texture0);
	mBackgroundSprite0.setPosition(sf::Vector2f(0.f, 0.f));
	mBackgroundSprite1 = sf::Sprite(texture1);
	mBackgroundSprite1.setPosition(sf::Vector2f(426.f, 0.f));
	mBackgroundSprite2 = sf::Sprite(texture2);
	mBackgroundSprite2.setPosition(sf::Vector2f(852.f, 0.f));

	// Draw the background then all the option elements to the renderwindow
	window.draw(mBackgroundSprite0);
	window.draw(mBackgroundSprite1);
	window.draw(mBackgroundSprite2);
	window.draw(mBuildInfo);

	window.draw(mStartButton);
	window.draw(mExitButton);
}
Exemple #4
0
void axToggle::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(*_currentColor);
	gc->DrawRectangle(rect0);

	if (_btnImg->IsImageReady())
	{
        if (IsFlag(Flags::SINGLE_IMG, _flags))
		{
			gc->DrawImageResize(_btnImg, axPoint(0, 0), rect.size, 1.0);
		}
		else
		{
            axPoint pos(0, _nCurrentImg * _btnImg->GetSize().y / 4);
            axSize size(_btnImg->GetSize().x, _btnImg->GetSize().y / 4);
            gc->DrawPartOfImageResize(_btnImg, pos, size,
                                      axRect(axPoint(0, 0), GetRect().size));
		}
	}

	if_not_empty(_label)
	{
		gc->SetColor(_info.font_color, 1.0);
		gc->SetFontSize(12);
		gc->DrawStringAlignedCenter(_label, rect0);
	}

	gc->SetColor(_info.contour);
	gc->DrawRectangleContour(axRect(axPoint(0, 0), rect.size));
}
void MedianFlow::filterNCC(const vector<TYPE_MF_PT> &initialPts, const vector<TYPE_MF_PT> &FPts, vector<int> &rejected)
{
    int size = int(initialPts.size());
    vector<pair<float, int> > V;
    
    for(int i = 0; i < size; i++)
    {
        if(rejected[i] & MF_REJECT_OFERROR) continue;
        
        if(!isPointInside(initialPts[i], MF_HALF_PATCH_SIZE)) continue;
        if(!isPointInside(FPts[i], MF_HALF_PATCH_SIZE)) continue;
        
        Point2d win(MF_HALF_PATCH_SIZE, MF_HALF_PATCH_SIZE);
        Point2d pt1(initialPts[i].x, initialPts[i].y);
        Point2d pt2(FPts[i].x, FPts[i].y);
        
        // must be int
        Rect_<int> rect0(pt1 - win, pt1 + win);
        Rect_<int> rect1(pt2 - win, pt2 + win);
        
        float ncc = calcNCC(this->prevImg(rect0), this->nextImg(rect1));
        
        V.push_back(make_pair(ncc, i));
    }
    
    sort(V.begin(), V.end(), compare);
    
    for(int i = int(V.size()) / 2; i < V.size(); i++)
    {
        rejected[V[i].second] |= MF_REJECT_NCC;
    }
}
Exemple #6
0
void axMenuNode::OnPaint()
{
    axGC* gc = GetGC();
    axSize size = GetSize();
    axRect rect( m_delta, 0, size.x, axMENU_NODE_HEIGHT );
	axRect rect0(0.0, 0.0, rect.size.x, rect.size.y);

    gc->SetColor(axColor(0.6, 0.6, 0.6));
    gc->DrawRectangle(rect0);

    gc->SetColor( axColor("#AAAAAA") );
    gc->SetFontSize(13);

    //cout << "Rect : " << rect.position.x << " " << rect.position.y << " " << rect.size.x << " " << rect.size.y << endl;
    gc->DrawStringAlignedCenter(m_label, rect);

    if( m_img != nullptr && m_img->IsImageReady() )
    {
        gc->DrawPartOfImage(m_img,
                            axPoint( 0, m_nCurrentImg * 12 ),
                            axSize( 12, 12 ), axPoint(m_delta + 7, 4));
    }

    // Contour.
    gc->SetColor(axColor(0.0, 0.0, 0.0));
    gc->DrawRectangleContour(axRect(0, 0, size.x, size.y));
}
Exemple #7
0
void axScrollBar::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect0(axPoint(0, 0), GetRect().size);
//
	gc->SetColor(axColor(1.0, 0.0, 0.0), 1.0);
	gc->DrawRectangle(rect0);
    
    gc->DrawRectangleColorFade(rect0,
                               axColor(0.6, 0.6, 0.6),
                               axColor(0.4, 0.4, 0.4));
//
//	// gc->DrawImageResize(_bgImg, rect0.position, rect0.size);
//
//	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
//	gc->DrawRectangleContour(axRect(axPoint(1, 1), rect0.size - axSize(1, 1) ));
//

    gc->SetColor(*_currentScrollBarColor);
	axRect bar_rect(0, _sliderPos, GetRect().size.x, _sliderHeight);
	gc->DrawRectangle(bar_rect);
    
    gc->SetColor(_info.contour);
    gc->DrawRectangleContour(bar_rect);
//
//	gc->SetColor(axColor(0.3, 0.3, 0.3), 1.0);
//	gc->DrawRectangleContour(bar_rect);
//
	gc->SetColor(_info.contour);
	gc->DrawRectangleContour(rect0);
}
Exemple #8
0
void Cutscene::Camera::onUpdateActivity(float dt)
{
    // update title
    _titleTimeout -= dt;
    if( _titleTimeout < 0 ) _titleTimeout = 0;

    // RT-RS pass
    bool flares = ( _scene->getLocation()->getWeather() == ::wtSunny ) || ( _scene->getLocation()->getWeather() == ::wtVariable );
    Gameplay::iGameplay->getRenderTarget()->render( _scene, _cameraMatrix, _cameraFOV, flares, false );

    // render title
    if( _titleTimeout > 0 )
    {
        Vector3f screenSize = Gameplay::iEngine->getScreenSize();
        float alpha = _titleTimeout / _titleFadeTime;
        if( alpha > 1 ) alpha = 1;
        if( alpha < 0 ) alpha = 0;
        gui::Rect rect0( 0, 0, int(screenSize[0]), int(screenSize[1]) );
        gui::Rect rect1( 1, 1, 1+int(screenSize[0]), 1+int(screenSize[1]) );
        Gameplay::iEngine->getDefaultCamera()->beginScene( 0, Vector4f(0,0,0,0) );
        Gameplay::iGui->renderUnicodeText(
            rect1, "title", Vector4f(0,0,0,alpha), gui::atCenter, gui::atCenter, true,
            _titleText.c_str()
        );
        Gameplay::iGui->renderUnicodeText(
            rect0, "title", Vector4f(1,1,1,alpha), gui::atCenter, gui::atCenter, true,
            _titleText.c_str()
        );
        Gameplay::iEngine->getDefaultCamera()->endScene();
    }

    // present result
    Gameplay::iEngine->present();
}
Exemple #9
0
void axGrid::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(_info.normal, 1.0);
	gc->DrawRectangle(rect0);

	gc->SetColor(_info.contour, 1.0);

	int y = 0;
	glLineWidth(1.0);
	for(int j = 0; j <= _dimension.y; j++)
	{
		int y = (double(j) / _dimension.y) * rect.size.y;
		gc->DrawLine(axPoint(0, y), axPoint(rect.size.x, y));
	}

	int x = 0;
	for(int i = 0; i <= _dimension.x; i++)
	{
		int x = (double(i) / _dimension.x) * rect.size.x;
		gc->DrawLine(axPoint(x, 0), axPoint(x, rect.size.y));
	}

	axSize element_size(1.0 / _dimension.x * rect.size.x - 1, 
						1.0 / _dimension.y * rect.size.y - 1);
	for(int j = 0;j < _dimension.y; j++)
	{
		for(int i = 0; i < _dimension.x; i++)
		{
			if(_gridElements[j][i].on)
			{
				gc->SetColor(_gridElements[j][i].color);

				axSize elem_size(floor((double(i+1)/ _dimension.x * rect.size.x)) - 
								 floor((double(i) / _dimension.x * rect.size.x)) - 1,
								1.0 / _dimension.y * rect.size.y - 1);
				gc->DrawRectangle(axRect(_gridElements[j][i].position, elem_size));
			}
		}
	}



	//_selectedElement
	gc->SetColor(axColor(0.0, 0.0, 1.0));
	//glLineWidth(4.0);
	gc->DrawRectangleContour(axRect(GetPositionOfElement(_selectedElement), element_size), 2);

	// glLineWidth(1.0);

	// gc->DrawCircle(axPoint(50, 50), 10, 500);

}
Exemple #10
0
void MenuPanel::OnPaint()
{
    axGC* gc = GetGC();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);
    
    gc->SetColor(axColor(0.4, 0.4, 0.4), 1.0);
    gc->DrawRectangle(rect0);
        
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->DrawRectangleContour(rect0);
}
Exemple #11
0
void MidiSequencer::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(axColor(0.1, 0.1, 0.1), 1.0);
	gc->DrawRectangle(rect0);

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(rect0);
}
Exemple #12
0
void CIperfView::PaintItems(CPaintDC &dc, CIperfViewItem *pa)
{
	POSITION pos;
	INT_PTR count;
	INT_PTR idx = 0;
	double x0 = 0, x1 = 0, y = 0;
	double t0, t1;
	double xstep, ystep;
	double speed;
	int fast = 0;
	CRect rect;

	count = pa->m_List.GetCount();
	GetClientRect(&rect);

    xstep = rect.Width() / 60.0;
    ystep = rect.Height() / HEIGHT;

	CPen pen(PS_SOLID, 1, pa->m_color);
	CPen* pOldPen = dc.SelectObject(&pen);


    for ( pos = pa->m_List.GetHeadPosition(); pos != NULL; pa->m_List.GetNext( pos ) )
    {
		t0 = pa->m_List.GetAt( pos ).t0;
		t1 = pa->m_List.GetAt( pos ).t1;
		if(pa->m_List.GetAt( pos ).speed) {
			speed = 10*log10(pa->m_List.GetAt( pos ).speed);
		} else {
			speed = 0;
		}

		//
		x0 = t0 * xstep;
		x1 = t1 * xstep;
		y = rect.Height() - speed * ystep;

		// point set
		CRect rect0( (int)x0-2, (int)y-2, (int)x0+2, (int)y+2);
		CRect rect1( (int)x1-2, (int)y-2, (int)x1+2, (int)y+2);

		//dc.Ellipse(rect0);
		dc.Ellipse(rect1);

		if(fast++ == 0)
			dc.MoveTo(CPoint((int)x0,(int)y));
		dc.LineTo(CPoint((int)x1,(int)y));

	}
	dc.SelectObject(pOldPen);
}
Exemple #13
0
void MyProject::OnPaint()
{
    axGC* gc = GetGC();
    axRect rect0(axPoint(0, 0), GetRect().size);
    
    gc->SetColor(axColor(0.4, 0.4, 0.4), 1.0);
    gc->DrawRectangle(rect0);
    
    gc->DrawImage(_bgImg, axPoint(0, 0));
    
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->DrawRectangleContour(rect0);
    
}
Exemple #14
0
void axMenu::OnPaint()
{
    axGC* gc = GetGC();
    axSize size = GetSize();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);

    gc->SetColor( axColor("#444444") );
    gc->DrawRectangle(rect0);

    // Contour.
    gc->SetColor(axColor("#000000"));
    gc->DrawRectangleContour(axRect(1, 1, rect0.size.x - 1, rect0.size.y - 1));
}
Exemple #15
0
void TitleBar::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->DrawRectangleColorFade(
		axRect(0, 0, rect0.size.x, rect0.size.y),// - 30),
		axColor(0.5, 0.5, 0.5), 1,
		axColor(0.3, 0.3, 0.3), 1);

	gc->SetColor(axColor(0.4, 0.4, 0.4));
	gc->DrawRectangleContour(axRect(1, 1, rect0.size.x - 1, rect0.size.y - 1));
}
Exemple #16
0
void ScrollDrumMachine::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(axColor(0.1, 0.1, 0.1), 1.0);
	gc->DrawRectangle(rect0);

	gc->DrawImage(_side_img, axPoint(0, 0));
	gc->DrawImage(_side_img, axPoint(rect0.size.x - 45, 0));

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(rect0);
}
Exemple #17
0
void ax::NumberBox::OnPaint(ax::GC gcs)
{
	ax::GC* gc = &gcs;
	ax::Rect rect0(win->dimension.GetDrawingRect());
	ax::Rect rect(win->dimension.GetRect());

	gc->SetColor(_currentColor);
	gc->DrawRectangle(rect0);

	widget::Component::Ptr widget = win->component.Get<widget::Component>("Widget");
	ax::NumberBox::Info& info = *static_cast<ax::NumberBox::Info*>(widget->GetInfo());

	if (_bgImg->IsImageReady()) {
		if (info.single_img) {
			if (ax::IsFlag(Flags::NO_IMG_RESIZE, _flags)) {
				gc->DrawImage(_bgImg, ax::Point(0, 0));
			}
			else {
				gc->DrawImageResize(_bgImg, ax::Point(0, 0), rect0.size);
			}
		}
		else {
			gc->DrawPartOfImage(_bgImg, ax::Point(0, _nCurrentImg * rect.size.y), rect.size, ax::Point(0, 0));
		}
	}

	gc->SetColor(info.font_color);

	if (_type == ax::Utils::Control::Type::REAL) {
		std::string v = std::to_string(_value);
		if (_value < 0) {
			v.resize(5);
		}
		else {
			v.resize(4);
		}

		gc->DrawStringAlignedCenter(*_font, v, rect0);
	}
	else if (_type == ax::Utils::Control::Type::INTEGER) {
		std::string v = std::to_string((int)_value);
		gc->DrawStringAlignedCenter(*_font, v, rect0);
	}

	gc->SetColor(info.contour);
	gc->DrawRectangleContour(rect0);
}
Exemple #18
0
void MidiPartition::OnPaint()
{
	axGC* gc = GetGC();
	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	gc->SetColor(axColor(0.3, 0.3, 0.3), 1.0);
	gc->DrawRectangle(rect0);

	DrawLines(gc, rect0);
	DrawHeighlightedCircle(gc, rect0);
	DrawCircles(gc, rect0);
	DrawSelectedCircle(gc, rect0);

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(rect0);
}
Exemple #19
0
void MyScrollPanel::OnPaint()
{
    
    axGC* gc = GetGC();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);
    
//    gc->SetColor(axColor(1.0, 0.0, 1.0, 0.4));
//    gc->DrawRectangle(rect0);
    
    gc->DrawRectangleColorFade(rect0,
                               axColor(0.0, 1.0, 0.0),
                               axColor(0.0, 0.0, 1.0));
    
    

    
}
Exemple #20
0
void SliderPanel::OnPaint()
{
    axGC* gc = GetGC();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);
    
    gc->SetColor(axColor(1.0, 1.0, 1.0), 1.0);
    gc->DrawRectangle(rect0);
    
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->SetFontSize(12);
    //    gc->DrawStringAlignedCenter("test", rect0);
    gc->DrawString("regular", axPoint(350, 80));
    gc->DrawString("with back slider", axPoint(350, 100));
    gc->DrawString("no slider", axPoint(350, 120));
    gc->DrawString("click anywhere", axPoint(350, 140));
    gc->DrawString("right align", axPoint(350, 160));
    gc->DrawString("no button", axPoint(350, 180));
    gc->DrawString("center align", axPoint(350, 200));
    
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->DrawRectangleContour(rect0);
}
Exemple #21
0
void FileDialog::OnPaint()
{
	axGC* gc = GetGC();

	axRect rect(GetRect());
	axRect rect0(axPoint(0, 0), rect.size);

	// Background.
	gc->SetColor(axColor(0.9, 0.9, 0.9), 1.0);
	gc->DrawRectangle(rect0);

	// Icon bar.
	axRect iconBarRect(1, 1, rect0.size.x - 1, 31);
	gc->DrawRectangle(iconBarRect);
	gc->DrawRectangleColorFade(iconBarRect, 
							  axColor(0.6, 0.6, 0.6), 1.0, 
							  axColor(0.7, 0.7, 0.7), 1.0);


	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(iconBarRect);

	// Folder name.
	gc->SetColor(axColor(0.2, 0.2, 0.2), 1.0);
	gc->SetFontSize(14);
	gc->DrawString(_dirNavigation->GetCurrentDirectoryName(), axPoint(50, 7));

	axRect buttonBarRect(1, rect0.size.y - 30, rect0.size.x - 1, 30);
	gc->DrawRectangle(buttonBarRect);
	gc->DrawRectangleColorFade(buttonBarRect, 
							  axColor(0.6, 0.6, 0.6), 1.0, 
							  axColor(0.7, 0.7, 0.7), 1.0);

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(buttonBarRect);
}
Exemple #22
0
void MainWindow::paintEvent(QPaintEvent *)
{
	QPainter painter(this);

	QRect rect0(10, 10, 20, 20);
	painter.setPen(Qt::red);
	// painter.setClipRect(rect0);
	painter.drawRect(rect0);

	QRect rect1(10, 35, 20, 20);
	painter.setPen(Qt::NoPen);
	painter.setClipRect(rect1);
	painter.fillRect(rect1, Qt::red);

	QRect rect2(10, 60, 20, 20);
	painter.setClipRect(rect2);
	painter.fillRect(rect2, Qt::red);

	QRect rect3(10, 85, 20, 20);
	painter.setPen(Qt::blue);
	painter.setClipRect(rect3);
	painter.drawLine(0, 90, 100, 90);
	painter.drawLine(20, 0, 20, 200);
}
Exemple #23
0
void FolderContent::OnPaint()
{
	BlockDrawing();

	axGC* gc = GetGC();
	axRect rect0(axPoint(0, 0), GetRect().size);

	gc->SetColor(axColor(0.9, 0.9, 0.9), 1.0);
	gc->DrawRectangle(axRect(1, 1, rect0.size.x - 2, rect0.size.y -1));

	// Folder Content.
	axColor col1(0.7, 0.7, 0.7);
	axColor col2(0.8, 0.8, 0.8);

	int y = 0;
	int x = 40;
	gc->SetFontSize(12);

	deque<DirectoryNavigation::FileInfo>& dirNames = *_dirNavigation->GetFileInfoDeque();

	for(int i = 0; i < dirNames.size(); i++)
	{
		if(i % 2) gc->SetColor(col1);
		else gc->SetColor(col2);
		
		// Draw file background.
		axRect backfileRect(1, y, rect0.size.x - 1, 24);
		gc->DrawRectangle(backfileRect);

		// Draw file highlight.
		if(_selected_file == i)
		{
			gc->SetColor(axColor(0.7, 0.7, 1.0), 0.5);

			axRect selected_rect(1, y, rect0.size.x - 2, 24);
			gc->DrawRectangle(selected_rect);
			gc->DrawRectangleColorFade(selected_rect, 
						  			   axColor(0.7, 0.7, 0.7), 0.5, 
						 			   axColor(0.8, 0.8, 0.8), 0.5);
		}

		// Draw file icon.
		if(dirNames[i].second != DirectoryNavigation::ICON_NONE)
		{
			gc->DrawImageResize(_icons[dirNames[i].second], axPoint(3, y), axSize(24, 24));
		}

		// Draw file name.
		gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
		gc->DrawString(dirNames[i].first, axPoint(x, y+4));

		y += 24;
	
		if(i > 30)
		{
			break;
		}
	}

	gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
	gc->DrawRectangleContour(axRect(1, 1, rect0.size.x - 1, rect0.size.y - 1));

	UnBlockDrawing();
}
Exemple #24
0
void PaintPanel::OnPaint()
{
    axGC* gc = GetGC();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);
    
    gc->SetColor(axColor(0.4, 0.4, 0.4), 1.0);
    gc->DrawRectangle(rect0);
    
    
    
    gc->SetColor(axColor(0.9, 0.4, 0.4, 0.5));
    gc->DrawRectangle(axRect(2, 2, 10, 10));
    
    gc->BlockDrawing(axRect(40, 40, 50, 50));
    gc->SetColor(axColor(0.9, 0.4, 0.4), 1.0);
    gc->DrawRectangle(axRect(40, 40, 50, 50));
    
    
    gc->SetColor(axColor(0.9, 0.4, 0.9), 1.0);
    gc->DrawRectangle(axRect(100, 40, 50, 50));
    gc->SetColor(axColor(0.0, 1.0, 0.0), 1.0);
    gc->DrawRectangleContour(axRect(100, 40, 50, 50));
    

    gc->SetColor(axColor(0.9, 0.9, 0.4), 1.0);
    gc->DrawRectangleContour(axRect(160, 40, 50, 50));
    
    
    gc->DrawRectangleColorFade(axRect(220, 40, 50, 50),
                               axColor(0.3, 0.8, 0.2),
                               1.0,
                               axColor(0.3, 0.8, 0.8),
                               1.0);
    
    gc->SetLineWidth(0.5);
    gc->SetColor(axColor(0.0, 0.0, 1.0), 1.0);
    gc->DrawCircle(axPoint(305, 65), 25.0, 3);
    
    gc->SetLineWidth(1.0);
    gc->SetColor(axColor(1.0, 0.0, 1.0), 1.0);
    gc->DrawCircle(axPoint(365, 65), 25.0, 4);
    
    gc->SetLineWidth(2.0);
    gc->SetColor(axColor(0.0, 1.0, 1.0), 1.0);
    gc->DrawCircle(axPoint(425, 65), 25.0, 5);

    gc->SetLineWidth(3.0);
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->DrawCircle(axPoint(485, 65), 25.0, 40);
    
    gc->DrawImage(dog_cat_img, axPoint(40, 100));
    gc->DrawImageResize(dog_cat_img,
                        axPoint(250, 100),
                        axSize(90, 70),
                        1.0);
    
    gc->DrawImageResize(dog_cat_img,
                        axPoint(340, 100),
                        axSize(90, 70),
                        0.35);
    
    gc->DrawPartOfImage(dog_cat_img,
                        axPoint(0, 0),
                        axSize(60, 45),
                        axPoint(430, 100));
    
    gc->SetLineWidth(3.0);
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    
    int y1 = 350, y2 = 250;
    double w = 1.0;
    for(int i = 0; i < 6; i++, y1 += 10, y2 += 10, w += 1.0)
    {
        gc->DrawLine(axPoint(40, y1), axPoint(300, y2), w);
    }
    
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->SetFontSize(12);
    gc->DrawString("Default 12", axPoint(350, 190));
    
    gc->SetFontSize(14);
    gc->DrawString("Default 14", axPoint(350, 205));
    
    gc->SetColor(axColor(0.0, 1.0, 0.0), 1.0);
    gc->SetFontSize(20);
    gc->DrawString("Default 20", axPoint(350, 220));

    
    gc->SeDefaultLine();
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    
    gc->DrawRoundedRectangle(axRect(350, 350, 50, 20));
    gc->DrawRectangleContour(rect0);
    
    
    gc->UnBlockDrawing();
    

}
static void draw_graph(
    QPainter &painter,
    int w, /* width */
    int h, /* height */
    int margin, 
    double *X, /* x-values */
    double *Y, /* y-values */
    unsigned int N /* number of X[], Y[] */
    )
{
    if ((w <= 3*margin) || (h <= 2*margin))
       return;

    /* Qt coordinate system */
    int x0 = 2*margin;
    int x1 = w - margin;
    int y0 = margin;
    int y1 = h - margin;

    if (x0 >= x1) return;
    if (y0 >= y1) return;

    /* draw boundary rectangle */
    QRectF rectangle(x0, y0, x1-x0, y1-y0);
    painter.drawRect(rectangle);

    if (!X || !Y || !N)
       return;

    double Ymin = 0.0;
    double Ymax = 1.0;
    double Xmin = X[0];
    double Xmax = X[0];
    for(uint32_t i=1; i < N; i++) {
       double x = X[i];
       if (x < Xmin) Xmin = x;
       if (x > Xmax) Xmax = x;
    }

    if ((Xmax > Xmin) && (Ymax > Ymin)) {
        /* allocate */
        QPoint **points = (QPoint **) malloc(N*sizeof(QPoint *));

        /* convert to qt coordinate system */
        for(uint32_t i=0; i < N; i++) {
            int x = (int) (x0 + (x1 - x0) * (X[i] - Xmin) / (Xmax - Xmin));
            int y = (int) (y1 - (y1 - y0) * (Y[i] - Ymin) / (Ymax - Ymin));
            points[i] = new QPoint(x, y);
        }

        /* order along horizontal axis */
        qsort((void *)points, N, sizeof(QPoint *), qpoint_cmp);

        /* draw line */
        for(uint32_t i=0; i+1 < N; i++)
            painter.drawLine(*points[i], *points[i+1]);

        int labelwidth = 3*margin/2;
        int labelheight = margin;
        const char *labelfmtX = "%.0f";
        const char *labelfmtY = "%.2f";

        char label[32];
        uint32_t labelsz = sizeof(label) - 1;

        /* draw horizontal labels */
        snprintf(label, labelsz, labelfmtX, Xmin);
        QString XminStr = label;
        QRectF rect0(x0-labelwidth/2, y1, labelwidth, labelheight);
        painter.drawText(rect0, Qt::AlignCenter, XminStr);

        snprintf(label, labelsz, labelfmtX, Xmax);
        QString XmaxStr = label;
        QRectF rect1(x1-labelwidth/2, y1, labelwidth, labelheight);
        painter.drawText(rect1, Qt::AlignCenter, XmaxStr);

        /* draw vertical labels */
        snprintf(label, labelsz, labelfmtY, Ymin);
        QString YminStr = label;
        QRectF rect2(x0-labelwidth, y1-labelheight/2, labelwidth, labelheight);
        painter.drawText(rect2, Qt::AlignCenter, YminStr);

        snprintf(label, labelsz, labelfmtY, Ymax);
        QString YmaxStr = label;
        QRectF rect3(x0-labelwidth, y0-labelheight/2, labelwidth, labelheight);
        painter.drawText(rect3, Qt::AlignCenter, YmaxStr);

        /* clean up */
        for(uint32_t i=0; i < N; i++)
            delete points[i];
        free(points);
    }
    else
    if ((Xmin == Xmax) && (Ymin == Ymax)) {
        /* draw point */
    }
    else
    if (Xmin == Xmax) {
        /* draw vertical line */
    }
    else
    if (Ymin == Ymax) {
        /* draw horizontal line */
    }
}
Exemple #26
0
//static int nDraw = 0;
void axWaveform::OnPaint()
{
//    nDraw++;
//    std::cout << "nDraw : " << nDraw << std::endl;

    axGC* gc = GetGC();
    axRect rect(GetRect());
    axRect rect0(axPoint(0, 0), rect.size);
    
    gc->SetColor(axColor(0.5, 0.5, 0.5), 1.0);
    gc->DrawRectangle(rect0);
    
    if(_audioBuffer != nullptr)
    {
        axBufferInfo b_info = _audioBuffer->GetBufferInfo();
        float* buffer = _audioBuffer->GetBuffer();
        int middle_y = rect.size.y * 0.5;
        
        gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);

        double nSamplesToProcess = double(b_info.frames) * _zoom;
        
        // Not a 100% sure about 1 + ..
        int index = 1 + b_info.frames * _leftPos;
        
        int changing_pixel = 0; // Just for debugging.
        int nSamplePerPixel = 0;
        
        double min_value_pixel = 1000.0;
        double max_value_pixel = -1000.0;
        
        // Ratio of number of pixel over number of sample to draw.
        double r = double(rect.size.x-2) / nSamplesToProcess;
        
        for(int i = 1; i < floor(nSamplesToProcess); i++, index++)
        {
            // Pixel position.
            double x_pos_left = double(i-1) * r;
            double x_pos_right = double(i) * r;
            
            double l_value = buffer[index - 1];
            double r_value = buffer[index];
            
            if(l_value < min_value_pixel) min_value_pixel = l_value;
            if(l_value > max_value_pixel) max_value_pixel = l_value;
            if(r_value < min_value_pixel) min_value_pixel = r_value;
            if(r_value > max_value_pixel) max_value_pixel = r_value;
            
            // Increment sample at each iteration.
            nSamplePerPixel++;
            
            // If pixel has change.
            if(int(x_pos_left) != int(x_pos_right))
            {
                if(nSamplePerPixel > 1)
                {
                    // Pixel value.
                    int y_pixel_left = middle_y - min_value_pixel * 0.9 * middle_y;
                    int y_pixel_right = middle_y - max_value_pixel * 0.9 * middle_y;
                    
                    // Draw min to max line on the left pixel.
                    gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                                 axPoint(x_pos_left, y_pixel_right));
                    
                    // Draw last value of left pixel and first value of right
                    // pixel. This is to make sure that horizontal lines will be
                    // drawn if necessary. A liason between each vertical lines.
                    y_pixel_left = middle_y - l_value * 0.9 * middle_y;
                    y_pixel_right = middle_y - r_value * 0.9 * middle_y;
                    
                    gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                                 axPoint(x_pos_right, y_pixel_right));
                }
                // One sample or less per pixel.
                else
                {
                    // Pixel value.
                    int y_pixel_left = middle_y - l_value * 0.9 * middle_y;
                    int y_pixel_right = middle_y - r_value * 0.9 * middle_y;
                    
                    gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                                 axPoint(x_pos_right, y_pixel_right));
                }
                
                changing_pixel++;
                nSamplePerPixel = 0;
                min_value_pixel = 1000.0;
                max_value_pixel = -1000.0;
            }
        }
        
        // Draw middle line.
        gc->SetColor(axColor(0.7, 0.7, 0.7), 0.4);
        gc->DrawLine(axPoint(1, middle_y), axPoint(rect.size.x - 2, middle_y));
    }
    
    //--------------------------------------------------------------------------
    if(_envBuffer != nullptr)
    {
        if((*_envBuffer).size() && _showEnv)
        {
            //        axBufferInfo b_info = _audioBuffer->GetBufferInfo();
            //        float* buffer = _audioBuffer->GetBuffer();
            int middle_y = rect.size.y * 0.5;
            
            gc->SetColor(axColor(1.0, 0.0, 0.0), 1.0);
            
            double nSamplesToProcess = double((*_envBuffer).size()) * _zoom;
            
            // Not a 100% sure about 1 + ..
            int index = 1 + (*_envBuffer).size() * _leftPos;
            
            int changing_pixel = 0; // Just for debugging.
            int nSamplePerPixel = 0;
            
            double min_value_pixel = 1000.0;
            double max_value_pixel = -1000.0;
            
            // Ratio of number of pixel over number of sample to draw.
            double r = double(rect.size.x-2) / nSamplesToProcess;
            
            for(int i = 1; i < floor(nSamplesToProcess); i++, index++)
            {
                // Pixel position.
                double x_pos_left = double(i-1) * r;
                double x_pos_right = double(i) * r;
                
                double l_value = (*_envBuffer)[index - 1];
                double r_value = (*_envBuffer)[index];
                
                if(l_value < min_value_pixel) min_value_pixel = l_value;
                if(l_value > max_value_pixel) max_value_pixel = l_value;
                if(r_value < min_value_pixel) min_value_pixel = r_value;
                if(r_value > max_value_pixel) max_value_pixel = r_value;
                
                // Increment sample at each iteration.
                nSamplePerPixel++;
                
                // If pixel has change.
                if(int(x_pos_left) != int(x_pos_right))
                {
                    if(nSamplePerPixel > 1)
                    {
                        // Pixel value.
                        int y_pixel_left = middle_y - min_value_pixel * 0.9 * middle_y;
                        int y_pixel_right = middle_y - max_value_pixel * 0.9 * middle_y;
                        
                        // Draw min to max line on the left pixel.
                        gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                                     axPoint(x_pos_left, y_pixel_right));
                        
                        // Draw last value of left pixel and first value of right
                        // pixel. This is to make sure that horizontal lines will be
                        // drawn if necessary. A liason between each vertical lines.
                        y_pixel_left = middle_y - l_value * 0.9 * middle_y;
                        y_pixel_right = middle_y - r_value * 0.9 * middle_y;
                        
                        gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                                     axPoint(x_pos_right, y_pixel_right));
                    }
                    // One sample or less per pixel.
                    else
                    {
                        // Pixel value.
                        int y_pixel_left = middle_y - l_value * 0.9 * middle_y;
                        int y_pixel_right = middle_y - r_value * 0.9 * middle_y;
                        
                        gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                                     axPoint(x_pos_right, y_pixel_right));
                    }
                    
                    changing_pixel++;
                    nSamplePerPixel = 0;
                    min_value_pixel = 1000.0;
                    max_value_pixel = -1000.0;
                }
            }
            
        }
    }
    
    if(_envPoints != nullptr)
    {
        if((*_envPoints).size() && _showEnv)
        {
            int middle_y = rect.size.y * 0.5;
            
//            gc->SetColor(axColor(0.0, 1.0, 0.0), 1.0);
//            
//            for(auto& n : *_envPoints)
//            {
//                double x_pos = n.x * GetRect().size.x;
//                gc->DrawLine(axPoint(x_pos, middle_y),
//                             axPoint(x_pos, middle_y - n.y * 0.9 * middle_y));
//                
////                std::cout << n.x << " " << n.y << std::endl;
//            }
            
            gc->SetColor(axColor(0.0, 0.0, 1.0), 1.0);
            
            for(int i = 1; i < (*_envPoints).size(); i++)
            {
                double x_pos_left = (*_envPoints)[i-1].x * GetRect().size.x;
                double x_pos_right = (*_envPoints)[i].x * GetRect().size.x;
                int y_pixel_left = middle_y - (*_envPoints)[i-1].y * 0.9 * middle_y;
                int y_pixel_right = middle_y - (*_envPoints)[i].y * 0.9 * middle_y;
                
                gc->DrawLine(axPoint(x_pos_left, y_pixel_left),
                             axPoint(x_pos_right, y_pixel_right));
//                gc->DrawLine(axPoint(x_pos, middle_y),
//                             axPoint(x_pos, middle_y - n.y * 0.9 * middle_y));
                
                //                std::cout << n.x << " " << n.y << std::endl;
            }
        }
    }
    

    // Draw contour.
    gc->SetColor(axColor(0.0, 0.0, 0.0), 1.0);
    gc->DrawRectangleContour(rect0);
}
Exemple #27
0
void StereogramWidget::paintEvent(QPaintEvent* event)
{
	m_radius = 0; //means that nothing has been drawn (yet ;)

	QLabel::paintEvent(event);
	QPainter painter(this);
	painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, true);

	//pen
	QPen pen;
	pen.setStyle(Qt::SolidLine);
	pen.setBrush(QColor(Qt::black));

	int diameter = std::min(width(),height());
	int halfW = width()/2;
	int halfH = height()/2;
	QPoint center(halfW,halfH);

	int hsvThickness = 0;
	if (m_showHSVRing)
	{
		int newDiameter = static_cast<int>(ceil(0.9*static_cast<double>(diameter))); 
		hsvThickness = diameter - newDiameter;

		//TODO
		if (hsvThickness > 0)
		{
			QRect rectangle(center.x()-diameter/2+1,center.y()-diameter/2+1,diameter-2,diameter-2);
			int angle_span = static_cast<int>(m_angularStep_deg * 16.0); //see QPainter::drawPie
			QBrush brush;
			brush.setStyle(Qt::SolidPattern);
			painter.setPen(Qt::NoPen);

			//dip direction steps (dip dir. in [0,360])
			unsigned ddSteps = static_cast<unsigned>(ceil(360.0 / std::max(m_angularStep_deg,1.0)));
			for (unsigned j=0; j<ddSteps; ++j)
			{
				double dipDir_deg = static_cast<double>(j) * m_angularStep_deg;

				//set family color
				ccColor::Rgb col;
				FacetsClassifier::GenerateSubfamilyColor(col, 90.0, dipDir_deg + 0.5 * m_angularStep_deg, 0, 1);
				brush.setColor(QColor(	static_cast<int>(col.r),
										static_cast<int>(col.g),
										static_cast<int>(col.b),
										255));
				painter.setBrush(brush);

				int angle_start = static_cast<int>((360.0 - dipDir_deg - m_angularStep_deg + 90.0) * 16.0); //see QPainter::drawPie
				painter.drawPie(rectangle,angle_start,angle_span);
			}
		}

		diameter = newDiameter; 
	}

	//outer circle
	pen.setWidth(2);
	painter.setPen(pen);
	painter.setBrush(Qt::white);
	int radius = diameter/2 - 2;
	painter.drawEllipse(center,radius,radius);
	painter.setBrush(Qt::NoBrush);

	//keep track of the circle position
	m_radius = radius;
	m_center = center;

	//main axes
	painter.drawLine(center-QPoint(radius,0),center+QPoint(radius,0));
	painter.drawLine(center-QPoint(0,radius),center+QPoint(0,radius));

	//draw circles
	if (m_angularStep_deg > 0)
	{
		//dip steps (dip in [0,90])
		unsigned dSteps = static_cast<unsigned>(ceil(90.0 / m_angularStep_deg));
		//dip direction steps (dip dir. in [0,360])
		unsigned ddSteps = static_cast<unsigned>(ceil(360.0 / m_angularStep_deg));

		//draw inner circles
		pen.setWidth(1);
		pen.setColor(Qt::gray);
		painter.setPen(pen);
		for (unsigned i=1; i<dSteps; ++i)
		{
			double dip_deg = static_cast<double>(i) * m_angularStep_deg;
			if (dip_deg < 90.0)
			{
				int R = static_cast<int>(static_cast<double>(radius) * (dip_deg/90.0));
				if (R > 1)
					painter.drawEllipse(center,R-1,R-1);
			}
		}

		//draw rays (+ 'm_ticksFreq' times more ticks)
		int ticksFreq = std::max(m_ticksFreq,1);
		for (unsigned j=1; j<=ddSteps*ticksFreq; ++j)
		{
			double dipDir_deg = static_cast<double>(j) * m_angularStep_deg / static_cast<double>(ticksFreq);
			if (dipDir_deg < 360.0)
			{
				QPoint X(	 static_cast<int>(sin(dipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)),
					-static_cast<int>(cos(dipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)) );

				if ((j % ticksFreq) == 0) //long ticks
					painter.drawLine(center,center+X);
				else
					painter.drawLine(center+X*0.93,center+X);
			}
		}
	}

	//draw density map
	if (m_densityGrid && m_densityColorScale && m_densityGrid->grid && m_densityGrid->minMaxDensity[1] != 0)
	{
		assert(m_densityColorScale);
		assert(m_densityGrid->grid);

		QBrush brush;
		brush.setStyle(Qt::SolidPattern);
		painter.setPen(Qt::NoPen);
		QPolygon poly(4);

		const double* d = m_densityGrid->grid;
		for (unsigned j=0; j<m_densityGrid->ddSteps; ++j)
		{
			double dipDir0_rad = static_cast<double>(j) * m_densityGrid->step_deg * CC_DEG_TO_RAD;
			double dipDir1_rad = static_cast<double>(j+1) * m_densityGrid->step_deg * CC_DEG_TO_RAD;
			double cos_dipDir0 = cos(dipDir0_rad);
			double sin_dipDir0 = sin(dipDir0_rad);
			double cos_dipDir1 = cos(dipDir1_rad);
			double sin_dipDir1 = sin(dipDir1_rad);

			for (unsigned i=0; i<m_densityGrid->rSteps; ++i, ++d)
			{
				if (*d != 0)
				{
					double relPos = static_cast<double>(*d)/static_cast<double>(m_densityGrid->minMaxDensity[1]);
					const colorType* col = m_densityColorScale->getColorByRelativePos(relPos,m_densityColorScaleSteps);
					brush.setColor(QColor(	static_cast<int>(col[0]),
						static_cast<int>(col[1]),
						static_cast<int>(col[2]),
						255));
					painter.setBrush(brush);

					//stereographic projection
					//double dip0_rad = static_cast<double>(i) * m_densityGrid->step_deg * CC_DEG_TO_RAD;
					//double dip1_rad = static_cast<double>(i+1) * m_densityGrid->step_deg * CC_DEG_TO_RAD;
					//double R0 = static_cast<double>(radius) * cos(dip0_rad) / (1.0 + sin(dip0_rad));
					//double R1 = static_cast<double>(radius) * cos(dip1_rad) / (1.0 + sin(dip1_rad));
					double R0 = static_cast<double>(radius) * static_cast<double>(i) * m_densityGrid->step_R;
					double R1 = static_cast<double>(radius) * static_cast<double>(i+1) * m_densityGrid->step_R;

					poly.setPoint(0,center+QPoint(static_cast<int>(sin_dipDir0 * R0),-static_cast<int>(cos_dipDir0 * R0)));
					poly.setPoint(1,center+QPoint(static_cast<int>(sin_dipDir0 * R1),-static_cast<int>(cos_dipDir0 * R1)));
					poly.setPoint(2,center+QPoint(static_cast<int>(sin_dipDir1 * R1),-static_cast<int>(cos_dipDir1 * R1)));
					poly.setPoint(3,center+QPoint(static_cast<int>(sin_dipDir1 * R0),-static_cast<int>(cos_dipDir1 * R0)));

					painter.drawPolygon(poly);
				}
			}
		}
	}

	//draw main 'dip direction'
	if (m_meanDipDir_deg >= 0)
	{
		pen.setWidth(2);
		pen.setColor(Qt::red);
		painter.setPen(pen);
		//draw main direction
		QPoint X(	 static_cast<int>(sin(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)),
			-static_cast<int>(cos(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)) );
		pen.setStyle(Qt::DashLine);
		painter.setPen(pen);
		painter.drawLine(center,center+X);

		//draw orthogonal to main direction
		QPoint Y(	static_cast<int>(cos(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)),
			static_cast<int>(sin(m_meanDipDir_deg * CC_DEG_TO_RAD) * static_cast<double>(radius)) );
		pen.setStyle(Qt::SolidLine);
		painter.setPen(pen);
		painter.drawLine(center-Y,center+Y);
	}

	//draw filter window around last cliked point
	if (m_trackMouseClick)
	{
		pen.setWidth(2);
		pen.setColor(Qt::magenta);
		painter.setPen(pen);
		//QBrush brush;
		//brush.setStyle(Qt::Dense6Pattern);
		//brush.setColor(Qt::red);
		//painter.setBrush(brush);
		painter.setBrush(Qt::NoBrush);

		double R0 = static_cast<double>(radius) * (std::max(0.0,m_clickDip_deg-m_clickDipSpan_deg/2)/90.0);
		double R1 = static_cast<double>(radius) * (std::min(90.0,m_clickDip_deg+m_clickDipSpan_deg/2)/90.0);

		//draw radial limits
		{
			QPoint X0(	 static_cast<int>(sin((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0),
				-static_cast<int>(cos((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0) );
			QPoint X1(	 static_cast<int>(sin((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1),
				-static_cast<int>(cos((m_clickDipDir_deg-m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1) );
			painter.drawLine(center+X0,center+X1);
		}
		{
			QPoint X0(	 static_cast<int>(sin((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0),
				-static_cast<int>(cos((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R0) );
			QPoint X1(	 static_cast<int>(sin((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1),
				-static_cast<int>(cos((m_clickDipDir_deg+m_clickDipDirSpan_deg/2) * CC_DEG_TO_RAD) * R1) );
			painter.drawLine(center+X0,center+X1);
		}

		//draw concentric limits
		{
			int angle_start = static_cast<int>((360.0 - m_clickDipDir_deg - m_clickDipDirSpan_deg/2 + 90.0) * 16.0); //see QPainter::drawPie
			int angle_span = static_cast<int>(m_clickDipDirSpan_deg * 16.0); //see QPainter::drawPie

			QRectF rect0(static_cast<double>(center.x()) - R0,
				static_cast<double>(center.y()) - R0,
				2*R0, 2*R0);
			painter.drawArc(rect0,angle_start,angle_span);

			QRectF rect1(static_cast<double>(center.x()) - R1,
				static_cast<double>(center.y()) - R1,
				2*R1, 2*R1);
			painter.drawArc(rect1,angle_start,angle_span);
		}
	}
}
//---------------------------------------------------------------------------
cv::Rect TKalmanFilter::Update(cv::Rect rect, bool dataCorrect)
{
    if (!m_initialized)
    {
        if (m_initialRects.size() < MIN_INIT_VALS)
        {
            if (dataCorrect)
            {
                m_initialRects.push_back(rect);
            }
        }
        if (m_initialRects.size() == MIN_INIT_VALS)
        {
            std::vector<Point_t> initialPoints;
            Point_t averageSize(0, 0);
            for (const auto& r : m_initialRects)
            {
                initialPoints.push_back(Point_t(r.x, r.y));
                averageSize.x += r.width;
                averageSize.y += r.height;
            }
            averageSize.x /= MIN_INIT_VALS;
            averageSize.y /= MIN_INIT_VALS;

            track_t kx = 0;
            track_t bx = 0;
            track_t ky = 0;
            track_t by = 0;
            get_lin_regress_params(initialPoints, 0, MIN_INIT_VALS, kx, bx, ky, by);
            cv::Rect_<track_t> rect0(kx * (MIN_INIT_VALS - 1) + bx, ky * (MIN_INIT_VALS - 1) + by, averageSize.x, averageSize.y);
            Point_t rectv0(kx, ky);

            switch (m_type)
            {
            case TypeLinear:
                CreateLinear(rect0, rectv0);
                break;

            case TypeUnscented:
#if USE_OCV_UKF
                CreateUnscented(rect0, rectv0);
#else
                CreateLinear(rect0, rectv0);
                std::cerr << "UnscentedKalmanFilter was disabled in CMAKE! Set KalmanLinear in constructor." << std::endl;
#endif
                break;

            case TypeAugmentedUnscented:
                CreateAugmentedUnscented(rect0, rectv0);
                break;
            }
        }
    }

    if (m_initialized)
    {
        cv::Mat measurement(4, 1, Mat_t(1));
        if (!dataCorrect)
        {
            measurement.at<track_t>(0) = m_lastRectResult.x;  // update using prediction
            measurement.at<track_t>(1) = m_lastRectResult.y;
            measurement.at<track_t>(2) = m_lastRectResult.width;
            measurement.at<track_t>(3) = m_lastRectResult.height;
        }
        else
        {
            measurement.at<track_t>(0) = static_cast<track_t>(rect.x);  // update using measurements
            measurement.at<track_t>(1) = static_cast<track_t>(rect.y);
            measurement.at<track_t>(2) = static_cast<track_t>(rect.width);
            measurement.at<track_t>(3) = static_cast<track_t>(rect.height);
        }
        // Correction
        cv::Mat estimated;
        switch (m_type)
        {
        case TypeLinear:
            estimated = m_linearKalman->correct(measurement);

            m_lastRectResult.x = estimated.at<track_t>(0);   //update using measurements
            m_lastRectResult.y = estimated.at<track_t>(1);
            m_lastRectResult.width = estimated.at<track_t>(2);
            m_lastRectResult.height = estimated.at<track_t>(3);
            break;

        case TypeUnscented:
        case TypeAugmentedUnscented:
#if USE_OCV_UKF
            estimated = m_uncsentedKalman->correct(measurement);

            m_lastRectResult.x = estimated.at<track_t>(0);   //update using measurements
            m_lastRectResult.y = estimated.at<track_t>(1);
            m_lastRectResult.width = estimated.at<track_t>(6);
            m_lastRectResult.height = estimated.at<track_t>(7);
#else
            estimated = m_linearKalman->correct(measurement);

            m_lastRectResult.x = estimated.at<track_t>(0);   //update using measurements
            m_lastRectResult.y = estimated.at<track_t>(1);
            m_lastRectResult.width = estimated.at<track_t>(2);
            m_lastRectResult.height = estimated.at<track_t>(3);
            std::cerr << "UnscentedKalmanFilter was disabled in CMAKE! Set KalmanLinear in constructor." << std::endl;
#endif
            break;
        }
    }
    else
    {
        if (dataCorrect)
        {
            m_lastRectResult.x = static_cast<track_t>(rect.x);
            m_lastRectResult.y = static_cast<track_t>(rect.y);
            m_lastRectResult.width = static_cast<track_t>(rect.width);
            m_lastRectResult.height = static_cast<track_t>(rect.height);
        }
    }
    return cv::Rect(static_cast<int>(m_lastRectResult.x), static_cast<int>(m_lastRectResult.y), static_cast<int>(m_lastRectResult.width), static_cast<int>(m_lastRectResult.height));
}