Exemplo n.º 1
0
/**
 * Translates a vector in screen coordinates to a vector in real coordinates.
 */
RS_Vector RS_GraphicView::toGraph(RS_Vector v) const{
	return RS_Vector(toGraphX(RS_Math::round(v.x)),
					 toGraphY(RS_Math::round(v.y)));
}
Exemplo n.º 2
0
/**
 * Translates two screen coordinates to a vector in real coordinates.
 */
RS_Vector RS_GraphicView::toGraph(int x, int y) const{
	return RS_Vector(toGraphX(x), toGraphY(y));
}
Exemplo n.º 3
0
	bool msgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
									
		if(msg == WM_SIZE) {

			updateBounds(hwnd);

		}
		
		if(msg == WM_PAINT) {

			updateBounds(hwnd);

			updateGraph(hwnd);

		}

		if(msg == WM_DESTROY) {
			//SendMessage(GetParent(hwnd), WM_GRAPH_CHANGED, 0, 0);		
			bClosed = true;
		}
		
		if(msg == WM_CREATE) {

			updateGraph(hwnd);

		}

				
		if(msg == WM_LBUTTONDBLCLK) {

//			POINT point;
			//GetCursorPos(&point);


			int xPos = LOWORD(lParam);
			int yPos = HIWORD(lParam);
			
			RECT rect;
			GetClientRect(hwnd, &rect);
			
			if((xPos >= rect.left) && (xPos <= rect.right) && (yPos >= rect.top) && 
				(yPos <= rect.bottom)) 
			{

				float x = toGraphX(xPos);
				float y = toGraphY(rect.bottom - yPos);
				
				for(int i = 0; i < mChannels.size(); i++) {
					Channel* c = &mChannels[i];
					c->insertKey(x);
				}
			}

			updateGraph(hwnd);
		
		}

		if((msg == WM_MOUSEMOVE) && mLocked) {
									
			if(wParam != MK_LBUTTON) {
			
				mLocked = false;
						
			} else {
		
				POINT point;
				
				point.x = LOWORD(lParam);
				point.y = HIWORD(lParam);
				
/*				//GetCursorPos(&point);
								
				RECT rect;
				GetClientRect(hwnd, &rect);
				
				float x = (float)(point.x - rect.left) / (float)(rect.right - rect.left);
				float y = 1.0f - (float)(point.y - rect.top) / (float)(rect.bottom - rect.top);
				float dx = x - mOldX;
				float dy = y - mOldY;
*/				
			RECT rc;
			GetClientRect(hwnd, &rc);

				float x = toGraphX(point.x);
				float y = toGraphY(rc.bottom - point.y);
				
				Channel* c = &mChannels[mLockedChannel];
				
				c->moveKey(x,y,mXTreshold, ymin, ymax);
			
				mOldX = x;
				mOldY = y;

			}

			updateGraph(hwnd);

		}
		

		if((msg == WM_LBUTTONDOWN) & !mLocked) {
		
			POINT point;
			//GetCursorPos(&point);
								
			point.x = LOWORD(lParam);
			point.y = HIWORD(lParam);

			RECT rc;
			GetClientRect(hwnd, &rc);
				
//			float x = (float)(point.x - rect.left) / (float)(rect.right - rect.left);
//			float y = 1.0f - (float)(point.y - rect.top) / (float)(rect.bottom - rect.top);

				float x = toGraphX(point.x);
				float y = toGraphY(rc.bottom - point.y);


			for(int i = 0; i < mChannels.size(); i++) {
				Channel* c = &mChannels[i];
				if(c->lockKey(x, y, mXTreshold, mYTreshold)) {
					mLockedChannel = i;
					mLocked = true;
					mOldX = x;
					mOldY = y;
					break;
				}
			}
		
		}
		
		return false;
	}