bool MicrobeScatterGraphObject::processEvent(cvr::InteractionEvent * ie)
{
    if(ie->asTrackedButtonEvent() && ie->asTrackedButtonEvent()->getButton() == 0 && (ie->getInteraction() == BUTTON_DOWN || ie->getInteraction() == BUTTON_DOUBLE_CLICK))
    {
	GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
	if(!layout)
	{
	    return false;
	}

	std::string patientGroup;
	std::vector<std::string> selectedPatients;

	bool clickUsed = false;
	if(_graph->processClick(patientGroup,selectedPatients))
	{
	    clickUsed = true;
	}

	layout->selectPatients(patientGroup,selectedPatients);
	if(clickUsed)
	{
	    return true;
	}
    }

    return TiledWallSceneObject::processEvent(ie);
}
예제 #2
0
bool MicrobePointLineObject::processEvent(cvr::InteractionEvent * ie)
{
    if(ie->asTrackedButtonEvent() && ie->asTrackedButtonEvent()->getButton() == 0 && (ie->getInteraction() == BUTTON_DOWN || ie->getInteraction() == BUTTON_DOUBLE_CLICK))
    {
	TrackedButtonInteractionEvent * tie = (TrackedButtonInteractionEvent*)ie;

	GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
	if(!layout)
	{
	    return false;
	}

	std::string selectedGroup;
	std::vector<std::string> selectedKeys;

	osg::Vec3 start, end(0,1000,0);
	start = start * tie->getTransform() * getWorldToObjectMatrix();
	end = end * tie->getTransform() * getWorldToObjectMatrix();

	osg::Vec3 planePoint;
	osg::Vec3 planeNormal(0,-1,0);
	osg::Vec3 intersect;
	float w;

	bool clickUsed = false;

	if(linePlaneIntersectionRef(start,end,planePoint,planeNormal,intersect,w))
	{
	    if(_graph->processClick(intersect,selectedGroup,selectedKeys))
	    {
		clickUsed = true;
	    }
	}

	layout->selectPatients(selectedGroup,selectedKeys);
	if(clickUsed)
	{
	    return true;
	}
    }

    return FPTiledWallSceneObject::processEvent(ie);
}
예제 #3
0
bool GraphKeyObject::eventCallback(InteractionEvent * ie)
{
    TrackedButtonInteractionEvent * tie = ie->asTrackedButtonEvent();
    if(tie)
    {
	if(tie->getButton() == 0 && (tie->getInteraction() == BUTTON_DOWN || tie->getInteraction() == BUTTON_DOUBLE_CLICK))
	{
	    osg::Vec3 point1, point2(0,1000.0,0);
	    point1 = point1 * tie->getTransform() * getWorldToObjectMatrix();
	    point2 = point2 * tie->getTransform() * getWorldToObjectMatrix();

	    osg::Vec3 planePoint, planeNormal(0,-1,0), intersect;
	    float w;

	    if(linePlaneIntersectionRef(point1,point2,planePoint,planeNormal,intersect,w))
	    {
		for(int i = 0; i < _rangeList.size(); ++i)
		{
		    if(intersect.x() >= _rangeList[i].first && intersect.x() <= _rangeList[i].second)
		    {
			std::string group = _labels[i];
			std::vector<std::string> emptyList;

			GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
			if(layout)
			{
			    layout->selectPatients(group,emptyList);
			}

			return true;
		    }
		}
	    }
	}
    }

    return false;
}