ccGraphicalSegmentationTool::ccGraphicalSegmentationTool(QWidget* parent)
	: ccOverlayDialog(parent)
	, Ui::GraphicalSegmentationDlg()
	, m_somethingHasChanged(false)
	, m_state(0)
	, m_segmentationPoly(0)
	, m_polyVertices(0)
	, m_rectangularSelection(false)
	, m_deleteHiddenParts(false)
{
	// Set QDialog background as transparent (DGM: doesn't work over an OpenGL context)
	//setAttribute(Qt::WA_NoSystemBackground);

	setupUi(this);
	setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);

	connect(inButton,							SIGNAL(clicked()),		this,	SLOT(segmentIn()));
	connect(outButton,							SIGNAL(clicked()),		this,	SLOT(segmentOut()));
	connect(razButton,							SIGNAL(clicked()),		this,	SLOT(reset()));
	connect(validButton,						SIGNAL(clicked()),		this,	SLOT(apply()));
	connect(validAndDeleteButton,				SIGNAL(clicked()),		this,	SLOT(applyAndDelete()));
	connect(cancelButton,						SIGNAL(clicked()),		this,	SLOT(cancel()));
	connect(pauseButton,						SIGNAL(toggled(bool)),	this,	SLOT(pauseSegmentationMode(bool)));

	//selection modes
	connect(actionSetPolylineSelection,			SIGNAL(triggered()),	this,	SLOT(doSetPolylineSelection()));
	connect(actionSetRectangularSelection,		SIGNAL(triggered()),	this,	SLOT(doSetRectangularSelection()));
	//import/export options
	connect(actionUseExistingPolyline,			SIGNAL(triggered()),	this,	SLOT(doActionUseExistingPolyline()));
	connect(actionExportSegmentationPolyline,	SIGNAL(triggered()),	this,	SLOT(doExportSegmentationPolyline()));

	//add shortcuts
	addOverridenShortcut(Qt::Key_Space);  //space bar for the "pause" button
	addOverridenShortcut(Qt::Key_Escape); //escape key for the "cancel" button
	addOverridenShortcut(Qt::Key_Return); //return key for the "apply" button
	addOverridenShortcut(Qt::Key_Delete); //delete key for the "apply and delete" button
	addOverridenShortcut(Qt::Key_Tab);    //tab key to switch between rectangular and polygonal selection modes
	addOverridenShortcut(Qt::Key_I);      //'I' key for the "segment in" button
	addOverridenShortcut(Qt::Key_O);      //'O' key for the "segment out" button
	connect(this, SIGNAL(shortcutTriggered(int)), this, SLOT(onShortcutTriggered(int)));

	QMenu* selectionModeMenu = new QMenu(this);
	selectionModeMenu->addAction(actionSetPolylineSelection);
	selectionModeMenu->addAction(actionSetRectangularSelection);
	selectionModelButton->setDefaultAction(actionSetPolylineSelection);
	selectionModelButton->setMenu(selectionModeMenu);

	QMenu* importExportMenu = new QMenu(this);
	importExportMenu->addAction(actionUseExistingPolyline);
	importExportMenu->addAction(actionExportSegmentationPolyline);
	loadSaveToolButton->setMenu(importExportMenu);

	m_polyVertices = new ccPointCloud("vertices");
	m_segmentationPoly = new ccPolyline(m_polyVertices);
	m_segmentationPoly->setForeground(true);
	m_segmentationPoly->setColor(ccColor::green);
	m_segmentationPoly->showColors(true);
	m_segmentationPoly->set2DMode(true);
	allowPolylineExport(false);
}
ccGraphicalTransformationTool::ccGraphicalTransformationTool(QWidget* parent)
	: ccOverlayDialog(parent)
	, Ui::GraphicalTransformationDlg()
	, m_toTransform("transformed")
{
	setupUi(this);

	connect(pauseButton,	SIGNAL(toggled(bool)),	this, SLOT(pause(bool)));
	connect(okButton,		SIGNAL(clicked()),		this, SLOT(apply()));
	connect(razButton,		SIGNAL(clicked()),		this, SLOT(reset()));
	connect(cancelButton,	SIGNAL(clicked()),		this, SLOT(cancel()));

	//add shortcuts
	addOverridenShortcut(Qt::Key_Space); //space bar for the "pause" button
	addOverridenShortcut(Qt::Key_Escape); //escape key for the "cancel" button
	addOverridenShortcut(Qt::Key_Return); //return key for the "ok" button
	connect(this, SIGNAL(shortcutTriggered(int)), this, SLOT(onShortcutTriggered(int)));
}
ccTracePolylineTool::ccTracePolylineTool(ccPickingHub* pickingHub, QWidget* parent)
	: ccOverlayDialog(parent)
	, Ui::TracePolyLineDlg()
	, m_polyTip(0)
	, m_polyTipVertices(0)
	, m_poly3D(0)
	, m_poly3DVertices(0)
	, m_done(false)
	, m_pickingHub(pickingHub)
{
	assert(pickingHub);

	setupUi(this);
	setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);

	connect(saveToolButton, SIGNAL(clicked()), this, SLOT(exportLine()));
	connect(resetToolButton, SIGNAL(clicked()), this, SLOT(resetLine()));
	connect(continueToolButton, SIGNAL(clicked()), this, SLOT(continueEdition()));
	connect(validButton, SIGNAL(clicked()), this, SLOT(apply()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
	connect(widthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(onWidthSizeChanged(int)));

	//add shortcuts
	addOverridenShortcut(Qt::Key_Escape); //escape key for the "cancel" button
	addOverridenShortcut(Qt::Key_Return); //return key for the "apply" button
	connect(this, SIGNAL(shortcutTriggered(int)), this, SLOT(onShortcutTriggered(int)));

	m_polyTipVertices = new ccPointCloud("Tip vertices");
	m_polyTipVertices->reserve(2);
	m_polyTipVertices->addPoint(CCVector3(0, 0, 0));
	m_polyTipVertices->addPoint(CCVector3(1, 1, 1));
	m_polyTipVertices->setEnabled(false);

	m_polyTip = new ccPolyline(m_polyTipVertices);
	m_polyTip->setForeground(true);
	m_polyTip->setTempColor(ccColor::green);
	m_polyTip->set2DMode(true);
	m_polyTip->reserve(2);
	m_polyTip->addPointIndex(0, 2);
	m_polyTip->setWidth(widthSpinBox->value() < 2 ? 0 : widthSpinBox->value()); //'1' is equivalent to the default line size
	m_polyTip->addChild(m_polyTipVertices);

	validButton->setEnabled(false);
}
Exemplo n.º 4
0
ccCompassDlg::ccCompassDlg(QWidget* parent/*=0*/)
	: ccOverlayDialog(parent)
	, Ui::compassDlg()
{
	setupUi(this);

	//setup "algorithm" dropdown
	m_cost_algorithm_menu = new QMenu(this);
	m_cost_algorithm_menu->setTitle("Algorithm");
	m_dark = new QAction("Darkness", this); m_dark->setCheckable(true); m_dark->setChecked(true);
	m_light = new QAction("Lightness", this); m_light->setCheckable(true);
	m_rgb = new QAction("RGB similarity", this); m_rgb->setCheckable(true);
	m_grad = new QAction("RGB gradient", this); m_grad->setCheckable(true); //m_grad->setEnabled(true);
	m_curve = new QAction("Curvature", this); m_curve->setCheckable(true); //m_curve->setEnabled(false);
	m_dist = new QAction("Distance", this); m_dist->setCheckable(true);
	m_scalar = new QAction("Scalar field", this); m_scalar->setCheckable(true);
	m_scalar_inv = new QAction("Inverse scalar field", this); m_scalar_inv->setCheckable(true);
	m_recalculate = new QAction("Recalculate selection", this); //used to recalculate selected traces with new cost function
	m_plane_fit = new QAction("Fit planes", this); m_plane_fit->setCheckable(true); m_plane_fit->setChecked(true);

	//setup tool-tips
	m_dark->setToolTip("Traces follow 'dark' points. Good for shadowed fracture traces.");
	m_light->setToolTip("Traces follow 'light' points. Good for thin quartz veins etc.");
	m_rgb->setToolTip("Traces follow points that have a similar color to the start and end points. Useful if structures being traced have a distinct color.");
	m_grad->setToolTip("Traces follow points in neighbourhoods with high colour gradients. Good for contacts.");
	m_curve->setToolTip("Traces follow ridges and valleys. Good for fractures with high relief, especially in combination with \"Darkness\".");
	m_dist->setToolTip("Traces take the shortest euclidean path (how booring...)");
	m_scalar->setToolTip("Use the active scalar field to define path cost (i.e. the path follows low scalar values).");
	m_scalar_inv->setToolTip("Use the inverse of the active scalar field to define path cost (i.e. the path follows high scalar values).");
	m_recalculate->setToolTip("Recalculate the selected traces using the latest cost function");

	//add to menu
	m_cost_algorithm_menu->addAction(m_dark);
	m_cost_algorithm_menu->addAction(m_light);
	m_cost_algorithm_menu->addAction(m_rgb);
	m_cost_algorithm_menu->addAction(m_grad);
	m_cost_algorithm_menu->addAction(m_curve);
	m_cost_algorithm_menu->addAction(m_dist);
	m_cost_algorithm_menu->addAction(m_scalar);
	m_cost_algorithm_menu->addAction(m_scalar_inv);
	m_cost_algorithm_menu->addSeparator();
	m_cost_algorithm_menu->addAction(m_recalculate);

	//add callbacks
	ccCompassDlg::connect(m_dark, SIGNAL(triggered()), this, SLOT(setDarkCost()));
	ccCompassDlg::connect(m_light, SIGNAL(triggered()), this, SLOT(setLightCost()));
	ccCompassDlg::connect(m_rgb, SIGNAL(triggered()), this, SLOT(setRGBCost()));
	ccCompassDlg::connect(m_grad, SIGNAL(triggered()), this, SLOT(setGradCost()));
	ccCompassDlg::connect(m_curve, SIGNAL(triggered()), this, SLOT(setCurveCost()));
	ccCompassDlg::connect(m_dist, SIGNAL(triggered()), this, SLOT(setDistCost()));
	ccCompassDlg::connect(m_scalar, SIGNAL(triggered()), this, SLOT(setScalarCost()));
	ccCompassDlg::connect(m_scalar_inv, SIGNAL(triggered()), this, SLOT(setInvScalarCost()));

	//setup settings menu
	m_settings_menu = new QMenu(this);
	m_plane_fit = new QAction("Fit planes", this); m_plane_fit->setCheckable(true); m_plane_fit->setChecked(false);
	m_showStippled = new QAction("Show stippled", this); m_showStippled->setCheckable(true); m_showStippled->setChecked(true);
	m_showNormals = new QAction("Show normals", this); m_showNormals->setCheckable(true); m_showNormals->setChecked(true);
	m_showNames = new QAction("Show names", this); m_showNames->setCheckable(true); m_showNames->setChecked(false);

	m_plane_fit->setToolTip("If checked, a plane will automatically be fitted to traces matching the criteria defined in the ccCompass description.");
	m_showStippled->setToolTip("If checked, planes will be drawn partially transparent (stippled).");
	m_showNormals->setToolTip("If checked, plane normals will be drawn.");
	m_showNames->setToolTip("If checked, plane orientations will be displayed in the 3D view.");

	m_settings_menu->addAction(m_plane_fit);
	m_settings_menu->addAction(m_showStippled);
	m_settings_menu->addAction(m_showNormals);
	m_settings_menu->addAction(m_showNames);
	m_settings_menu->addSeparator();
	m_settings_menu->addMenu(m_cost_algorithm_menu);
	
	algorithmButton->setPopupMode(QToolButton::InstantPopup);
	algorithmButton->setMenu(m_settings_menu); //add settings menu
	algorithmButton->setEnabled(true);
	
	//setup pair picking menu
	m_pairpicking_menu = new QMenu(this);
	m_research_menu = new QMenu(this);
	m_research_menu->setTitle("Research");

	m_loadFoliations = new QAction("Import foliations...", this);
	m_loadLineations = new QAction("Import lineations...", this);
	m_toSVG = new QAction("Export SVG...", this);
	m_noteTool = new QAction("Add note", this);
	m_pinchTool = new QAction("Add pinch nodes", this);
	m_measure_thickness = new QAction("Measure one-point thickness", this);
	m_measure_thickness_twoPoint = new QAction("Measure two-point thickness", this);
	m_youngerThan = new QAction("Assign \"Younger-Than\" relationship", this); m_youngerThan->setEnabled(false); //todo
	m_follows = new QAction("Assign \"Follows\" relationship", this); m_follows->setEnabled(false);
	m_equivalent = new QAction("Assign \"Equivalent\" relationship", this); m_equivalent->setEnabled(false);
	m_fitPlaneToGeoObject = new QAction("Fit plane to GeoObject", this);
	m_mergeSelected = new QAction("Merge selected GeoObjects", this);
	m_estimateNormals = new QAction("Estimate structure normals", this);

	m_pinchTool->setToolTip("Add Pinch Node objects to record features such as dyke tips or sedimentary units that pinch-out.");
	m_loadFoliations->setToolTip("Converts a point cloud containing points (measurement location) and dip/dip-direction scalar fields to planes.");
	m_loadLineations->setToolTip("Convert a point cloud containing measurement points and trend->plunge scalar fields into foliation objects.");
	m_toSVG->setToolTip("Export the currently visible trace to a SVG vector graphic using an orthographic projection of the current view.");
	m_noteTool->setToolTip("Add short notes to a point in a point cloud for future reference.");
	m_measure_thickness->setToolTip("Select a plane and then a point to measure plane-perpendicular thickness.");
	m_measure_thickness_twoPoint->setToolTip("Measure the plane-perpendicular distance between two points.");
	m_youngerThan->setToolTip("Pick two GeoObjects to assign a \"younger-than\" (i.e. crosscutting, superposition) relationshi.p");
	m_follows->setToolTip("Select two GeoObjects to assign a \"follows\" (i.e. conformable) relationship.");
	m_equivalent->setToolTip("Select two GeoObjects to assign an \"equivalent\" (i.e. coeval) relationship.");
	m_fitPlaneToGeoObject->setToolTip("Calculates best fit planes for the entire upper/lower surfaces of the GeoObject.");
	m_mergeSelected->setToolTip("Merge all selected GeoObjects into a single GeoObject.");
	m_estimateNormals->setToolTip("Estimate trace structure normals with maximum a-postiori plane fitting algorithm.");
	

	m_pairpicking_menu->addAction(m_pinchTool);
	m_pairpicking_menu->addAction(m_measure_thickness);
	m_pairpicking_menu->addAction(m_measure_thickness_twoPoint);
	m_pairpicking_menu->addAction(m_noteTool);
	m_pairpicking_menu->addSeparator();
	//m_pairpicking_menu->addAction(m_youngerThan); //TODO - reenable these once topology code has been fixed
	//m_pairpicking_menu->addAction(m_follows);
	//m_pairpicking_menu->addAction(m_equivalent);
	//m_pairpicking_menu->addSeparator();
	m_pairpicking_menu->addAction(m_fitPlaneToGeoObject);
	m_pairpicking_menu->addAction(m_mergeSelected);
	m_pairpicking_menu->addAction(m_estimateNormals);
	m_pairpicking_menu->addSeparator();
	m_pairpicking_menu->addAction(m_loadFoliations);
	m_pairpicking_menu->addAction(m_loadLineations);
	m_pairpicking_menu->addAction(m_toSVG);
	m_pairpicking_menu->addSeparator();
	m_pairpicking_menu->addMenu(m_research_menu);
	
	
	//Add tools to research menu
	m_recalculateFitPlanes = new QAction("Recalculate fit-planes", this);
	m_toPointCloud = new QAction("Convert to point cloud", this);
	m_distributeSelection = new QAction("Distribute to GeoObjects", this);
	m_estimateP21 = new QAction("Estimate P21 intensity", this);
	m_estimateStrain = new QAction("Estimate strain", this);

	m_recalculateFitPlanes->setToolTip("Recalculates all fit-planes deriving from traces and GeoObjects (but not those calculated with the Plane Tool).");
	m_toPointCloud->setToolTip("Converts the selected GeoObject(s) or individual traces to a point cloud (typically for proximity analysis).");
	m_distributeSelection->setToolTip("Distributes the selected objects into GeoObjects that have matching names.");
	m_estimateP21->setToolTip("Uses structure traces and the mesh octree to measure fracture intensity.");
	m_estimateStrain->setToolTip("Estimate bulk strain tensor from Mode-I dykes and veins with structure normal estimates.");

	m_research_menu->addAction(m_recalculateFitPlanes);
	m_research_menu->addAction(m_estimateP21);
	m_research_menu->addAction(m_estimateStrain);
	m_research_menu->addAction(m_distributeSelection);
	m_research_menu->addAction(m_toPointCloud);
	
	extraModeButton->setPopupMode(QToolButton::InstantPopup);
	extraModeButton->setMenu(m_pairpicking_menu);

	//set background color
	QPalette p;
	p.setColor(backgroundRole(), QColor(240, 240, 240, 200));
	setPalette(p);
	setAutoFillBackground(true);

	//add shortcuts
	addOverridenShortcut(Qt::Key_Escape); //escape key for the "cancel" button
	addOverridenShortcut(Qt::Key_Return); //return key for the "apply" button
	addOverridenShortcut(Qt::Key_Space); //space key also hits the "apply" button (easier for some)
	connect(this, SIGNAL(shortcutTriggered(int)), this, SLOT(onShortcutTriggered(int)));
}