Exemplo n.º 1
0
void Widget::removeClicked(const QString &url)
{
	if(Label *label = qobject_cast<Label*>(sender())) {
		if(!m_timedOut.contains(label)) {
			removeLabel(label);
		}
	}

	emit linkClicked(url);
}
Exemplo n.º 2
0
void Widget::maybeRemove()
{
	if(Label *label = qobject_cast<Label*>(sender())) {
		if(m_mouseInside) {
			m_timedOut << label;
		} else {
			removeLabel(label);
		}
	}
}
Exemplo n.º 3
0
TEST_F( Labels, Remove )
{
    auto m = ml->addMedia( "media.avi" );
    auto l1 = ml->createLabel( "sea otter" );
    auto l2 = ml->createLabel( "cony the cone" );

    m->addLabel( l1 );
    m->addLabel( l2 );

    auto labels = m->labels()->all();
    ASSERT_EQ( labels.size(), 2u );

    bool res = m->removeLabel( l1 );
    ASSERT_TRUE( res );

    // Check for existing media first
    labels = m->labels()->all();
    ASSERT_EQ( labels.size(), 1u );
    ASSERT_EQ( labels[0]->name(), "cony the cone" );

    // And now clean fetch another instance of the media & check again for DB replication
    auto media = ml->media( m->id() );
    labels = media->labels()->all();
    ASSERT_EQ( labels.size(), 1u );
    ASSERT_EQ( labels[0]->name(), "cony the cone" );

    // Remove a non-linked label
    res = m->removeLabel( l1 );
    ASSERT_FALSE( res );

    // Remove the last label
    res = m->removeLabel( l2 );
    ASSERT_TRUE( res );

    labels = m->labels()->all();
    ASSERT_EQ( labels.size(), 0u );

    // Check again for DB replication
    media = ml->media( m->id() );
    labels = media->labels()->all();
    ASSERT_EQ( labels.size(), 0u );
}
Exemplo n.º 4
0
void OSGSegment::attachLabel(std::string name, std::string filepath){
    if(label_)
        removeLabel();

    osg::ref_ptr<osg::Geode> geode = osg::ref_ptr<osg::Geode>(new osg::Geode());
    osg::ref_ptr<osg::Geometry> geometry = osg::ref_ptr<osg::Geometry>(new osg::Geometry());

    osg::ref_ptr<osg::Vec3Array> vertices = osg::ref_ptr<osg::Vec3Array>(new osg::Vec3Array);
    vertices->push_back (osg::Vec3 (0, 0, 0.0));

    geometry->setVertexArray (vertices);

    geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,vertices->size()));

    geode->addDrawable(geometry);
    osg::ref_ptr<osg::StateSet> set = geode->getOrCreateStateSet();

    /// Setup the point sprites
    osg::ref_ptr<osg::PointSprite> sprite = osg::ref_ptr<osg::PointSprite>(new osg::PointSprite());
    set->setTextureAttributeAndModes(0, sprite, osg::StateAttribute::ON);

    /// Give some size to the points to be able to see the sprite
    osg::ref_ptr<osg::Point> point = osg::ref_ptr<osg::Point>(new osg::Point());
    point->setSize(50);
    set->setAttribute(point);

    /// Disable depth test to avoid sort problems and Lighting
    set->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
    set->setMode(GL_LIGHTING, osg::StateAttribute::OFF);

    osg::ref_ptr<osg::BlendFunc> texture_blending_function = new osg::BlendFunc();
    set->setAttributeAndModes(texture_blending_function.get(), osg::StateAttribute::ON);

    osg::ref_ptr<osg::AlphaFunc> alpha_transparency_function = new osg::AlphaFunc();
    alpha_transparency_function->setFunction(osg::AlphaFunc::GEQUAL, 0.05);
    set->setAttributeAndModes(alpha_transparency_function.get(), osg::StateAttribute::ON );

    /// The texture for the sprites
    osg::ref_ptr<osg::Texture2D> tex = osg::ref_ptr<osg::Texture2D>(new osg::Texture2D());
    osg::ref_ptr<osg::Image> image = osgDB::readImageFile(filepath);
    image->flipVertical();
    tex->setImage(image);

    set->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);

    post_transform_->addChild(geode);

    geode->setName(name);
    geode->setUserData(this);

    label_ = geode;
}
Exemplo n.º 5
0
void Widget::leaveEvent(QEvent *event)
{
	QWidget::leaveEvent(event);
	m_mouseInside = false;

	foreach(Label *label, m_timedOut) {
		if(label) {
			removeLabel(label);
		}
	}

	m_timedOut.clear();
}
Exemplo n.º 6
0
// Remove specific labels in selection
void Model::selectionRemoveLabels(Atom::AtomLabel al)
{
	for (Atom* i = atoms_.first(); i != NULL; i = i->next) if (i->isSelected()) removeLabel(i, al);
	logChange(Log::Labels);
}
Exemplo n.º 7
0
 foreach(GraphLabel* currentLabel, labels) {
     removeLabel(currentLabel);
 }
Exemplo n.º 8
0
void Widget::removeAll()
{
	m_timedOut.clear();
	foreach(Label *label, findChildren<Label*>()) {
		removeLabel(label);
	}