Пример #1
0
int main (int argc, char *argv[]) {
	int i = 1;
	vertex_t **vhead, *vp;
	*vhead = NULL;
	adj_vertex_t *adj_v;
         //initially assigned to NULL
	while ((argv[i] != NULL) && (argv[i + 1] != NULL) && (argv[i + 2] != NULL)) {
	    int intWeight = atoi(argv[i + 2]) ;
	    add_edge(vhead, argv[i], argv[i + 1], intWeight);
	    i = i + 3;
	}

	//print out our adjacency list 
	printf("Adjacency list:\n");
	for (vp = *vhead; vp != NULL; vp = vp->next) {
		printf("  %s: ", vp->name);
		for (adj_v = vp->adj_list; adj_v != NULL; adj_v = adj_v->next) {
			printf("%s(%d) ", adj_v->vertex->name, adj_v->edge_weight);
		}
		printf("\n");
	}
	printf("Finding whether tour exists:\n");
	findTour(vhead);

        freeGraph(*vhead);

	return 0;
}
Пример #2
0
void TourWidgetPrivate::captureTour()
{
    MarbleWidget* widget = new MarbleWidget;
    widget->setMapThemeId( m_widget->mapThemeId() );
    widget->resize( 1280, 720 );

    m_widget->model()->treeModel()->removeDocument(m_document);
    widget->model()->treeModel()->addDocument(m_document);

    GeoDataTour* tour = findTour( m_document );
    TourPlayback* playback = new TourPlayback;
    playback->setMarbleWidget( widget );
    playback->setTour( tour );

    m_tourUi.m_listView->setModel( widget->model()->treeModel() );
    if( tour ){
        m_tourUi.m_listView->setRootIndex( widget->model()->treeModel()->index( tour->playlist() ) );
        m_tourUi.m_listView->repaint();

        TourCaptureDialog* tourCaptureDialog = new TourCaptureDialog( widget, m_widget );
        tourCaptureDialog->setDefaultFilename( tour->name() );
        tourCaptureDialog->setTourPlayback( playback );
        tourCaptureDialog->exec();
    }

    delete playback;
    widget->model()->treeModel()->removeDocument(m_document);
    m_widget->model()->treeModel()->addDocument(m_document);
    updateRootIndex();
    delete widget;
}
Пример #3
0
GeoDataTour *TourWidgetPrivate::findTour( GeoDataFeature *feature ) const
{
    if ( feature && feature->nodeType() == GeoDataTypes::GeoDataTourType ) {
        return static_cast<GeoDataTour*>( feature );
    }

    GeoDataContainer *container = dynamic_cast<GeoDataContainer*>( feature );
    if ( container ) {
        QVector<GeoDataFeature*>::Iterator end = container->end();
        QVector<GeoDataFeature*>::Iterator iter = container->begin();
        for( ; iter != end; ++iter ) {
            GeoDataTour *tour = findTour( *iter );
            if ( tour ) {
                return tour;
            }
        }
    }
    return 0;
}
Пример #4
0
void TourWidgetPrivate::updateRootIndex()
{
    GeoDataTour *tour = findTour( m_document );
    if ( tour ){
        GeoDataPlaylist *playlist = tour->playlist();
        if ( playlist ) {
            m_tourUi.m_listView->setModel( m_widget->model()->treeModel() );
            m_tourUi.m_listView->setRootIndex( m_widget->model()->treeModel()->index( playlist ) );
            QObject::connect( m_tourUi.m_listView->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ),
                              q, SLOT( updateButtonsStates() ) );
        }
        m_playback.setMarbleWidget( m_widget );
        m_playback.setTour( tour );
        m_tourUi.m_slider->setMaximum( m_playback.duration() * 100 );
        QTime nullTime( 0, 0, 0 );
        QTime time = nullTime.addSecs( m_playback.duration() );
        m_tourUi.m_totalTime->setText( QString("%L1:%L2").arg( time.minute(), 2, 10, QChar('0') ).arg( time.second(), 2, 10, QChar('0') ) );
        QObject::connect( &m_playback, SIGNAL( progressChanged( double ) ),
                         q, SLOT( handlePlaybackProgress( double ) ) );
        q->stopPlaying();
        m_tourUi.m_toolBarPlayback->setEnabled( true );
        bool isPlaybackEmpty = m_playback.mainTrackSize() != 0;
        m_tourUi.actionPlay->setEnabled( isPlaybackEmpty );
        m_tourUi.m_slider->setEnabled( isPlaybackEmpty );
        m_tourUi.m_actionRecord->setEnabled( isPlaybackEmpty );
        m_tourUi.actionStop->setEnabled( false );
        if( m_playback.mainTrackSize() > 0 ) {
            if( dynamic_cast<PlaybackFlyToItem*>( m_playback.mainTrackItemAt( 0 ) ) ) {
                QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
                for( int i = 0; i < playlist->size(); ++i ) {
                    if( playlist->primitive( i )->nodeType() == GeoDataTypes::GeoDataFlyToType ) {
                        m_delegate->setFirstFlyTo( m_widget->model()->treeModel()->index( i, 0, playlistIndex ) );
                        break;
                    }
                }
            } else {
                m_delegate->setFirstFlyTo( QPersistentModelIndex() );
            }
        }
    }
}