void MainWindow::createConnections()
{
    connect(fileNewAction, SIGNAL(triggered()),
            this, SLOT(fileNew()));
    connect(fileOpenAction, SIGNAL(triggered()),
            this, SLOT(fileOpen()));
    connect(fileSaveAction, SIGNAL(triggered()),
            this, SLOT(fileSave()));
    connect(fileSaveAsAction, SIGNAL(triggered()),
            this, SLOT(fileSaveAs()));
    connect(fileExportAction, SIGNAL(triggered()),
            this, SLOT(fileExport()));
    connect(filePrintAction, SIGNAL(triggered()),
            this, SLOT(filePrint()));
    connect(fileQuitAction, SIGNAL(triggered()),
            this, SLOT(close()));
    connect(editSelectedItemAction, SIGNAL(triggered()),
            this, SLOT(editSelectedItem()));
    connect(editAddTextAction, SIGNAL(triggered()),
            this, SLOT(editAddItem()));
    connect(editAddBoxAction, SIGNAL(triggered()),
            this, SLOT(editAddItem()));
    connect(editAddSmileyAction, SIGNAL(triggered()),
            this, SLOT(editAddItem()));
    connect(editCopyAction, SIGNAL(triggered()),
            this, SLOT(editCopy()));
    connect(editCutAction, SIGNAL(triggered()),
            this, SLOT(editCut()));
    connect(editPasteAction, SIGNAL(triggered()),
            this, SLOT(editPaste()));
    connect(QApplication::clipboard(), SIGNAL(dataChanged()),
            this, SLOT(updateUi()));
    foreach (QAction *action, QList<QAction*>()
             << editAlignmentAction << editAlignLeftAction
             << editAlignRightAction << editAlignTopAction
             << editAlignBottomAction)
        connect(action, SIGNAL(triggered()), this, SLOT(editAlign()));
    connect(editClearTransformsAction, SIGNAL(triggered()),
            this, SLOT(editClearTransforms()));
    connect(scene, SIGNAL(selectionChanged()),
            this, SLOT(selectionChanged()));
    connect(viewShowGridAction, SIGNAL(toggled(bool)),
            this, SLOT(viewShowGrid(bool)));
    connect(viewZoomInAction, SIGNAL(triggered()),
            view, SLOT(zoomIn()));
    connect(viewZoomOutAction, SIGNAL(triggered()),
            view, SLOT(zoomOut()));
}
LDViewMainWindow::LDViewMainWindow(QApplication *a)
	:QMainWindow(),Ui::LDView(),
	fileSeparatorIndex(-1),
	toolbarMaxStep(new QLabel),
	toolbarCurrentStep(new QLabel),
	toolbarStepLabel(new QLabel("Step :")),
	toolbarViewAngle(NULL),
	toolbarWireframeMenu(new QMenu(this)),
	edgeMenu(new QMenu(this)),
	bfcMenu(new QMenu(this)),
	primitiveMenu(new QMenu(this))
{
    setupUi(this);
	toolbar->insertWidget(toolbarFirstStep,toolbarStepLabel);
	toolbar->insertWidget(toolbarFirstStep,toolbarCurrentStep);
	toolbar->insertWidget(toolbarFirstStep,toolbarMaxStep);
    if (modelViewer) modelViewer->setMainWindow(this);
    connect( fileOpenAction, SIGNAL( triggered() ), this, SLOT( fileOpen() ) );
    connect( fileSaveSettingsAction, SIGNAL( triggered() ), this, SLOT( fileSaveSettings() ) );
    connect( fileExportAction, SIGNAL( triggered() ), this, SLOT( fileExport() ) );
    connect( fileExportOptionAction, SIGNAL( triggered() ), this, SLOT( fileExportOption() ) );
	connect( file3DSExportOptionAction, SIGNAL( triggered() ), this, SLOT( file3DSExportOption() ) );
    connect( fileJPEGOptionsAction, SIGNAL( triggered() ), this, SLOT( fileJPEGOptions() ) );
    connect( fileSaveAction, SIGNAL( triggered() ), this, SLOT( fileSave() ) );
    connect( filePrintAction, SIGNAL( triggered() ), this, SLOT( filePrint() ) );
    connect( fileExitAction, SIGNAL( triggered() ), this, SLOT( fileExit() ) );
    connect( helpContentsAction, SIGNAL( triggered() ), this, SLOT( helpContents() ) );
    connect( helpAboutAction, SIGNAL( triggered() ), this, SLOT( helpAbout() ) );
    connect( helpAboutQtAction, SIGNAL( triggered() ), this, SLOT( helpAboutQt() ) );
    connect( editPreferencesAction, SIGNAL( triggered() ), this, SLOT( editPreferences() ) );
    connect( viewToolBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewToolBar(bool) ) );
    connect( toolbarWireframeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframe(bool) ) );
    connect( toolbarEdgeAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarEdge(bool) ) );
    connect( toolbarPrimitiveSubstitutionAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarPrimitiveSubstitution(bool) ) );
    connect( toolbarLightingAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarLighting(bool) ) );
    connect( toolbarBFCAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarBFC(bool) ) );
    connect( toolbarAxesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarAxes(bool) ) );
    connect( toolbarSeamsAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarSeams(bool) ) );
    connect( viewStatusBarAction, SIGNAL( toggled(bool) ), this, SLOT( viewStatusBar(bool) ) );
    connect( viewLatitudeRotationAction, SIGNAL( toggled(bool) ), this, SLOT( latitudeRotation(bool) ) );
    connect( viewKeepRightSideUpAction, SIGNAL( toggled(bool) ), this, SLOT( keepRightSideUp(bool) ) );
    connect( viewFullScreenAction, SIGNAL( triggered() ), this, SLOT( viewFullScreen() ) );
    connect( viewResetViewAction, SIGNAL( triggered() ), this, SLOT( viewResetView() ) );
    connect( helpOpenGLDriverInfoAction, SIGNAL( triggered() ), this, SLOT( helpOpenGLDriverInfo() ) );
    connect( fileLDrawDirAction, SIGNAL( triggered() ), this, SLOT( fileLDrawDir() ) );
    connect( fileExtraDirAction, SIGNAL( triggered() ), this, SLOT( fileExtraDir() ) );
    connect( fileCheckForUpdatesAction, SIGNAL( triggered() ), this, SLOT( fileCheckForUpdates() ) );
    connect( fileReloadAction, SIGNAL( triggered() ), this, SLOT( fileReload() ) );
    connect( viewShowErrorsAction, SIGNAL( triggered() ), this, SLOT( viewShowErrors() ) );
    connect( pollActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( pollChanged(QAction*) ) );
    connect( viewZoomToFitAction, SIGNAL( triggered() ), this, SLOT( viewZoomToFit() ) );
	connect( viewRightSideUpAction, SIGNAL( triggered() ), this, SLOT( viewRightSideUp() ) );
    connect( viewModeActionGroup, SIGNAL( triggered(QAction*) ), this, SLOT( viewModeChanged(QAction*) ) );
    connect( frontViewAngleAction, SIGNAL( triggered() ), this, SLOT( frontViewAngle() ) );
    connect( backViewAngleAction, SIGNAL( triggered() ), this, SLOT( backViewAngle() ) );
    connect( leftViewAngleAction, SIGNAL( triggered() ), this, SLOT( leftViewAngle() ) );
    connect( rightViewAngleAction, SIGNAL( triggered() ), this, SLOT( rightViewAngle() ) );
    connect( topViewAngleAction, SIGNAL( triggered() ), this, SLOT( topViewAngle() ) );
    connect( bottomViewAngleAction, SIGNAL( triggered() ), this, SLOT( bottomViewAngle() ) );
    connect( latLongViewAngleAction, SIGNAL( triggered() ), this, SLOT( latLongViewAngle() ) );
    connect( isoViewAngleAction, SIGNAL( triggered() ), this, SLOT( isoViewAngle() ) );
    connect( saveDefaultViewAngleAction, SIGNAL( triggered() ), this, SLOT( saveDefaultViewAngle() ) );
    connect( fileCancelLoadAction, SIGNAL( triggered() ), this, SLOT( fileCancelLoad() ) );
    connect( showViewInfoAction, SIGNAL( triggered() ), this, SLOT( showViewInfo() ) );
    connect( showPovCameraAction, SIGNAL( triggered() ), this, SLOT( showPovCamera() ) );
    connect( showPovAspectRatioAction, SIGNAL( toggled(bool) ), this, SLOT( showPovAspectRatio(bool) ) );
    connect( toolsPartListAction, SIGNAL( triggered() ), this, SLOT( toolsPartList() ) );
    connect( toolbarPrevStep, SIGNAL( triggered() ), this, SLOT( prevStep() ) );
    connect( toolbarNextStep, SIGNAL( triggered() ), this, SLOT( nextStep() ) );
    connect( toolbarFirstStep, SIGNAL( triggered() ), this, SLOT( firstStep() ) );
    connect( toolbarLastStep, SIGNAL( triggered() ), this, SLOT( lastStep() ) );
    connect( stepGoto, SIGNAL( triggered() ), this, SLOT( gotoStep() ) );
    connect( toolsModelTreeAction, SIGNAL( triggered() ), this, SLOT( toolsModelTree() ) );
    connect( toolsBoundingBoxAction, SIGNAL( triggered() ), this, SLOT( toolsBoundingBox() ) );
    connect( toolsMpdModelSelectionAction, SIGNAL( triggered() ), this, SLOT( toolsMpdModelSelection() ) );

    connect(fileMenu, SIGNAL(aboutToShow()), this, SLOT(doFileMenuAboutToShow()));
    connect(editMenu, SIGNAL(aboutToShow()), this, SLOT(doEditMenuAboutToShow()));
    connect(viewMenu, SIGNAL(aboutToShow()), this, SLOT(doViewMenuAboutToShow()));
    connect(toolsMenu,SIGNAL(aboutToShow()), this, SLOT(doToolsMenuAboutToShow()));
    connect(helpMenu, SIGNAL(aboutToShow()), this, SLOT(doHelpMenuAboutToShow()));

	int cnt,i;
	QAction *item;
    for ( cnt = i = 0; ; i++)
    {
        item = fileMenu->actions()[i];
        if (item->isSeparator())
        {
            if (++cnt == 2)
                break;
        }
    }
    fileSeparatorIndex = i;
#ifdef __APPLE__
    fileMenu->removeItemAt(fileSeparatorIndex);
    fileSeparatorIndex = -1;
    openRecentMenu = new QMenu(this, "openRecentMenu");
    fileMenu->insertItem("Open Recent", openRecentMenu, -1, 1);
#endif // __APPLE__
    if (!recentFiles)
    {
        recentFiles = new TCStringArray(10);
        populateRecentFiles();
    }
    populateRecentFileMenuItems();
	setupStandardSizes();
#ifdef __APPLE__
        // Since Preferences is the only item in the edit menu, we need to
        // delete the edit menu on the Mac, since the item is going to get
        // magically moved to the LDView menu.  The problem is, if we delete
        // the edit menu, the magic stops working, since it's apparently all
        // done on the fly.  So, we're going to create a new fully-functional
        // Preferences menu item at the top of the File menu, and THEN delete
        // the edit menu.  This newly created menu item won't be visible to the
        // user, but it will make the other one continue to function after the
        // deletion of the edit menu.
        fileMenu->insertItem("Preferences", this, SLOT(doPreferences()),
            0, -1, 0);
        // Remove the (empty without Preferences) edit menu.
        menuBar->removeItem(menuBar->idAt(1));
#endif //__APPLE__
	toolbarViewAngle = new QToolButton(toolbar);
	toolbarViewAngle->setMenu(viewingAnglePopupMenu);
	toolbarViewAngle->setPopupMode(QToolButton::InstantPopup);
	toolbarViewAngle->setIcon(QPixmap( ":/images/images/toolbar_view.png"));
	toolbarViewAngle->setEnabled(false);
	toolbar->insertWidget(editPreferencesAction,toolbarViewAngle);
	connect( wireframeFogAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeFog(bool) ) );
	connect( wireframeRemoveHiddenLinesAction, SIGNAL( toggled(bool) ), this, SLOT( toolbarWireframeRemoveHiddenLines(bool) ) );
	toolbarWireframeMenu->addAction(wireframeFogAction);
	toolbarWireframeMenu->addAction(wireframeRemoveHiddenLinesAction);
	QToolButton *toolbarWireframe =
		(QToolButton *)toolbar->widgetForAction(toolbarWireframeAction);	
	if (toolbarWireframe != NULL)
	{
		toolbarWireframe->setMenu(toolbarWireframeMenu);
		toolbarWireframe->setPopupMode(QToolButton::MenuButtonPopup);
	}
	connect( textureStudAction, SIGNAL( toggled(bool) ), this, SLOT( textureStud(bool) ) );
	primitiveMenu->addAction(textureStudAction);
	QToolButton *toolbarPrimitives =
		(QToolButton *)toolbar->widgetForAction(toolbarPrimitiveSubstitutionAction);
	if (toolbarPrimitives)
	{
		toolbarPrimitives->setMenu(primitiveMenu);
		toolbarPrimitives->setPopupMode(QToolButton::MenuButtonPopup);
	}
	connect( edgeShowEdgeOnlyAction, SIGNAL( toggled(bool) ), this, SLOT( edgeShowEdgeOnly(bool) ) );
	connect( edgeConditionalLineAction, SIGNAL( toggled(bool) ), this, SLOT( edgeConditionalLine(bool) ) );
	connect( edgeHighQualityAction, SIGNAL( toggled(bool) ), this, SLOT( edgeHighQuality(bool) ) );
	connect( edgeAlwaysBlackAction, SIGNAL( toggled(bool) ), this, SLOT( edgeAlwaysBlack(bool) ) );
	edgeMenu->addAction(edgeShowEdgeOnlyAction);
	edgeMenu->addAction(edgeConditionalLineAction);
	edgeMenu->addAction(edgeHighQualityAction);
	edgeMenu->addAction(edgeAlwaysBlackAction);
	QToolButton *toolbarEdge =
		(QToolButton *)toolbar->widgetForAction(toolbarEdgeAction);
	if (toolbarEdge)
	{
		toolbarEdge->setMenu(edgeMenu);
		toolbarEdge->setPopupMode(QToolButton::MenuButtonPopup);
	}
	connect( bfcRedBackFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcRedBackFaces(bool) ) );
	connect( bfcGreenFrontFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcGreenFrontFaces(bool) ) );
	connect( bfcBlueNeutralFacesAction, SIGNAL( toggled(bool) ), this, SLOT( bfcBlueNeutralFaces(bool) ) );
	bfcMenu->addAction(bfcRedBackFacesAction);
	bfcMenu->addAction(bfcGreenFrontFacesAction);
	bfcMenu->addAction(bfcBlueNeutralFacesAction);
	QToolButton *toolbarBfc =
		(QToolButton *)toolbar->widgetForAction(toolbarBFCAction);
	if (toolbarBfc)
	{
		toolbarBfc->setMenu(bfcMenu);
		toolbarBfc->setPopupMode(QToolButton::MenuButtonPopup);
	}
    modelViewer->setApplication(a);
}
Beispiel #3
0
shared_ptr<CBaseCommCtl> CDisplayCtl::takeCommCtl(CBaseDevice* device, const std::string& displayName)
{

    {
        std::stringstream log;
        log << "CDisplayCtl::takeCommCtl try to take " << displayName;
        SetTo::LocalLog(device->c_name, trace, log.str());
    }

    try {

        {
            std::stringstream log;
            log << "CDisplayCtl::takeCommCtl: getting " << displayPath << displayName;
            SetTo::LocalLog(device->c_name, trace, log.str());
        }
        boostio::stream_buffer<boostio::file_sink> bufExport(displayPath+displayName);
        std::ostream fileExport(&bufExport);

        // Create TPinData
        {
            std::stringstream log;
            log << "CDisplayCtl::takeCommCtl: create fname " << displayPath << displayName;
            SetTo::LocalLog(device->c_name, trace, log.str());
        }
        std::string fname(CDisplayCtl::displayPath + displayName);

        TDisplayData display;
        display.filename = fname;
        display.fd = -1;
        display.name = displayName;

        {
            std::stringstream log;
            log << "CDisplayCtl::takeCommCtl: getDisplayConfig " << displayPath << displayName;
            SetTo::LocalLog(device->c_name, trace, log.str());
        }
        settings::CommDisplayConfig config = getDisplayConfig(device, displayName);

        // create CDisplayCtl for displayNum
        {
            std::stringstream log;
            log << "CDisplayCtl::takeCommCtl: New CDisplayCtl " << displayPath << displayName;
            SetTo::LocalLog(device->c_name, trace, log.str());
        }

        shared_ptr<CBaseCommCtl> displayCtl( (CBaseCommCtl*) new CDisplayCtl(device, config, display) );
        {
            std::stringstream log;
            log << "CDisplayCtl::takeCommCtl: pr(displayName, displayCtl) " << displayPath << displayName;
            SetTo::LocalLog(device->c_name, trace, log.str());
        }
        std::pair<std::string, shared_ptr<CBaseCommCtl> > pr(displayName, displayCtl);

        {
            std::stringstream log;
            log << "CDisplayCtl::takeCommCtl: take " << displayName << " successfully [fake]";
            SetTo::LocalLog(device->c_name, debug, log.str());
        }

        return displayCtl;
    }

    catch(boost::exception& ex)
    {
        {
            std::stringstream log;
            log << "ERROR! CDisplayCtl::takeCommCtl: exception: " << boost::diagnostic_information(ex);
            SetTo::LocalLog(device->c_name, error, log.str());
        }
        return nullptr;
    }

    catch(std::exception& ex)
    {
        {
            std::stringstream log;
            log << "ERROR! CDisplayCtl::takeCommCtl: exception: " << ex.what();
            SetTo::LocalLog(device->c_name, error, log.str());
        }
        return nullptr;
    }

    catch(...)
    {
        SetTo::LocalLog(device->c_name, error, "ERROR! CDisplayCtl::takeCommCtl: unknown exception");
        return nullptr;
    }

    return nullptr;
}