void MediaBrowser::handleSelectionChange() { // Update the preview if a texture is selected if (!isDirectorySelected()) { _preview->SetTexture(getSelectedName()); GlobalShaderClipboard().setSource(getSelectedName()); } else { _preview->SetTexture(""); // Nothing selected, clear the clipboard GlobalShaderClipboard().clear(); } }
void Map::load(const std::string& filename) { rMessage() << "Loading map from " << filename << "\n"; setMapName(filename); // Reset all layers before loading the file GlobalLayerSystem().reset(); GlobalSelectionSystem().setSelectedAll(false); { ScopeTimer timer("map load"); m_resource = GlobalMapResourceManager().capture(_mapName); // greebo: Add the observer, this usually triggers a onResourceRealise() call. m_resource->addObserver(*this); // Traverse the scenegraph and find the worldspawn MapWorldspawnFinder finder; GlobalSceneGraph().root()->traverse(finder); } rMessage() << "--- LoadMapFile ---\n"; rMessage() << _mapName << "\n"; rMessage() << GlobalCounters().getCounter(counterBrushes).get() << " brushes\n"; rMessage() << GlobalCounters().getCounter(counterPatches).get() << " patches\n"; rMessage() << GlobalCounters().getCounter(counterEntities).get() << " entities\n"; // Move the view to a start position gotoStartPosition(); // Load the stored map positions from the worldspawn entity GlobalMapPosition().loadPositions(); // Remove them, so that the user doesn't get bothered with them GlobalMapPosition().removePositions(); // Disable the region to make sure GlobalRegion().disable(); // Clear the shaderclipboard, the references are most probably invalid now GlobalShaderClipboard().clear(); // Let the filtersystem update the filtered status of all instances GlobalFilterSystem().update(); // Update the layer control dialog ui::LayerControlDialog::Instance().refresh(); // Clear the modified flag setModified(false); }
// free all map elements, reinitialize the structures that depend on them void Map::freeMap() { map::PointFile::Instance().clear(); GlobalSelectionSystem().setSelectedAll(false); GlobalSelectionSystem().setSelectedAllComponents(false); GlobalShaderClipboard().clear(); GlobalRegion().clear(); m_resource->removeObserver(*this); // Reset the resource pointer m_resource = IMapResourcePtr(); GlobalLayerSystem().reset(); }
void createDecals() { for (FaceInstanceList::iterator i = _faceInstances.begin(); i != _faceInstances.end(); ++i) { // Get the winding const Winding& winding = (*i)->getFace().getWinding(); // Create a new decal patch scene::INodePtr patchNode = GlobalPatchCreator(DEF3).createPatch(); if (patchNode == NULL) { gtkutil::errorDialog(_("Could not create patch."), GlobalMainFrame().getTopLevelWindow()); return; } Patch* patch = Node_getPatch(patchNode); assert(patch != NULL); // must not fail // Set the tesselation of that 3x3 patch patch->setDims(3,3); patch->setFixedSubdivisions(true, Subdivisions(1,1)); // Set the coordinates patch->ctrlAt(0,0).vertex = winding[0].vertex; patch->ctrlAt(2,0).vertex = winding[1].vertex; patch->ctrlAt(1,0).vertex = (patch->ctrlAt(0,0).vertex + patch->ctrlAt(2,0).vertex)/2; patch->ctrlAt(0,1).vertex = (winding[0].vertex + winding[3].vertex)/2; patch->ctrlAt(2,1).vertex = (winding[1].vertex + winding[2].vertex)/2; patch->ctrlAt(1,1).vertex = (patch->ctrlAt(0,1).vertex + patch->ctrlAt(2,1).vertex)/2; patch->ctrlAt(2,2).vertex = winding[2].vertex; patch->ctrlAt(0,2).vertex = winding[3].vertex; patch->ctrlAt(1,2).vertex = (patch->ctrlAt(2,2).vertex + patch->ctrlAt(0,2).vertex)/2; // Use the texture in the clipboard, if it's a decal texture Texturable& clipboard = GlobalShaderClipboard().getSource(); if (!clipboard.empty()) { if (clipboard.getShader().find("decals") != std::string::npos) { patch->setShader(clipboard.getShader()); } } // Fit the texture on it patch->SetTextureRepeat(1,1); patch->FlipTexture(1); // Insert the patch into worldspawn scene::INodePtr worldSpawnNode = GlobalMap().getWorldspawn(); assert(worldSpawnNode != NULL); // This must be non-NULL, otherwise we won't have faces worldSpawnNode->addChildNode(patchNode); // Deselect the face instance (*i)->setSelected(SelectionSystem::eFace, false); // Select the patch Node_setSelected(patchNode, true); } }
// Handles the mouseDown event, basically determines which action should be performed (select or manipulate) void RadiantWindowObserver::onMouseDown(const WindowVector& position, GdkEventButton* ev) { // Retrieve the according ObserverEvent for the GdkEventButton ui::ObserverEvent observerEvent = GlobalEventManager().MouseEvents().getObserverEvent(ev); // Check if the user wants to copy/paste a texture if (observerEvent == ui::obsCopyTexture || observerEvent == ui::obsPasteTextureProjected || observerEvent == ui::obsPasteTextureNatural || observerEvent == ui::obsPasteTextureCoordinates || observerEvent == ui::obsPasteTextureToBrush || observerEvent == ui::obsJumpToObject) { // Get the mouse position DeviceVector devicePosition(device_constrained(window_to_normalised_device(position, _width, _height))); // Check the target object render::View scissored(*_selectObserver._view); ConstructSelectionTest(scissored, Rectangle::ConstructFromPoint(devicePosition, _selectObserver._epsilon)); SelectionVolume volume(scissored); // Do we have a camera view (fill() == true)? if (_selectObserver._view->fill()) { if (observerEvent == ui::obsJumpToObject) { CamWndPtr cam = GlobalCamera().getActiveCamWnd(); if (cam != NULL) { cam->jumpToObject(volume); } } // If the apply texture modifier is held else if (observerEvent == ui::obsPasteTextureProjected) { // Paste the shader projected (TRUE), but not to an entire brush (FALSE) selection::algorithm::pasteShader(volume, true, false); } // If the copy texture modifier is held else if (observerEvent == ui::obsCopyTexture) { // Set the source texturable from the given test GlobalShaderClipboard().setSource(volume); } else if (observerEvent == ui::obsPasteTextureNatural) { // Paste the shader naturally (FALSE), but not to an entire brush (FALSE) selection::algorithm::pasteShader(volume, false, false); } else if (observerEvent == ui::obsPasteTextureCoordinates) { // Clone the texture coordinates from the patch in the clipboard selection::algorithm::pasteTextureCoords(volume); } else if (observerEvent == ui::obsPasteTextureToBrush) { // Paste the shader projected (TRUE), and to the entire brush (TRUE) selection::algorithm::pasteShader(volume, true, true); } } } // Have any of the "selection" events occurred? // greebo: This could be an "else if (observerEvent != obsNothing)" as well, // but perhaps there will be more events in the future that aren't selection events. if (observerEvent == ui::obsManipulate || observerEvent == ui::obsSelect || observerEvent == ui::obsToggle || observerEvent == ui::obsToggleFace || observerEvent == ui::obsToggleGroupPart || observerEvent == ui::obsReplace || observerEvent == ui::obsReplaceFace) { _mouseDown = true; // Determine the current mouse position DeviceVector devicePosition(window_to_normalised_device(position, _width, _height)); if (observerEvent == ui::obsManipulate && _manipulateObserver.mouseDown(devicePosition)) { // This is a manipulation operation, register the callbacks // Note: the mouseDown call in the if clause returned already true, // so a manipulator could be successfully selected _mouseMotionCallback = boost::bind(&ManipulateObserver::mouseMoved, &_manipulateObserver, _1); _mouseUpCallback = boost::bind(&ManipulateObserver::mouseUp, &_manipulateObserver, _1); _listenForCancelEvents = true; } else { // Call the mouseDown method of the selector class, this covers all of the other events _selectObserver.mouseDown(devicePosition); _mouseMotionCallback = boost::bind(&SelectObserver::mouseMoved, &_selectObserver, _1); _mouseUpCallback = boost::bind(&SelectObserver::mouseUp, &_selectObserver, _1); // greebo: the according actions (toggle face, replace, etc.) are handled in the mouseUp methods. } } }
void Redo (void) { GlobalUndoSystem().redo(); SceneChangeNotify(); GlobalShaderClipboard().clear(); }