/** * Constructor. Creates a tree of GLActors. Each actor is responsible for displaying insrument components in 3D. * Some of the components have "pick ID" assigned to them. Pick IDs can be uniquely converted to a RGB colour value * which in turn can be used for picking the component from the screen. * @param wsName :: Workspace name * @param autoscaling :: True to start with autoscaling option on. If on the min and max of * the colormap scale are defined by the min and max of the data. * @param scaleMin :: Minimum value of the colormap scale. Used to assign detector colours. Ignored if autoscaling == true. * @param scaleMax :: Maximum value of the colormap scale. Used to assign detector colours. Ignored if autoscaling == true. */ InstrumentActor::InstrumentActor(const QString &wsName, bool autoscaling, double scaleMin, double scaleMax): m_workspace(AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName.toStdString())), m_ragged(true), m_autoscaling(autoscaling), m_defaultPos(), m_maskedColor(100,100,100), m_failedColor(200,200,200) { // settings loadSettings(); auto sharedWorkspace = m_workspace.lock(); if (!sharedWorkspace) throw std::logic_error("InstrumentActor passed a workspace that isn't a MatrixWorkspace"); // set up the color map if (!m_currentColorMapFilename.isEmpty()) { loadColorMap(m_currentColorMapFilename,false); } m_colorMap.changeScaleType(m_scaleType); // set up data ranges and colours setUpWorkspace(sharedWorkspace, scaleMin, scaleMax); Instrument_const_sptr instrument = getInstrument(); // If the instrument is empty, maybe only having the sample and source const int nelements = instrument->nelements(); if ( ( nelements == 0 ) || ( nelements == 1 && ( instrument->getSource() || instrument->getSample() ) ) || ( nelements == 2 && instrument->getSource() && instrument->getSample() ) ) { QMessageBox::warning(NULL,"MantidPlot - Warning","This instrument appears to contain no detectors","OK"); } // this adds actors for all instrument components to the scene and fills in m_detIDs m_scene.addActor(new CompAssemblyActor(*this,instrument->getComponentID())); setupPickColors(); if ( !m_showGuides ) { // hide guide and other components showGuides( m_showGuides ); } }