Exemple #1
0
void MainWindow::quit()
{
    qDebug() << "Logging out...";
    logout();

    writePreferences();
}
Exemple #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RIApplication::saveProjectAs(const QString& fileName)
{
    m_project->fileName = fileName;
    m_project->writeFile();

    m_preferences->lastUsedProjectFileName = fileName;
    writePreferences();

    return true;
}
Exemple #3
0
void
NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& eID, const std::string& lID,
                         SUMOReal speed, SVCPermissions permissions, SVCPermissions preferred,
                         SUMOReal endOffset, SUMOReal width, PositionVector shape,
                         const std::string& origID, SUMOReal length, unsigned int index, bool origNames,
                         const NBNode* node) {
    // output the lane's attributes
    into.openTag(SUMO_TAG_LANE).writeAttr(SUMO_ATTR_ID, lID);
    // the first lane of an edge will be the depart lane
    into.writeAttr(SUMO_ATTR_INDEX, index);
    // write the list of allowed/disallowed vehicle classes
    if (permissions != SVC_UNSPECIFIED) {
        writePermissions(into, permissions);
    }
    writePreferences(into, preferred);
    // some further information
    if (speed == 0) {
        WRITE_WARNING("Lane #" + toString(index) + " of edge '" + eID + "' has a maximum velocity of 0.");
    } else if (speed < 0) {
        throw ProcessError("Negative velocity (" + toString(speed) + " on edge '" + eID + "' lane#" + toString(index) + ".");
    }
    if (endOffset > 0) {
        length = length - endOffset;
    }
    into.writeAttr(SUMO_ATTR_SPEED, speed);
    into.writeAttr(SUMO_ATTR_LENGTH, length);
    if (endOffset != NBEdge::UNSPECIFIED_OFFSET) {
        into.writeAttr(SUMO_ATTR_ENDOFFSET, endOffset);
    }
    if (width != NBEdge::UNSPECIFIED_WIDTH) {
        into.writeAttr(SUMO_ATTR_WIDTH, width);
    }
    if (node != 0) {
        const NBNode::CustomShapeMap& cs = node->getCustomLaneShapes();
        NBNode::CustomShapeMap::const_iterator it = cs.find(lID);
        if (it != cs.end()) {
            shape = it->second;
            into.writeAttr(SUMO_ATTR_CUSTOMSHAPE, true);
        }
    }
    into.writeAttr(SUMO_ATTR_SHAPE, endOffset > 0 ?
                   shape.getSubpart(0, shape.length() - endOffset) : shape);
    if (origNames && origID != "") {
        into.openTag(SUMO_TAG_PARAM);
        into.writeAttr(SUMO_ATTR_KEY, "origId");
        into.writeAttr(SUMO_ATTR_VALUE, origID);
        into.closeTag();
        into.closeTag();
    } else {
        into.closeTag();
    }
}
Exemple #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool RIApplication::loadProject(const QString& projectFileName)
{
    if (!closeProject(true)) return false;

    if (!QFile::exists(projectFileName)) return false;

    m_project->fileName = projectFileName;
    m_project->readFile();

    if (m_project->projectFileVersionString().isEmpty())
    {
        closeProject(false);

        QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName);
        QMessageBox::warning(NULL, "Error when opening project file", tmp);

        RIMainWindow* mainWnd = RIMainWindow::instance();
        mainWnd->setPdmRoot(NULL);

        // Delete all object possibly generated by readFile()
        delete m_project;
        m_project = new RimProject;
    }
    else
    {
        m_preferences->lastUsedProjectFileName = projectFileName;
        writePreferences();

        size_t i;
        for (i = 0; i < m_project->reservoirs().size(); ++i)
        {
            RimReservoir* ri = m_project->reservoirs()[i];
            CVF_ASSERT(ri);

            size_t j;
            for (j = 0; j < ri->reservoirViews().size(); j++)
            {
                RimReservoirView* riv = ri->reservoirViews()[j];
                CVF_ASSERT(riv);

                riv->loadDataAndUpdate();
            }
        }
    }

    onProjectOpenedOrClosed();
    
    return true;
}
void
NWWriter_SUMO::writeLane(OutputDevice& into, const std::string& eID, const std::string& lID, const NBEdge::Lane& lane,
                         SUMOReal length, unsigned int index, bool origNames) {
    // output the lane's attributes
    into.openTag(SUMO_TAG_LANE).writeAttr(SUMO_ATTR_ID, lID);
    // the first lane of an edge will be the depart lane
    into.writeAttr(SUMO_ATTR_INDEX, index);
    // write the list of allowed/disallowed vehicle classes
    writePermissions(into, lane.permissions);
    writePreferences(into, lane.preferred);
    // some further information
    if (lane.speed == 0) {
        WRITE_WARNING("Lane #" + toString(index) + " of edge '" + eID + "' has a maximum velocity of 0.");
    } else if (lane.speed < 0) {
        throw ProcessError("Negative velocity (" + toString(lane.speed) + " on edge '" + eID + "' lane#" + toString(index) + ".");
    }
    if (lane.offset > 0) {
        length = length - lane.offset;
    }
    into.writeAttr(SUMO_ATTR_SPEED, lane.speed);
    into.writeAttr(SUMO_ATTR_LENGTH, length);
    if (lane.offset != NBEdge::UNSPECIFIED_OFFSET) {
        into.writeAttr(SUMO_ATTR_ENDOFFSET, lane.offset);
    }
    if (lane.width != NBEdge::UNSPECIFIED_WIDTH) {
        into.writeAttr(SUMO_ATTR_WIDTH, lane.width);
    }
    PositionVector shape = lane.shape;
    if (lane.offset > 0) {
        shape = shape.getSubpart(0, shape.length() - lane.offset);
    }
    into.writeAttr(SUMO_ATTR_SHAPE, shape);
    if (origNames && lane.origID != "") {
        into.openTag(SUMO_TAG_PARAM);
        into.writeAttr(SUMO_ATTR_KEY, "origId");
        into.writeAttr(SUMO_ATTR_VALUE, lane.origID);
        into.closeTag();
        into.closeTag();
    } else {
        into.closeTag();
    }
}
Exemple #6
0
void App::gui() {
	ImGuiIO& io = ImGui::GetIO();

	if (ImGui::BeginMainMenuBar()) {
		if (ImGui::BeginMenu("File")) {
			if (ImGui::MenuItem("New", io.OSXBehaviors ? "Cmd+N" : "Ctrl+N")) {
				newShader();
			}
			ImGui::Separator();
			if (ImGui::MenuItem("Open...", io.OSXBehaviors ? "Cmd+O" : "Ctrl+O")) {
				openShaderDialog();
			}
			if (ImGui::BeginMenu("Open Recent", !!recently_used_filepaths[most_recently_used_index])) {
				for (int i = 0; i < (int)ARRAY_COUNT(recently_used_filepaths); i++) {
					int index = (most_recently_used_index+i) % ARRAY_COUNT(recently_used_filepaths);
					if (recently_used_filepaths[index]) {
						char *menuitem_label = recently_used_filepaths[index];
						// we might include libgen.h and use basename(3) but there is no windows support...
						// TODO: test this on windows
						char *basename = strrchr(menuitem_label, '/');
						if (basename) menuitem_label = basename+1;
						if (ImGui::MenuItem(menuitem_label)) {
							loadShader(recently_used_filepaths[index]);
						}
						if (basename && ImGui::IsItemHovered()) {
							ImGui::SetTooltip("%s", recently_used_filepaths[index]);
						}
					} else break;
				}
				ImGui::Separator();
				if (ImGui::MenuItem("Clear Items")) {
					clearRecentlyUsedFilepaths();
				}
				ImGui::EndMenu();
			}
			// TODO: move this to settings pane eventually
			if (ImGui::MenuItem("Autoreload", nullptr, shader_file_autoreload)) {
				shader_file_autoreload = !shader_file_autoreload;
				writePreferences();
			}
			if (ImGui::MenuItem("Save", io.OSXBehaviors ? "Cmd+S" : "Ctrl+S", false, !!shader_filepath)) {
				saveShader();
			}
			if (ImGui::IsItemHovered() && shader_filepath) {
				ImGui::SetTooltip("%s", shader_filepath);
			}
			if (ImGui::MenuItem("Save As...", io.OSXBehaviors ? "Cmd+Shift+S" : "Ctrl+Shift+S", false, !!src_edit_buffer[0])) {
				saveShaderDialog();
			}
			ImGui::Separator();
			if (ImGui::MenuItem("Quit", io.OSXBehaviors ? "Cmd+Q" : "Ctrl+Q")) {
				quit = true;
			}
 			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("View")) {
			if (ImGui::MenuItem("Fullscreen", io.OSXBehaviors ? "Cmd+F" : "Ctrl+F", windowIsFullscreen())) {
				windowToggleFullscreen();
			}
			if (ImGui::MenuItem("Hide Controls", io.OSXBehaviors ? "Cmd+Shift+H" : "Ctrl+H", hide_gui)) {
				hide_gui = !hide_gui;
			}
			ImGui::Separator();
			if (ImGui::MenuItem(anim_play ? "Pause Animation" : "Play Animation", "Space")) {
				toggleAnimation();
			}
			if (ImGui::MenuItem("Reset Animation")) {
				frame_count = 0;
			}
			if (ImGui::MenuItem("Reset Camera")) {
				resetCamera();
			}
			ImGui::EndMenu();
		}
if (ImGui::BeginMenu("Tools")) {
	if (ImGui::MenuItem("Recompile Shader", io.OSXBehaviors ? "Cmd+B" : "Ctrl+B", false, !!src_edit_buffer[0])) {
		recompileShader();
	}
	ImGui::EndMenu();
}
if (ImGui::BeginMenu("Window")) {
	if (ImGui::MenuItem("Uniforms", io.OSXBehaviors ? "Cmd+1" : "Ctrl+1", show_uniforms_window)) {
		show_uniforms_window = !show_uniforms_window;
	}
	if (ImGui::MenuItem("Textures", io.OSXBehaviors ? "Cmd+2" : "Ctrl+2", show_textures_window)) {
		show_textures_window = !show_textures_window;
	}
	ImGui::Separator();
	if (ImGui::MenuItem("Camera", io.OSXBehaviors ? "Cmd+3" : "Ctrl+3", show_textures_window)) {
		show_camera_window = !show_camera_window;
	}
	ImGui::Separator();
	if (ImGui::MenuItem("Source editor", io.OSXBehaviors ? "Cmd+4" : "Ctrl+4", show_src_edit_window)) {
		show_src_edit_window = !show_src_edit_window;
	}
	ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
	}

	if (show_uniforms_window) {
		if (ImGui::Begin("Uniforms", &show_uniforms_window)) {
			if (ImGui::CollapsingHeader("Built-in uniform names")) {
				ImGui::InputText("Time", u_time_name, sizeof(u_time_name));
				ImGui::InputText("Resolution", u_resolution_name, sizeof(u_resolution_name));
				ImGui::InputText("View to World Matrix", u_view_to_world_name, sizeof(u_view_to_world_name));
				ImGui::InputText("World to View Matrix", u_world_to_view_name, sizeof(u_world_to_view_name));
			}
			ImGui::Separator();

			if (!compile_error_log) {
				ImGui::AlignFirstTextHeightToWidgets();
				ImGui::Text("Data"); ImGui::SameLine();
				if (ImGui::Button("Clear")) {
					if (uniform_data) {
						memset(uniform_data, 0, uniform_data_size);
					}
				} ImGui::SameLine();
				if (ImGui::Button("Save")) {
					writeUniformData();
				} ImGui::SameLine();
				if (ImGui::Button("Load")) {
					readUniformData();
				}
				for (int i = 0; i < uniform_count; i++) {
					// skip builtin uniforms
					if (!strcmp(u_time_name, uniforms[i].name)) continue;
					if (!strcmp(u_resolution_name, uniforms[i].name)) continue;
					if (!strcmp(u_view_to_world_name, uniforms[i].name)) continue;
					if (!strcmp(u_world_to_view_name, uniforms[i].name)) continue;
					uniforms[i].gui();
				}
			}
		}
		ImGui::End();
	}

	if (show_textures_window) {
		if (ImGui::Begin("Textures", &show_textures_window)) {
			ImGui::Columns(2);
			for (int tsi = 0; tsi < (int)ARRAY_COUNT(texture_slots); tsi++) {
				TextureSlot *texture_slot = texture_slots + tsi;

				ImGui::BeginGroup();
				ImGui::PushID(tsi);
				ImGui::Text("%d:", tsi);
				ImGui::SameLine();
				ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(0.0f, 0.6f, 0.6f));
				ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(0.0f, 0.7f, 0.7f));
				ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(0.0f, 0.8f, 0.8f));
				if (ImGui::SmallButton("x")) texture_slot->clear();
				ImGui::PopStyleColor(3);
				if (ImGui::Button(" 2D ")) openImageDialog(texture_slot);
				if (ImGui::Button("Cube")) openImageDialog(texture_slot, /*load_cube_cross*/true);
				ImGui::PopID();
				ImGui::EndGroup();

				ImGui::SameLine();
				//ImTextureID im_tex_id = (ImTextureID)(intptr_t)texture_slot->texture;
				ImGui::Image((void*)texture_slot, ImVec2(64, 64));
				if (ImGui::IsItemHovered() && texture_slot->image_filepath) {
					ImGui::SetTooltip("%s\n%dx%d", texture_slot->image_filepath,
						texture_slot->image_width, texture_slot->image_height);
				}

				if ((tsi & 1) && tsi + 1 != ARRAY_COUNT(texture_slots)) {
					ImGui::Separator();
				}
				else {
					ImGui::SameLine(); ImGui::Spacing();
				}
				ImGui::NextColumn();
			}
			ImGui::Columns(1);
		}
		ImGui::End();
	}

	if (show_camera_window) {
		if (ImGui::Begin("Camera", &show_camera_window)) {
			ImGui::DragFloat3("Location", camera_location.e);
			ImGui::SliderAngle("Pitch", &camera_euler_angles.x);
			ImGui::SliderAngle("Yaw", &camera_euler_angles.y);
			ImGui::SliderAngle("Roll", &camera_euler_angles.z);
			if (ImGui::Button("Reset")) resetCamera();
			ImGui::End();
		}
	}

	if (show_src_edit_window) {
		if (ImGui::Begin("Source editor", &show_src_edit_window)) {
			// TODO: add horizontal scrollbar
			ImGui::InputTextMultiline("##Text buffer", src_edit_buffer, sizeof(src_edit_buffer)-1,
				/*fullwidth, fullheight*/ImVec2(-1.0f, -1.0f), ImGuiInputTextFlags_AllowTabInput);
		}
		ImGui::End();
	}

	// overlay messages
	int overlay_flags = ImGuiWindowFlags_NoTitleBar
		| ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize
		| ImGuiWindowFlags_NoBringToFrontOnFocus
		| ImGuiWindowFlags_NoMove
		| ImGuiWindowFlags_NoSavedSettings;
	if (!shader_filepath && !src_edit_buffer[0]) {
		ImGui::SetNextWindowPosCenter();
		ImGui::Begin("Overlay", nullptr, ImVec2(0, 0), 0.3f, overlay_flags);
		ImGui::AlignFirstTextHeightToWidgets(); // valign text to button
		ImGui::Text("No fragment shader");
		ImGui::SameLine();
		if (ImGui::Button("Open")) openShaderDialog();
		ImGui::SameLine();
		if (ImGui::Button("New")) newShader();
		ImGui::End();
	} else if (compile_error_log) {
		ImGui::SetNextWindowPosCenter();
		ImGui::Begin("Overlay", nullptr, ImVec2(0, 0), 0.3f, overlay_flags);
		ImGui::TextUnformatted(compile_error_log);
		ImGui::End();
	}
}
Exemple #7
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RIApplication::setShowPerformanceInfo(bool enable)
{
    m_preferences->showHud = enable;
    writePreferences();
}
Exemple #8
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RIApplication::setUseShaders(bool enable)
{
    m_preferences->useShaders = enable;
    writePreferences();
}
void PreferenceDialog::closeEvent(QCloseEvent *event) {
    writePreferences();
    event->accept();
}