Exemple #1
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::selectedObjectsChanged()
{
    std::vector<caf::PdmUiItem*> uiItems;
    m_projectTreeView->selectedUiItems(uiItems);

    caf::PdmObjectHandle* firstSelectedObject = nullptr;

    if (uiItems.size() == 1)
    {
        firstSelectedObject = dynamic_cast<caf::PdmObjectHandle*>(uiItems[0]);
    }

    m_pdmUiPropertyView->showProperties(firstSelectedObject);

    if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection)
    {
        // Find the reservoir view or the Plot that the selected item is within

        if (!firstSelectedObject)
        {
            caf::PdmFieldHandle* selectedField = dynamic_cast<caf::PdmFieldHandle*>(uiItems[0]);
            if (selectedField) firstSelectedObject = selectedField->ownerObject();
        }

        if (!firstSelectedObject) return;

        
        RimViewWindow* selectedWindow = dynamic_cast<RimViewWindow*>(firstSelectedObject);
        if (!selectedWindow)
        {
            firstSelectedObject->firstAncestorOrThisOfType(selectedWindow);
        }

        // If we cant find the view window as an MDI sub window, we search higher in the
        // project tree to find a possible parent view window that has.
        if (selectedWindow && !findMdiSubWindow(selectedWindow->viewWidget()))
        {
            if (selectedWindow->parentField() && selectedWindow->parentField()->ownerObject())
            {
                selectedWindow->parentField()->ownerObject()->firstAncestorOrThisOfType(selectedWindow);
            }
        }

        if (selectedWindow)
        {
            if (selectedWindow->viewWidget())
            {
                setActiveViewer(selectedWindow->viewWidget());
            }
            // The only way to get to this code is by selection change initiated from the project tree view
            // As we are activating an MDI-window, the focus is given to this MDI-window
            // Set focus back to the tree view to be able to continue keyboard tree view navigation
            m_projectTreeView->treeView()->setFocus();
        }
    }
}
void DistViewGUI::initSignals(QObject *dvctrl)
{
	// signals from DistviewController
	connect(dvctrl, SIGNAL(pixelOverlayInvalid()),
	        vp, SLOT(removePixelOverlay()));
	connect(dvctrl, SIGNAL(toggleLabeled(bool)),
	        vp, SLOT(toggleLabeled(bool)));
	connect(dvctrl, SIGNAL(toggleUnlabeled(bool)),
	        vp, SLOT(toggleUnlabeled(bool)));

	connect(dvctrl, SIGNAL(labelSelected(int)),
	        vp, SLOT(toggleLabelHighlight(int)));

	// signals to controller
	connect(this, SIGNAL(requestBinCount(representation::t, int)),
	        dvctrl, SLOT(changeBinCount(representation::t, int)));


	//   viewport action
	connect(vp, SIGNAL(activated(representation::t)),
	        dvctrl, SLOT(setActiveViewer(representation::t)));
	connect(vp, SIGNAL(activated(representation::t)),
	        this, SIGNAL(activated()));
	connect(vp, SIGNAL(bandSelected(int)),
	        dvctrl, SLOT(propagateBandSelection(int)));
	connect(vp, SIGNAL(requestOverlay(int,int)),
	        dvctrl, SLOT(drawOverlay(int,int)));
	connect(vp, SIGNAL(requestOverlay(std::vector<std::pair<int,int> >,int)),
	        dvctrl, SLOT(drawOverlay(std::vector<std::pair<int,int> >,int)));

	connect(vp, SIGNAL(addSelectionRequested()),
	        dvctrl, SLOT(addHighlightToLabel()));
	connect(vp, SIGNAL(remSelectionRequested()),
	        dvctrl, SLOT(remHighlightFromLabel()));

	// illumination correction
	connect(this, SIGNAL(newIlluminantCurve(QVector<multi_img::Value>)),
	        vp, SLOT(changeIlluminantCurve(QVector<multi_img::Value>)));
	connect(this, SIGNAL(toggleIlluminationShown(bool)),
	        vp, SLOT(setIlluminationCurveShown(bool)));
	connect(this, SIGNAL(newIlluminantApplied(QVector<multi_img::Value>)),
	        vp, SLOT(setAppliedIlluminant(QVector<multi_img::Value>)));
}