Esempio n. 1
0
void TouchPointField::drawTouchPoints() {
  for (unsigned int i = 0; i < tpoints.size(); i++) {
    TouchPoint* tp = tpoints[i];
    if (tp !=  NULL) {
      tp->draw();
    }
  }
}
Esempio n. 2
0
	static TouchPoint* touchPointWithParent(CCNode* pParent)
	{
		TouchPoint* pRet = new TouchPoint();
		pRet->setContentSize(pParent->getContentSize());
		pRet->setAnchorPoint(ccp(0.0f, 0.0f));
		pRet->autorelease();
		return pRet;
	}
Esempio n. 3
0
int TouchPointField::addTouchPoint (int x, int y, int r) {
  int id = IDG.nextID();
  TouchPoint* tp = new TouchPoint(id, "tpf point");
  
  tp->setBoundingBox(offx + x - (r/2), offy + y - (r/2), r,r);
  tpoints.push_back(tp);
  resize();
  return id;
}
Esempio n. 4
0
float PinchZoomGesture::getDistanceInObjectPlane(TouchPoint &firstPoint, TouchPoint &secondPoint, NxPlane& plane)
{
	// Unproject both points onto the objects plane
	Vec3 firstWorldPoint = firstPoint.unProject(plane);
	Vec3 secondWorldPoint = secondPoint.unProject(plane);

	//Calculate the distance between the world points
	return (secondWorldPoint - firstWorldPoint).magnitude();
}
KDvoid TestMultiTouch::ccTouchesMoved ( CCSet* pTouches, CCEvent* pEvent )
{
	for ( CCSetIterator  iter = pTouches->begin ( ); iter != pTouches->end ( ); iter++ )
	{
        CCTouch*     pTouch = (CCTouch*) ( *iter );
        TouchPoint*  pTouchPoint = (TouchPoint*) m_tDictionary.objectForKey ( pTouch->getID ( ) );

        pTouchPoint->setTouchPos ( this->convertTouchToNodeSpace ( pTouch ) );
	}
}
Esempio n. 6
0
void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
        CCPoint location = pTouch->getLocation();
        pTP->setTouchPos(location);
    }
}
Esempio n. 7
0
	TouchPoint SymmetryLine::symmetricLine(TouchPoint line)
	{
		auto points = line.getPointList();
		vec2 firstPoint = SymmetryLine::symmetricPoint(points.front());
		TouchPoint symmetricTouch(firstPoint, line.getColor(), line.getSize());
		for (auto touches : points)
		{
			symmetricTouch.addPoint(SymmetryLine::symmetricPoint(touches));
		}

		return symmetricTouch;
	};
Esempio n. 8
0
void MutiTouchTestLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTP = (TouchPoint*)s_dic.objectForKey(pTouch->getID());
        CCPoint location = pTouch->locationInView();
        location = CCDirector::sharedDirector()->convertToGL(location);
        pTP->setTouchPos(location);
    }
}
Esempio n. 9
0
 // Callback for when touch has ended
 void DraggingState::onTouchEnded(Agent* director) {
     
     // Check if the ending touch is the one dragging this agent
     TouchPoint *touchPoint = ((Director *)director)->getTouchPoint(_draggingTouchID);
     
     if (!touchPoint || touchPoint->hasEnded())
     {
         // Move to final position and end the drag
         moveActorToTouchPosition(((Director *)director)->getTouchPoint(_draggingTouchID));
         endDrag();
     }
 }
KDvoid TestMultiTouch::ccTouchesBegan ( CCSet* pTouches, CCEvent* pEvent )
{
    for ( CCSetIterator  iter = pTouches->begin ( ); iter != pTouches->end ( ); iter++ )
    {
        CCTouch*	 pTouch = (CCTouch*) ( *iter );
        TouchPoint*  pTouchPoint = TouchPoint::create ( this );

        pTouchPoint->setTouchPos   ( this->convertTouchToNodeSpace ( pTouch ) );
        pTouchPoint->setTouchColor ( l_aTouchColors [ pTouch->getID ( ) ]);

        this->addChild ( pTouchPoint );
        m_tDictionary.setObject ( pTouchPoint, pTouch->getID ( ) );		
    }
}
Esempio n. 11
0
void TouchPointField::drag(int x, int y) {
  // what to do here ?
  // drag one handle, if selected
  for (unsigned int i = 0; i < tpoints.size(); i++) {
    TouchPoint* tp = tpoints[i];

    if (tp != NULL) {
      if (tp->isSelected()) {
	// test, if tp->getPosX(), tp->getPosY() inside maximum boudaries
	tp->drag(x,y);
	resize();
	// do something with the offset offx and offy ????
      }
    }
  }
}
void FourthStudy::ConnectionGestureRecognizer::processGroup(list<shared_ptr<TouchTrace>> group) {
	if(group.size() == 1) {
		auto trace = group.front();
		TheApp *theApp = (TheApp *)App::get();
		TouchPoint a = trace->touchPoints.front();
		TouchPoint b = trace->touchPoints.back();
		
		Vec2f ap = theApp->tuioToWindow(a.getPos());
		Vec2f bp = theApp->tuioToWindow(b.getPos());
		
		theApp->widgetsMutex().lock();
		int fromWid = 0;
		for(auto w : theApp->widgets()) {
			if(w->id() == trace->widgetId) {
				if(dynamic_pointer_cast<MeasureWidget>(w)) {
					shared_ptr<MeasureWidget> tmp = dynamic_pointer_cast<MeasureWidget>(w);
					if(tmp->hitOutlet(ap)) {
						fromWid = tmp->id();
						tmp.reset();
						break;
					}
				}
			}
		}
		
		int toWid = 0;
		for(auto w : theApp->widgets()) {
			if(dynamic_pointer_cast<MeasureWidget>(w)) {
				shared_ptr<MeasureWidget> tmp = dynamic_pointer_cast<MeasureWidget>(w);
				if(tmp->hitInlet(bp)) {
					toWid = tmp->id();
					tmp.reset();
					break;
				}
			}
		}
		theApp->widgetsMutex().unlock();
		
		if(fromWid != 0 && toWid != 0 && fromWid != toWid) {
			shared_ptr<ConnectionGesture> g = make_shared<ConnectionGesture>(fromWid, toWid);
			_gesturesMutex->lock();
			_gestures->push_back(g);
			_gesturesMutex->unlock();
		}
	}
}
Esempio n. 13
0
void MutiTouchTestLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
    CCSetIterator iter = pTouches->begin();
    for (; iter != pTouches->end(); iter++)
    {
        CCTouch* pTouch = (CCTouch*)(*iter);
        TouchPoint* pTouchPoint = TouchPoint::touchPointWithParent(this);
        CCPoint location = pTouch->getLocation();

        pTouchPoint->setTouchPos(location);
        pTouchPoint->setTouchColor(s_TouchColors[pTouch->getID()]);

        addChild(pTouchPoint);
        s_dic.setObject(pTouchPoint, pTouch->getID());
    }
    

}
Esempio n. 14
0
void TouchPointField::clicked(int x, int y) {
  // is a handle selected ?
  std::cout << "clicked inside tpf\n";

  int count = 0;
  for (unsigned int i = 0; i < tpoints.size(); i++) {
    TouchPoint* tp = tpoints[i];

    if (tp != NULL) {
      tp->setSelected(false); // reset selection
      if (count == 0) { // none selected so far, single selection only
	if (tp->inside(x,y)) {
	  count++;
	}
      }
    }

  }
}