void medViewContainerSplitterTestObject::testAddViewContainer()
{
    medViewContainerSplitter *splitter = new medViewContainerSplitter();
    splitter->show();

    medViewContainer *container1 = new medViewContainer;

    QSignalSpy spy1(splitter, SIGNAL(newContainer(QUuid)));
    splitter->addViewContainer(container1);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(splitter->count(), 1);
    QCOMPARE(splitter->widget(0), container1);

    QList<QVariant> arguments = spy1.takeFirst();
    QUuid receivedUuid = qvariant_cast<QUuid>(arguments.at(0));
    QCOMPARE(container1->uuid(), receivedUuid);

    medViewContainer *container2 = new medViewContainer;
    splitter->addViewContainer(container2);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(splitter->count(), 2);
    QCOMPARE(splitter->widget(1), container2);

    arguments = spy1.takeFirst();
    receivedUuid = qvariant_cast<QUuid>(arguments.at(0));
    QCOMPARE(container2->uuid(), receivedUuid);

    delete splitter;
}
void medViewContainerSplitterTestObject::testSplitHorizontally()
{
    medViewContainerSplitter *splitter = new medViewContainerSplitter();
    splitter->setOrientation(Qt::Horizontal);
    splitter->show();

    medViewContainer *container1 = new medViewContainer;
    splitter->addViewContainer(container1);

    QSignalSpy spy1(splitter, SIGNAL(newContainer(QUuid)));

    medViewContainer *newContainer = splitter->splitHorizontally(container1);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(splitter->count(), 1);

    medViewContainerSplitter *nestedSplitter = dynamic_cast<medViewContainerSplitter*>(splitter->widget(0));
    QCOMPARE(nestedSplitter->widget(0), container1);
    QCOMPARE(nestedSplitter->widget(1), newContainer);
    QCOMPARE(nestedSplitter->orientation(), Qt::Vertical);

    QList<QVariant> arguments = spy1.takeFirst();
    QUuid receivedUuid = qvariant_cast<QUuid>(arguments.at(0));
    QCOMPARE(newContainer->uuid(), receivedUuid);

    medViewContainer *newContainer2 = nestedSplitter->splitHorizontally(newContainer);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(nestedSplitter->count(), 3);
    QCOMPARE(nestedSplitter->widget(0), container1);
    QCOMPARE(nestedSplitter->widget(1), newContainer);
    QCOMPARE(nestedSplitter->widget(2), newContainer2);
}
void medViewContainerSplitter::insertNestedSplitter(int index, medViewContainer *oldContainer, medViewContainer *newContainer, bool inverseOrderInSplitter)
{
    Qt::Orientation ori = Qt::Vertical;
    if(this->orientation() == Qt::Vertical)
            ori = Qt::Horizontal;

    QList<int> savedSizes = this->sizes();
    oldContainer->disconnect(this);
    medViewContainerSplitter *splitter = new medViewContainerSplitter;
    splitter->setOrientation(ori);

    connect(splitter, SIGNAL(newContainer(QUuid)), this, SIGNAL(newContainer(QUuid)));
    connect(splitter, SIGNAL(destroyed()), this, SLOT(checkIfStillDeserveToLiveSpliter()));

    if(inverseOrderInSplitter)
    {
       splitter->addViewContainer(newContainer);
       splitter->blockSignals(true);
       splitter->addViewContainer(oldContainer);
       splitter->blockSignals(false);
    }
    else
    {
       splitter->blockSignals(true);
       splitter->addViewContainer(oldContainer);
       splitter->blockSignals(false);
       splitter->addViewContainer(newContainer);
    }

    this->insertWidget(index, splitter);
    this->setCollapsible(index, false);
    this->setSizes(savedSizes);

    // resize nested container because QVtkWidget2 is automatically resize to fit the its view
    // (given the fixed width/height of the splitter) when it is added to the splitter.
    int newSize = 0;
    if(splitter->orientation() == Qt::Vertical)
        newSize = splitter->width() / 2;
    else
        newSize = splitter->height() / 2;
    splitter->recomputeSizes(0, 1, newSize);

}
Ejemplo n.º 4
0
uiWindow *uiNewWindow(char *title, int width, int height)
{
	uiWindow *w;

	w = uiNew(uiWindow);
	w->widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(w->widget), title);
	gtk_window_resize(GTK_WINDOW(w->widget), width, height);
	g_signal_connect(w->widget, "destroy", G_CALLBACK(onDestroy), w);
	w->container = newContainer();
	gtk_container_add(GTK_CONTAINER(w->widget), w->container);
	return w;
}
void medViewContainerSplitter::insertViewContainer(int index, medViewContainer *container)
{
    connect(container, SIGNAL(hSplitRequest()), this, SLOT(splitHorizontally()));
    connect(container, SIGNAL(vSplitRequest()), this, SLOT(splitVertically()));
    connect(container, SIGNAL(splitRequest(medDataIndex, Qt::AlignmentFlag)), this, SLOT(split(medDataIndex, Qt::AlignmentFlag)));
    connect(container, SIGNAL(destroyed()), this, SLOT(checkIfStillDeserveToLiveSpliter()));
    container->setContainerParent(this);

    emit newContainer(container->uuid());

    this->insertWidget(index, container);
    this->setCollapsible(index, false);
}
Ejemplo n.º 6
0
//-*****************************************************************************
Reader::Request
Reader::object( const std::string &name, 
                const std::string &prot, 
                unsigned int protVersion,
                const ObjectInfo &info ) 
{
    if ( m_objects == NULL )
    {
        GTC_THROW( "Reader reading without objects" );
    }
    
    PropertyContainer *g = NULL;
    Protocol protocol( prot, protVersion );
    bool found = false;

    if ( m_useExisting )
    {
        for ( int i = 0; i < m_objects->size(); ++i )
        {
            PropertyContainer *pc = (*m_objects)[i];

            if ( pc->name() == name &&
                 pc->protocol() == protocol )
            {
                found = true;
                g = pc;
            }
        }
    }
    
    if ( !g )
    {
        g = newContainer( protocol );
        g->setName( name );
        g->setProtocol( protocol );
    }

    if ( !found ) { m_objects->push_back( g ); }

    return Request( true, g );
}
void medViewContainerSplitterTestObject::testInsertViewContainer()
{
    medViewContainerSplitter *splitter = new medViewContainerSplitter();
    splitter->show();

    medViewContainer *container1 = new medViewContainer;
    medViewContainer *container2 = new medViewContainer;

    splitter->addViewContainer(container1);
    splitter->addViewContainer(container2);

    QSignalSpy spy1(splitter, SIGNAL(newContainer(QUuid)));

    medViewContainer *containerToInsert = new medViewContainer;

    //insert a new container at the begining
    splitter->insertViewContainer(0, containerToInsert);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(splitter->count(), 3);
    QCOMPARE(splitter->widget(0), containerToInsert);
    QCOMPARE(splitter->widget(1), container1);
    QCOMPARE(splitter->widget(2), container2);

    QList<QVariant> arguments = spy1.takeFirst();
    QUuid receivedUuid = qvariant_cast<QUuid>(arguments.at(0));
    QCOMPARE(containerToInsert->uuid(), receivedUuid);


    medViewContainer *containerToInsert2 = new medViewContainer;

    //insert a new container at the end
    splitter->insertViewContainer(3, containerToInsert2);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(splitter->count(), 4);
    QCOMPARE(splitter->widget(0), containerToInsert);
    QCOMPARE(splitter->widget(1), container1);
    QCOMPARE(splitter->widget(2), container2);
    QCOMPARE(splitter->widget(3), containerToInsert2);

    arguments = spy1.takeFirst();
    receivedUuid = qvariant_cast<QUuid>(arguments.at(0));
    QCOMPARE(containerToInsert2->uuid(), receivedUuid);


    medViewContainer *containerToInsert3 = new medViewContainer;

    //insert a new container at the middle
    splitter->insertViewContainer(2, containerToInsert3);

    QCOMPARE(spy1.count(), 1);
    QCOMPARE(splitter->count(), 5);
    QCOMPARE(splitter->widget(0), containerToInsert);
    QCOMPARE(splitter->widget(1), container1);
    QCOMPARE(splitter->widget(2), containerToInsert3);
    QCOMPARE(splitter->widget(3), container2);
    QCOMPARE(splitter->widget(4), containerToInsert2);

    arguments = spy1.takeFirst();
    receivedUuid = qvariant_cast<QUuid>(arguments.at(0));
    QCOMPARE(containerToInsert3->uuid(), receivedUuid);


    delete splitter;

}