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
void MicrobePointLineObject::objectRemoved()
{
    GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
    if(layout && layout->getPatientKeyObject())
    {
	layout->getPatientKeyObject()->unref(this);
    }
}
bool MicrobeBarGraphObject::processEvent(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;
        bool selectValid = false;

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

        if(selectValid && _microbeCount)
        {
            if(selectedKeys.size())
            {
                for(int i = 0; i < _microbeCount; ++i)
                {
                    if(!strcmp(selectedKeys[0].c_str(),_microbeList[i].species))
                    {
                        selectedGroup = _microbeList[i].phylum;
                        break;
                    }
                }
            }
            layout->selectMicrobes(selectedGroup,selectedKeys);
        }
        if(clickUsed)
        {
            return true;
        }
    }

    return TiledWallSceneObject::processEvent(ie);
}
예제 #4
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);
}
예제 #5
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;
}
예제 #6
0
void MicrobePointLineObject::objectAdded()
{
    GraphLayoutObject * layout = dynamic_cast<GraphLayoutObject*>(_parent);
    if(layout && layout->getPatientKeyObject())
    {
	bool addKey = !layout->getPatientKeyObject()->hasRef();
	layout->getPatientKeyObject()->ref(this);

	if(addKey)
	{
	    layout->addLineObject(layout->getPatientKeyObject());
	}
    }
}