/** * Add a cubeViewport to the workspace, open the cube. * * @param cubename[in] (QString) cube name * * @internal * @history 2006-06-12 Tracie Sucharski, Clear errors after catching when * attempting to open cube. * @history 2007-02-13 Tracie Sucharski, Open cube read, not read/write. * Opening read/write was done to accomodate the * EditTool. EditTool will now reopen the cube * read/write. * @history 2008-05-27 Noah Hilt, When opening a cube now if a * user specifies extra arguments to the cube name, * the cube will be opened using a CubeAttributeInput * specifically for the number and index of bands to * be opened. Additionally, if a cube is opened with 3 * bands it will be opened in RGB mode with red, * green, and blue set to the 3 bands respectively. * @history 2008-12-04 Jeannie Walldren - Removed "delete cube" * since this was causing a segfault and this * deallocation is already taking place in * addCubeViewport(cube). * */ void Workspace::addCubeViewport(QString cubename) { Cube *cube = new Cube; //Read in the CubeAttribueInput from the cube name CubeAttributeInput inAtt(cubename); std::vector<QString> bands = inAtt.bands(); //Set the virtual bands to the bands specified by the input cube->setVirtualBands(bands); cube->open(cubename); MdiCubeViewport *cvp = addCubeViewport(cube); // Check for RGB format (#R,#G,#B) if(bands.size() == 3) { IString st = IString(bands.at(0)); int index_red = st.ToInteger(); st = IString(bands.at(1)); int index_green = st.ToInteger(); st = IString(bands.at(2)); int index_blue = st.ToInteger(); cvp->viewRGB(index_red, index_green, index_blue); } }