void ToolSemiTracking::mousePress( QMouseEvent *mouseEvent)
{
	if (Qt::LeftButton == mouseEvent->button())    // left mouse button, add point and line 
	{   
		// check if the current vechleID is ok, same vehicle cannot appear two time at same time instance
		int frmIndex = mView->mCurrentFrameIndex;
		QPair<TrajectoryPoint*, QGraphicsTextItem*> pt_text_old = mView->mMainWind->findTrajPoint( mView, frmIndex, mCurrentVehicleID);
		if( pt_text_old.first != NULL )  // two vehicle appear at same time
		{
			QMessageBox::information(mView, "same vehicle existed", "please change vehicle ID!");
			return;
		}			
		
		// add one point
		// save point to list
		QPointF pt = mView->mapToScene( QPoint(mouseEvent->x(), mouseEvent->y()) );
		float x = pt.x();
		float y = pt.y();

		// if point not on image, return
		if (x<0 || x>mView->mCurrentFrame.cols || y<0 || y>mView->mCurrentFrame.rows)
			return;
		 
		// add sum image to Image Window
		//		
		int xMin = (x - mSubWndWidth)>=0 ? x-mSubWndWidth : 0;
		int yMin = (y - mSubWndWidth)>=0 ? y-mSubWndWidth : 0;

		int xMax = (x + mSubWndWidth)>=mView->mCurrentFrame.cols ? mView->mCurrentFrame.cols : (x+mSubWndWidth);
		int yMax = (y + mSubWndWidth)>=mView->mCurrentFrame.rows ? mView->mCurrentFrame.rows : (y+mSubWndWidth);
		if ( xMax<=0 )
		{
			xMax=0;
		}

		if ( yMax<=0 )
		{
			yMax=0;
		}

		if ( xMax-xMin == 0)
			return;
		if ( yMax-yMin == 0)
			return;

		Mat mSubImage = mView->mCurrentFrame.colRange(xMin,xMax).rowRange(yMin,yMax);
		Mat subImg = Mat( mSubImage.size(), mSubImage.type(), Scalar(0, 0, 0) );
		mSubImage.copyTo( subImg );

		// draw center and show in small window
		// 
		resize( subImg, subImg, subImg.size()*mEnlargeRate );
		circle( subImg, Point( subImg.cols/2, subImg.rows/2), 1, Scalar(230, 0, 0) );
		circle( subImg, Point( subImg.cols/2, subImg.rows/2), 5, Scalar(230, 0, 0) );
		mView->mMainWind->mMatWnd->showMatUp( subImg );

		// create point item and show
		//
		TrajectoryPoint *pointItem = new TrajectoryPoint( mCurrentVehicleID, mView->mMainWind->getBikeType() );
		pointItem->setPosition( pt.x(), pt.y() );  // 1, 1  
		//pointItem->setPos( pt );    this will cause point lost in GUI       ??????????????????????????????????????????????????????????????
		pointItem->setPen( QPen(Qt::red) );
		mPointItems.append( pointItem );
		mView->scene()->addItem( pointItem );      // show line	

		// create label for ID of vehicle and show
		//
		QGraphicsTextItem *textItem = new QGraphicsTextItem( QString("%1").arg(mCurrentVehicleID) );
		//textItem->setPen( QPen(Qt::red) );
		textItem->setPos( pt );
		QFont font;
		font.setPointSize( 6 );
		textItem->setFont( font );
		textItem->setOpacity( 0.6 );
		mView->scene()->addItem( textItem );

		// save trajectory point into main window
		// 
		
		QPair<TrajectoryPoint*, QGraphicsTextItem*> pair;
		pair.first = pointItem;
		pair.second = textItem;
		if ( !mView->mMainWind->mPrjFileObj.mTrajectory.contains(frmIndex) ) // not found points at time instance
		{
			QMap<int, QPair<TrajectoryPoint*, QGraphicsTextItem*>> timePoints;

			timePoints[ mCurrentVehicleID ] = pair;
			mView->mMainWind->mPrjFileObj.mTrajectory[frmIndex] = timePoints;
		} else {   //found point at given time instance
			mView->mMainWind->mPrjFileObj.mTrajectory[frmIndex][ mCurrentVehicleID ] = pair ;
		}
	} 
}