Exemplo n.º 1
0
void EventDlg::UpdateColumnEntry(int iItem, int hcol, LPTSTR val)
{
	UINT icol =ImpEditCol::m_fileheadermap[hcol];  // see this garbage? a result of poor design
	CString s;

	if (ImpEditCol::eMeasType == icol)   // for string to numeric internal maps, handle the update differently
	{
		MEvent* pm = (MEvent*)m_List.GetItemData(iItem);
		if (pm)
		{
			CString szDisplayableResult;
			pm->UpdateMeasurementInfo(ImpEditCol::m_meacolmap[icol], val, szDisplayableResult);
			m_List.SetItemText(iItem,ImpEditCol::eMeasType,tMeasurementTypeImage((tMeasurementType)pm->m_vr._iMPMeasurementType));
		}	
	}
	else
	{
		if (UpdateValue(iItem , icol, val, s)) // icol is ImpEd enum
		{
			m_List.SetItemText(iItem , icol, s);
		}
	}


}
Exemplo n.º 2
0
MStatus customAttrCtx::doRelease( MEvent & event )
//
// Description
//     This method is called when a mouse button is released while this context is
//    the current context.
//
{
	// Let the parent class handle the event.
	MStatus stat = MPxSelectionContext::doRelease( event );

	// If an object is selected, process the event if the middle mouse button
	// was lifted.
	if ( !isSelecting() ) {
		if (event.mouseButton() == MEvent::kMiddleMouse)
		{
			event.getPosition( endPos_x, endPos_y );

			// Delete the move command if we have moved less then 2 pixels
			// otherwise call finalize to set up the journal and add the
			// command to the undo queue.
			//
			if ( abs(startPos_x - endPos_x) < 2 ) {
				delete cmd;
				view.refresh( true );
			}
			else {
				stat = cmd->finalize();
				view.refresh( true );
			}
			setCursor(MCursor::defaultCursor);
		}
	}

	return stat;
}
Exemplo n.º 3
0
MStatus customAttrCtx::doDrag( MEvent & event )
//
// Description
//     This method is called when a mouse button is dragged while this context is
//    the current context.
//
{
	MStatus stat;

	// If an object has been selected, then process the drag.  Otherwise, pass the
    // event on up to the parent class.
	if ((!isSelecting()) && (event.mouseButton() == MEvent::kMiddleMouse)) {

		event.getPosition( endPos_x, endPos_y );

		// Undo the command to erase the previously set delta value from the
		// node, set a new delta value in the command and redo the command to
		// set the values in the node.
		cmd->undoIt();
		cmd->setDelta(endPos_x - startPos_x);
		stat = cmd->redoIt();
		view.refresh( true );
	}
	else
		stat = MPxSelectionContext::doDrag( event );

	return stat;
}
Exemplo n.º 4
0
bool Mint::ProcessEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
	if(!m_pMainFrame) return false;

	MEvent e;
	int nResult = e.TranslateEvent(hwnd, message, wparam, lparam);
	if(nResult&EVENT_MINT_TRANSLATED){
		// Drag & Drop
		if(m_pDragSourceObject!=NULL){
#define DRAm_VISIBLE_LENGTH	2	// µå·¡±× ¿ÀºêÁ§Æ®¸¦ º¸¿©Áֱ⠽ÃÀÛÇÏ´Â °£°Ý
			if(e.nMessage==MWM_MOUSEMOVE){
				MPOINT p = e.Pos;
				//MPOINT p = MEvent::GetMousePos();
				int px = m_GrabPoint.x - p.x;
				if ( px < 0)  px *= -1;
				int py = m_GrabPoint.y - p.y;
				if ( py < 0)  py *= -1;

				if( m_bVisibleDragObject==false &&
				    ((px > DRAm_VISIBLE_LENGTH) || (py > DRAm_VISIBLE_LENGTH)))
                    m_bVisibleDragObject = true;
				MWidget* pFind = FindWidget(p);
				if(pFind!=NULL && pFind->IsDropable(m_pDragSourceObject)==true)
					m_pDropableObject = pFind;
				else
					m_pDropableObject = NULL;
			}
			if(e.nMessage==MWM_LBUTTONUP){
				MPOINT p = e.Pos;
				MWidget* pFind = FindWidgetDropAble(p);
//				MWidget* pFind = FindWidget(p);
				if(pFind!=NULL && pFind->IsDropable(m_pDragSourceObject)==true)
					pFind->Drop(m_pDragSourceObject, m_pDragObjectBitmap, m_szDragObjectString, m_szDragObjectItemString);	// ÇØ´ç À§Á¬¿¡ µå·Ó
				m_pDragSourceObject = NULL;
				m_pMainFrame->ReleaseCapture();
				return true;
			}
		}

		// Àü¿ª À̺¥Æ® ó¸®
		if (m_fnGlobalEventCallBack) {
			if (m_fnGlobalEventCallBack(&e) == true) return true;
		}

		// ÀÏ¹Ý À̺¥Æ® ó¸®
		if(m_pMainFrame->Event(&e)==true) return true;
		// ¾øÀ¸¸é Accelerator ó¸®
		if(m_pMainFrame->EventAccelerator(&e)==true) return true;
		// Default Key(Enter, ESC) ó¸®
		if(m_pMainFrame->EventDefaultKey(&e)==true) return true;

	}
	if(nResult&EVENT_PROCESSED) return true;	// ¹«Á¶°Ç 󸮵Ê

	return false;
}
Exemplo n.º 5
0
LRESULT EventDlg::OnComboSelection(WPARAM nItem, LPARAM nSubItem)
{
	CString sle = m_List.GetComboText(nItem, nSubItem);
	MEvent* pm = (MEvent*)m_List.GetItemData(nItem);
	if (pm)
	{
		CString szDisplayableResult;
		pm->UpdateMeasurementInfo(ImpEditCol::m_meacolmap[nSubItem], sle, szDisplayableResult);
	}	

	return 0;
}
MStatus HairToolContext::doDrag( MEvent& event )
 {
	 if(intersectionFound){
		 //Our Viewer
		m_View = M3dView::active3dView();

		//Get Screen click position
		event.getPosition( m_storage[0], m_storage[1] );
		screenPoints.push_back(vec2(m_storage[0], m_storage[1]));

		//Camera stuff
		MPoint origin = MPoint();
		MVector direction = MVector();
		m_View.viewToWorld(m_storage[0], m_storage[1], origin, direction);

		float tValue = ((point - origin)*normal) / (direction * normal);
		MPoint newPoint = tValue*direction + origin;
		splinePoints.push_back(newPoint);

		//Draw GL curve
		m_View.beginXorDrawing(true, true, 1.0f, M3dView::kStippleDashed);
			glBegin(GL_LINE_STRIP );
				for ( unsigned i = 0; i < screenPoints.size() ; i++ ){
					glVertex2i( screenPoints[i][0], screenPoints[i][1] );
				 }
			glEnd();
		m_View.endXorDrawing();
	 }
	 return MPxContext::doDrag(event);
 }
Exemplo n.º 7
0
MStatus marqueeContext::doDrag( MEvent & event )
//
// Drag out the marquee (using OpenGL)
//
{
#if CUSTOM_XOR_DRAW
	xorDraw XORdraw(&view);
	XORdraw.beginXorDrawing();
#else
	view.beginXorDrawing();
#endif

	if (fsDrawn) {
		// Redraw the marquee at its old position to erase it.
		drawMarqueeGL();
	}

	fsDrawn = true;

	//	Get the marquee's new end position.
	event.getPosition( last_x, last_y );

	// Draw the marquee at its new position.
	drawMarqueeGL();

#if CUSTOM_XOR_DRAW
	XORdraw.endXorDrawing();
#else
	view.endXorDrawing();
#endif

	return MS::kSuccess;		
}
MStatus HairToolContext::doRelease( MEvent& event )
 {
	// only bother handling the release of a left mouse button.
	if(event.mouseButton() != MEvent::kLeftMouse) {
		return MPxContext::doRelease(event);
	}
	else if(!intersectionFound){
		return MPxContext::doRelease(event);
	}
	else if(splinePoints.size() < 2){
		return MPxContext::doRelease(event);
	}

	OverCoatNode::numOfSplinesCreated++;
	MGlobal::executeCommand("print \" Intersection Detected \\n\"");

	char curveCreation[8000];
	sprintf(curveCreation, "curve", OverCoatNode::numOfSplinesCreated);
	for(int i = 0; i < splinePoints.size(); i++){
		char buffer[200];
		sprintf(buffer, " -p %f %f %f", splinePoints[i].x, splinePoints[i].y, splinePoints[i].z);
		strcat(curveCreation, buffer);

	}
	MString result;
	MGlobal::executeCommand(curveCreation, result);
	const char* curveName = result.asChar();
	int splineCount;
	sscanf(curveName, "curve%d", &splineCount);

	char overCoatNodeCreation[200];
	sprintf(overCoatNodeCreation, "createNode OverCoatNode -name OverCoatNode%d", splineCount);
	MGlobal::executeCommand(overCoatNodeCreation);

	char overCoatNodeSetAttrColor[200];
	sprintf(overCoatNodeSetAttrColor, "setAttr OverCoatNode%d.color -type \"double3\" %f %f %f", splineCount, red, green, blue);
	MGlobal::executeCommand(overCoatNodeSetAttrColor);

	char overCoatNodeSetAttrThick[200];
	sprintf(overCoatNodeSetAttrThick, "setAttr OverCoatNode%d.thick %f", splineCount, thick);
	MGlobal::executeCommand(overCoatNodeSetAttrThick);

	char overCoatNodeSetAttrBrush[200];
	sprintf(overCoatNodeSetAttrBrush, "setAttr OverCoatNode%d.brush %d", splineCount, brush);
	MGlobal::executeCommand(overCoatNodeSetAttrBrush);

	char overCoatNodeSetAttrTrans[200];
	sprintf(overCoatNodeSetAttrTrans, "setAttr OverCoatNode%d.transparency %f", splineCount, transparency);
	MGlobal::executeCommand(overCoatNodeSetAttrTrans);

	char overCoatNodeConnectAttr[200];
	sprintf(overCoatNodeConnectAttr, "connectAttr curve%d.worldSpace OverCoatNode%d.spline", splineCount, splineCount);
	MGlobal::executeCommand(overCoatNodeConnectAttr);

	char overCoatNodeSetAttrSpacing[200];
	sprintf(overCoatNodeSetAttrSpacing, "setAttr OverCoatNode%d.spacing %f", splineCount, spacing);
	MGlobal::executeCommand(overCoatNodeSetAttrSpacing);

	return MS::kSuccess;
}
Exemplo n.º 9
0
MStatus customAttrCtx::doPress( MEvent & event )
//
// Description
//     This method is called when a mouse button is pressed while this context is
//    the current context.
//
{
	// Let the parent class handle the event first in case there is no object
	// selected yet.  The parent class will perform any necessary selection.
	MStatus stat = MPxSelectionContext::doPress( event );

	// If an object has been selected, then process the event.  Otherwise,
	// ignore it as there is nothing to do.
	if ( !isSelecting() ) {
		if (event.mouseButton() == MEvent::kMiddleMouse)
		{
			setCursor(MCursor::handCursor);
			view = M3dView::active3dView();

			// Create an instance of the customAttrCmd tool command and initialize
			// its delta value to 0.  As the mouse drags, the delta value will change.
			// when the mouse is lifted, a final command will be constructed with the
			// most recently set delta value and axis specifications.
			cmd = (customAttrCmd *)newToolCommand();
			cmd->setDelta(0.0);

			event.getPosition( startPos_x, startPos_y );

			// Determine the channel box attribute which will be operated on by the
			// dragging motion and set the state of the command accordingly.
			unsigned int i;
			MStringArray result;
			MGlobal::executeCommand(
					"channelBox -q -selectedMainAttributes $gChannelBoxName", result);
			for (i=0; i<result.length(); i++)
			{
				if (result[i] == customAttributeString)
				{
					cmd->setDragX();
					break;
				}
			}
		}
	}

	return stat;
}
Exemplo n.º 10
0
bool EventDlg::UpdateValue(int iEntry, int iColumnID, LPCSTR pRawString, CString& szDisplayableResult)  // column id is ImpEd enum
{
	// get the list entry (MEvent)

	// update the relevant field on the MEvent

	// return false if the value does not match the allowed data ranges

	// otherwise return true so that the text can be inserted with the correct formatting in the list row subitem

	MEvent* pm = (MEvent*)m_List.GetItemData(iEntry);
	if (pm)
	{
		pm->UpdateMeasurementInfo(ImpEditCol::m_meacolmap[iColumnID], pRawString, szDisplayableResult);
	}	
	return true;
}
Exemplo n.º 11
0
bool filterEvent(const MEvent& event, int type, bool thru)
      {
      switch(event.type()) {
            case ME_NOTEON:
            case ME_NOTEOFF:
                  if (type & MIDI_FILTER_NOTEON)
                        return true;
                  break;
            case ME_POLYAFTER:
                  if (type & MIDI_FILTER_POLYP)
                        return true;
                  break;
            case ME_CONTROLLER:
                  if (type & MIDI_FILTER_CTRL)
                        return true;
                  if (!thru && (MusEGlobal::midiFilterCtrl1 == event.dataA()
                     || MusEGlobal::midiFilterCtrl2 == event.dataA()
                     || MusEGlobal::midiFilterCtrl3 == event.dataA()
                     || MusEGlobal::midiFilterCtrl4 == event.dataA())) {
                        return true;
                        }
                  break;
            case ME_PROGRAM:
                  if (type & MIDI_FILTER_PROGRAM)
                        return true;
                  break;
            case ME_AFTERTOUCH:
                  if (type & MIDI_FILTER_AT)
                        return true;
                  break;
            case ME_PITCHBEND:
                  if (type & MIDI_FILTER_PITCH)
                        return true;
                  break;
            case ME_SYSEX:
                  if (type & MIDI_FILTER_SYSEX)
                        return true;
                  break;
            default:
                  break;
            }
      return false;
      }
Exemplo n.º 12
0
void marqueeContext::doPressCommon( MEvent & event )
{
	// Figure out which modifier keys were pressed, and set up the
	// listAdjustment parameter to reflect what to do with the selected points.
	if (event.isModifierShift() || event.isModifierControl() ) {
		if ( event.isModifierShift() ) {
			if ( event.isModifierControl() ) {
				// both shift and control pressed, merge new selections
				listAdjustment = MGlobal::kAddToList;
			} else {
				// shift only, xor new selections with previous ones
				listAdjustment = MGlobal::kXORWithList;
			}
		} else if ( event.isModifierControl() ) {
			// control only, remove new selections from the previous list
			listAdjustment = MGlobal::kRemoveFromList; 
		}
	} else {
		listAdjustment = MGlobal::kReplaceList;
	}

	// Extract the event information
	//
	event.getPosition( start_x, start_y );
}
MStatus SelectRingContext2::doPress( MEvent &event )
{
	listAdjust = MGlobal::kReplaceList;
	
	// Determine which modifier keys were pressed
	if( event.isModifierShift() || event.isModifierControl() ) 
	{
		if( event.isModifierShift() ) 
		{
			if( event.isModifierControl() ) 
				listAdjust = MGlobal::kAddToList; // Shift+Ctrl: Merge selection
			else
				listAdjust = MGlobal::kXORWithList; // Shift: Toggle selection (XOR)
		} 
		else
		{
			if( event.isModifierControl() )
				listAdjust = MGlobal::kRemoveFromList; // Ctrl: Remove selection
		}
	}
	
	// Get the position of the mouse click
	event.getPosition( pressX, pressY );

	return MS::kSuccess;		
}
Exemplo n.º 14
0
void EventDlg::SetOKButtonIfValidContent(bool bAcceptanceCheck)
{
	int good = 0;
	for (int nItem = 0; nItem < m_List.GetItemCount(); nItem++)
	{
		if (!m_List.GetCheckbox(nItem,ImpEditCol::eCheck)) 
			continue;

		MEvent* pm = (MEvent*)m_List.GetItemData(nItem);
		if (!pm)
			continue;

		if (pm->m_vr.ValidContent())
		{
			if ((!bAcceptanceCheck) || // don't care or 
				(bAcceptanceCheck && (!pm->GetAccepted()))) // catch those worth accepting
				good++;
		}
	}

	if (good < 1)
	{
		m_WaitingForFit = false;
		GetDlgItem(IDOK)->EnableWindow(false);
		SetDlgItemText(IDCANCEL, TEXT("Save Results"));
	}
	else
	{
		CString s;
		s = "Fit Selected Measurement";
		if (good > 1)
			s.Append("s");
		SetDlgItemText(IDOK, s);
		GetDlgItem(IDOK)->EnableWindow(true);
		SetDlgItemText(IDCANCEL, TEXT("Cancel"));
		m_WaitingForFit = true;
	}
}
Exemplo n.º 15
0
MStatus moveContext::doPress( MEvent & event )
{
	MStatus stat = MPxSelectionContext::doPress( event );
	MSpace::Space spc = MSpace::kWorld;

	// If we are not in selecting mode (i.e. an object has been selected)
	// then set up for the translation.
	//
	if ( !isSelecting() ) {
		event.getPosition( startPos_x, startPos_y );
		view = M3dView::active3dView();

		MDagPath camera;
		stat = view.getCamera( camera );
		if ( stat != MS::kSuccess ) {
			cerr << "Error: M3dView::getCamera" << endl;
			return stat;
		}
		MFnCamera fnCamera( camera );
		MVector upDir = fnCamera.upDirection( spc );
		MVector rightDir = fnCamera.rightDirection( spc );

		// Determine the camera used in the current view
		//
		if ( fnCamera.isOrtho() ) {
			if ( upDir.isEquivalent(MVector::zNegAxis,kVectorEpsilon) ) {
				currWin = TOP;
			} else if ( rightDir.isEquivalent(MVector::xAxis,kVectorEpsilon) ) {
				currWin = FRONT;
			} else  {
				currWin = SIDE;
			}
		}
		else {
			currWin = PERSP;
		}

		// Create an instance of the move tool command.
		//
		cmd = (moveCmd*)newToolCommand();

		cmd->setVector( 0.0, 0.0, 0.0 );
	}
	return stat;
}
Exemplo n.º 16
0
MStatus grabUVContext::doPtrMoved( MEvent & event, MHWRender::MUIDrawManager& drawMgr, const MHWRender::MFrameContext& context)
{
	MPxTexContext::doPtrMoved(event, drawMgr, context);

	double portW, portH;
	portSize(portW, portH);

	short x, y;
	event.getPosition( x, y );

	y = short(portH) - y;

	fCurrentScreenPoint = MPoint( x, y );
	fLastScreenPoint = MPoint( x, y );
	fBrushCenterScreenPoint = MPoint( x, y );

	return MS::kSuccess;
}
Exemplo n.º 17
0
MStatus moveContext::doRelease( MEvent & event )
{
	MStatus stat = MPxSelectionContext::doRelease( event );
	if ( !isSelecting() ) {
		event.getPosition( endPos_x, endPos_y );

		// Delete the move command if we have moved less then 2 pixels
		// otherwise call finalize to set up the journal and add the
		// command to the undo queue.
		//
		if ( abs(startPos_x - endPos_x) < 2 && abs(startPos_y - endPos_y) < 2 ) {
			delete cmd;
			view.refresh( true );
		}
		else {
			stat = cmd->finalize();
			view.refresh( true );
		}
	}
	return stat;
}
Exemplo n.º 18
0
MStatus marqueeContext::doPress( MEvent & event )
//
// Begin marquee drawing (using OpenGL)
// Get the start position of the marquee 
//
{

		// Figure out which modifier keys were pressed, and set up the
	// listAdjustment parameter to reflect what to do with the selected points.
	if (event.isModifierShift() || event.isModifierControl() ) {
		if ( event.isModifierShift() ) {
			if ( event.isModifierControl() ) {
				// both shift and control pressed, merge new selections
				listAdjustment = MGlobal::kAddToList;
			} else {
				// shift only, xor new selections with previous ones
				listAdjustment = MGlobal::kXORWithList;
			}
		} else if ( event.isModifierControl() ) {
			// control only, remove new selections from the previous list
			listAdjustment = MGlobal::kRemoveFromList; 
		}
	} else {
		listAdjustment = MGlobal::kReplaceList;
	}

	// Extract the event information
	//
	event.getPosition( start_x, start_y );

	// Enable OpenGL drawing on viewport
	view = M3dView::active3dView();
	view.beginGL();

#ifdef USE_SOFTWARE_OVERLAYS
	p_last_x = start_x;
	p_last_y = start_y;

	fsDrawn = false;
#else
	// If HW overlays supported then initialize the overlay plane for drawing.
	view.beginOverlayDrawing();
#endif

	return MS::kSuccess;		
}
Exemplo n.º 19
0
bool MEvent::operator<(const MEvent& e) const
{
    if (time() != e.time())
        return time() < e.time();
    if (port() != e.port())
        return port() < e.port();

    // play note off events first to prevent overlapping
    // notes

    if (channel() == e.channel())
        return type() == ME_NOTEOFF
            || (type() == ME_NOTEON && dataB() == 0);

    int map[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15};
    return map[channel()] < map[e.channel()];
}
Exemplo n.º 20
0
void marqueeContext::doReleaseCommon( MEvent & event )
{
	MSelectionList			incomingList, marqueeList;

	// Get the end position of the marquee
	event.getPosition( last_x, last_y );

	// Save the state of the current selections.  The "selectFromSceen"
	// below will alter the active list, and we have to be able to put
	// it back.
	MGlobal::getActiveSelectionList(incomingList);

	// If we have a zero dimension box, just do a point pick
	//
	if ( abs(start_x - last_x) < 2 && abs(start_y - last_y) < 2 ) {
		// This will check to see if the active view is in wireframe or not.
		MGlobal::SelectionMethod selectionMethod = MGlobal::selectionMethod();

		MGlobal::selectFromScreen( start_x, start_y, MGlobal::kReplaceList, selectionMethod );
	} else {
		// The Maya select tool goes to wireframe select when doing a marquee, so
		// we will copy that behaviour.
		// Select all the objects or components within the marquee.
		MGlobal::selectFromScreen( start_x, start_y, last_x, last_y,
			MGlobal::kReplaceList, 
			MGlobal::kWireframeSelectMethod );
	}

	// Get the list of selected items
	MGlobal::getActiveSelectionList(marqueeList);

	// Restore the active selection list to what it was before
	// the "selectFromScreen"
	MGlobal::setActiveSelectionList(incomingList, MGlobal::kReplaceList);

	// Update the selection list as indicated by the modifier keys.
	MGlobal::selectCommand(marqueeList, listAdjustment);
}
Exemplo n.º 21
0
MStatus lassoTool::doDrag( MEvent & event )
// Add to the growing lasso
{
	view.beginXorDrawing(true, true, 1.0f, M3dView::kStippleDashed);

	if (!firstDraw) {
		//	Redraw the old lasso to clear it.
		draw_lasso();
	} else {
		firstDraw = false;
	}

	coord currentPos;
	event.getPosition( currentPos.h, currentPos.v );
	append_lasso( currentPos.h, currentPos.v );

	//	Draw the new lasso.
	draw_lasso();

	view.endXorDrawing();

	return MS::kSuccess;
}
Exemplo n.º 22
0
MStatus	marqueeContext::doDrag (
	MEvent & event,
	MHWRender::MUIDrawManager& drawMgr,
	const MHWRender::MFrameContext& context)
{
	//	Get the marquee's new end position.
	event.getPosition( last_x, last_y );

	// Draw the marquee at its new position.
	drawMgr.beginDrawable();
	drawMgr.setColor( MColor(1.0f, 1.0f, 0.0f) );
	drawMgr.line2d( MPoint( start_x, start_y), MPoint(last_x, start_y) );
	drawMgr.line2d( MPoint( last_x, start_y), MPoint(last_x, last_y) );
	drawMgr.line2d( MPoint( last_x, last_y), MPoint(start_x, last_y) );
	drawMgr.line2d( MPoint( start_x, last_y), MPoint(start_x, start_y) );

	double len = (last_y - start_y) * (last_y - start_y) + 
		(last_x - start_x) * (last_x - start_x) * 0.01;
	drawMgr.line(MPoint(0,0,0), MPoint(len, len, len));
	drawMgr.endDrawable();

	return MS::kSuccess;
}
Exemplo n.º 23
0
MStatus lassoTool::doPress( MEvent & event )
// Set up for overlay drawing, and remember our starting point
{
	// Figure out which modifier keys were pressed, and set up the
	// listAdjustment parameter to reflect what to do with the selected points.
	if (event.isModifierShift() || event.isModifierControl() ) {
		if ( event.isModifierShift() ) {
			if ( event.isModifierControl() ) {
				// both shift and control pressed, merge new selections
				listAdjustment = MGlobal::kAddToList;
			} else {
				// shift only, xor new selections with previous ones
				listAdjustment = MGlobal::kXORWithList;
			}
		} else if ( event.isModifierControl() ) {
			// control only, remove new selections from the previous list
			listAdjustment = MGlobal::kRemoveFromList; 
		}
	} else {
		listAdjustment = MGlobal::kReplaceList;
	}

	// Get the active 3D view.
	//
	view = M3dView::active3dView();

	// Create an array to hold the lasso points. Assume no mem failures
	maxSize = initialSize;
	lasso = (coord*) malloc (sizeof(coord) * maxSize);

	coord start;
	event.getPosition( start.h, start.v );
	num_points = 1;
	lasso[0] = min = max = start;

	firstDraw = true;

	return MS::kSuccess;
}
MStatus SelectRingContext2::doRelease( MEvent &event )
{
	// Get the mouse release position
	event.getPosition( releaseX, releaseY );

	// Didn't select a single point
	if( abs(pressX - releaseX) > 1 || abs(pressY - releaseY) > 1 )
	{
		MGlobal::displayWarning( "Click on a single edge" );
		return MS::kFailure;
	}
	
	// Set the selection surface area
	int halfClickBoxSize = clickBoxSize / 2;
	pressX -= halfClickBoxSize;
	pressY -= halfClickBoxSize;
	releaseX = pressX + clickBoxSize;
	releaseY = pressY + clickBoxSize;
	 
	// Get the current selection
	MSelectionList curSel;
	MGlobal::getActiveSelectionList( curSel );

	//MGlobal::displayInfo( MString("Dim: ") + start_x + " " + start_y + " " + last_x + " " + last_y );
	
	// Change to object selection mode
	MGlobal::setSelectionMode( MGlobal::kSelectObjectMode );
	MGlobal::setComponentSelectionMask( MSelectionMask( MSelectionMask::kSelectObjectsMask ) );

	// Select the object under the selection area
	MGlobal::selectFromScreen( pressX, pressY, releaseX, releaseY, MGlobal::kReplaceList);
	MGlobal::executeCommand( "hilite" );
	
	// Change selection mode to mesh edges
	MGlobal::setSelectionMode( MGlobal::kSelectComponentMode );
	MGlobal::setComponentSelectionMask( MSelectionMask( MSelectionMask::kSelectMeshEdges ) );
	
	// Select the edges
	MGlobal::selectFromScreen( pressX, pressY, releaseX, releaseY, MGlobal::kReplaceList );
								   
	// Get the list of selected edges
	MSelectionList origEdgesSel;
	MGlobal::getActiveSelectionList( origEdgesSel );	
		
	// Only use the first edge in the selection
	MItSelectionList selIter( origEdgesSel, MFn::kMeshEdgeComponent );
	if( !selIter.isDone() )
	{
		MDagPath dagPath;
		MObject component;	
		selIter.getDagPath( dagPath, component );
		
		SelectRingToolCmd2 &cmd = *(SelectRingToolCmd2 *) newToolCommand();
		cmd.setCurrentSelection( curSel );
		cmd.setSelectedEdgeObject( dagPath );
		cmd.setSelectedEdgeComponent( component );
		cmd.setListAdjust( listAdjust );
		cmd.setSelEdges( selEdges );
		cmd.setSelFaces( selFaces );
		cmd.setSelVertices( selVertices );
		cmd.setSelType( SelectRingToolCmd2::SelType(selType) );
		cmd.redoIt();
		cmd.finalize();
	}
		
	return MS::kSuccess;		
}
Exemplo n.º 25
0
void ImportProcessor::ProcessImportedMeasurements()
{
	try
	{
		//	These are all the events that have data we want to check out
		StartupImpDlg StartUpDlg;
		StartUpDlg.DoIt("Find New Measurements . . .");

		// now, must identify those that are new, mark them
		POSITION pos = pM->GetHeadPosition();
		while( pos != NULL )
		{
			MEvent* p = (MEvent*)pM->GetNext( pos );
			p->Match();  // finds the closest match in time that matches the identity settings
		}

		/* case 1:	marked events match measurement timestamps found in the database
					but do they match the detector, or item id?
		   case 2:	unmarked events do not match on timestamp, may match on facility, mtype (B or (V,C))item id (or not)	

		   put up an editable dialog that shows all of these events with the matching components and unknown or unmatching
		   then for each row, allow these operations
		       fill in missing data for a matching entry (if entry)
			   
			   subclasses of data probably require some subtlety

			   for a new measurement, require a declaration to be entered into the database and what about the measurement plan?

			   The primary step now is to build the UI component and get it to work

			   use the original editable init file id class to get this going

		 */

		// put up import editor dialog that lets each measurement event be identified, then process them.

		bool bNewToProcess = false;
		bool bExistingToUpdate = false;
		bool bBkgToProcess = false;
		pos = pM->GetHeadPosition();
		CFDMSApp* pApp = (CFDMSApp*)AfxGetApp();
		StartUpDlg.SetCount(pM->GetCount());
		StartUpDlg.BumpCount();

		while( pos != NULL )
		{
			MEvent* p = (MEvent*)pM->GetNext( pos );
			if (p->GetMark())
			{
				if (!p->m_bExactMatch[eisMP])
				{
					bExistingToUpdate = true;
					pApp->AppendToLogF("* existing %s", p->Image());
				}
				else
				{
					pApp->AppendToLogF("== exact %s", p->Image());
				}
			}
			else if (p->GetAssayType() == eBackgroundAssay)
			{
				pApp->AppendToLogF("background %s [BKG]", p->Image());
				bBkgToProcess = true;
				StartUpDlg.BumpCount();
				Sleep(150);
			}
			else // 
			{
				pApp->AppendToLogF("new      %s [%d]", p->Image(), p->m_iGIndex[eisMP]);
				bNewToProcess = true;
				StartUpDlg.BumpCount();
				Sleep(150);
			}
		}
		StartUpDlg.DestroyWindow();
		if (!bExistingToUpdate && !bNewToProcess)
		{
			CFDMSApp* pApp = (CFDMSApp*)AfxGetApp();
			CString s, msg;
			s = "Imported Events from Radiation Review";
			msg = "No new or updated measurements were found in the imported events from Radiation Review.";
			pApp->MyMessageBox( msg, MB_OK | MB_ICONEXCLAMATION, (UINT)-1, s);
			bBkgToProcess = false;
		}

		if (bBkgToProcess)
		{
			BkgEventDlg x(true, pM, pB, AfxGetMainWnd());  // display all the bkg events, user operates upon and chooses the events to add to the MP
			x.DoModal();
		}
		if (bNewToProcess)
		{
			NewEventDlg y(true, pM, pB, AfxGetMainWnd());  // display all the new events in a dialog, user operates upon and chooses the events to add to the MP
			y.DoModal();
		}
		if (bExistingToUpdate)
		{
			MatchingEventDlg z(false, pM, pB, AfxGetMainWnd()); // display all the events that had a real match, user operates and chooses said same self serk
			z.DoModal();
		}
		// alternate technique: gather the matching items and the new items from the pM list and do the final storage here
	}
	catch( CMemoryException* theException )
	{
		theException->Delete();
	}
	catch (const _com_error& comerr) 
	{
		handlecomerr(comerr);				
	}
	catch (...)
	{
	}

}
Exemplo n.º 26
0
MStatus marqueeContext::doRelease( MEvent & event )
//
// Selects objects within the marquee box.
{

	MSelectionList			incomingList, marqueeList;

	// Clear the marquee when you release the mouse button

#ifdef USE_SOFTWARE_OVERLAYS

	GLboolean depthTest[1];
	GLboolean colorLogicOp[1];
	GLboolean lineStipple[1];

	event.getPosition( last_x, last_y );

	// Save the state of these 3 attribtes and restore them later.
	glGetBooleanv (GL_DEPTH_TEST, depthTest);
	glGetBooleanv (GL_COLOR_LOGIC_OP, colorLogicOp);
	glGetBooleanv (GL_LINE_STIPPLE, lineStipple);

	// Turn Line stippling on.
	glLineStipple( 1, 0x5555 );
	glLineWidth( 1.0 );
	glEnable( GL_LINE_STIPPLE );

	// Disable GL_DEPTH_TEST
	glDisable (GL_DEPTH_TEST);

	// Enable XOR mode.
	glEnable(GL_COLOR_LOGIC_OP);
	glLogicOp (GL_INVERT);

	// Save the current Matrix onto the stack
	glMatrixMode (GL_MODELVIEW);
	glPushMatrix();

	// Setup the Orthographic projection Matrix.
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
    gluOrtho2D(
    			0.0, (GLdouble) view.portWidth(),
    			0.0, (GLdouble) view.portHeight()
    );
    glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
    glTranslatef(0.375, 0.375, 0.0);

	// Set the draw color
	glIndexi (2);

	// Redraw the marquee so that it will be cleared from the screen
	// when the mouse is released.
	glBegin( GL_LINE_LOOP );
		glVertex2i( start_x, start_y );
		glVertex2i( p_last_x, start_y );
		glVertex2i( p_last_x, p_last_y );
		glVertex2i( start_x, p_last_y );
	glEnd();
		

#ifndef _WIN32
    glXSwapBuffers( view.display(), view.window() );
#else
	SwapBuffers( view.deviceContext() );
#endif

	// Restore saved Matrix from stack
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();

	glDisable(GL_COLOR_LOGIC_OP);
	
	// Restore the previous state of these attributes
	if (colorLogicOp[0])
		glEnable (GL_COLOR_LOGIC_OP);
	else
		glDisable (GL_COLOR_LOGIC_OP);

	if (depthTest[0])
		glEnable (GL_DEPTH_TEST);
	else
		glDisable (GL_DEPTH_TEST);

	if (lineStipple[0])
		glEnable( GL_LINE_STIPPLE );
	else
		glDisable( GL_LINE_STIPPLE );

#else
	// If HW overlays enabled, then clear the overlay plane
	// such that the marquee is no longer drawn on screen.
	view.clearOverlayPlane();
	view.endOverlayDrawing();
#endif

	view.endGL();

	// Get the end position of the marquee
	event.getPosition( last_x, last_y );

	// Save the state of the current selections.  The "selectFromSceen"
	// below will alter the active list, and we have to be able to put
	// it back.
	MGlobal::getActiveSelectionList(incomingList);

	// If we have a zero dimension box, just do a point pick
	//
	if ( abs(start_x - last_x) < 2 && abs(start_y - last_y) < 2 ) {
		MGlobal::selectFromScreen( start_x, start_y, MGlobal::kReplaceList );
	} else {
		// Select all the objects or components within the marquee.
		MGlobal::selectFromScreen( start_x, start_y, last_x, last_y,
								   MGlobal::kReplaceList );
	}

	// Get the list of selected items
	MGlobal::getActiveSelectionList(marqueeList);

	// Restore the active selection list to what it was before
	// the "selectFromScreen"
	MGlobal::setActiveSelectionList(incomingList, MGlobal::kReplaceList);

	// Update the selection list as indicated by the modifier keys.
	MGlobal::selectCommand(marqueeList, listAdjustment);
	return MS::kSuccess;		
}
Exemplo n.º 27
0
MStatus marqueeContext::doDrag( MEvent & event )
//
// Drag out the marquee (using OpenGL)
//
{
	
	event.getPosition( last_x, last_y );


#ifdef USE_SOFTWARE_OVERLAYS

	GLboolean depthTest[1];
	GLboolean colorLogicOp[1];
	GLboolean lineStipple[1];

	// Save the state of these 3 attribtes and restore them later.
	glGetBooleanv (GL_DEPTH_TEST, depthTest);
	glGetBooleanv (GL_COLOR_LOGIC_OP, colorLogicOp);
	glGetBooleanv (GL_LINE_STIPPLE, lineStipple);
#endif

	// Turn Line stippling on.
	glLineStipple( 1, 0x5555 );
	glLineWidth( 1.0 );
	glEnable( GL_LINE_STIPPLE );

	// Save the state of the matrix on stack
	glMatrixMode (GL_MODELVIEW);
	glPushMatrix();

	// Setup the Orthographic projection Matrix.
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
    gluOrtho2D(
    			0.0, (GLdouble) view.portWidth(),
    			0.0, (GLdouble) view.portHeight()
    );
    glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
    glTranslatef(0.375, 0.375, 0.0);

	// Set the draw color
	glIndexi (2);

	// If we are using software overlays then we need to draw the marquee
	// in XOR mode

#ifdef USE_SOFTWARE_OVERLAYS
	
	glDisable (GL_DEPTH_TEST);

	// Enable XOR mode.
	glEnable(GL_COLOR_LOGIC_OP);
	glLogicOp (GL_XOR);

	// We erase the previously drawn rubber band on the screen by 
	// redrawing it in XOR OpenGL mode.

	if (fsDrawn)
	{
		
		glBegin( GL_LINE_LOOP );
			glVertex2i( start_x, start_y );
			glVertex2i( p_last_x, start_y );
			glVertex2i( p_last_x, p_last_y );
			glVertex2i( start_x, p_last_y );
		glEnd();
		
	}

	fsDrawn = true;
#else
	// If HW overlays enabled then we will clear the overlay plane 
	// so that the previously drawn marquee does not appear on the screen
	// anymore
	view.clearOverlayPlane();

#endif

	// Draw the rectangular marquee
	//
	glBegin( GL_LINE_LOOP );
		glVertex2i( start_x, start_y );
		glVertex2i( last_x, start_y );
		glVertex2i( last_x, last_y );
		glVertex2i( start_x, last_y );
	glEnd();

#ifdef _WIN32
	SwapBuffers( view.deviceContext() );
#elif defined (OSMac_)
	::aglSwapBuffers(view.display()); 
#else
	glXSwapBuffers( view.display(), view.window() );
#endif

	// Restore the state of the matrix from stack
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();


#ifdef USE_SOFTWARE_OVERLAYS
	// Store the current x and y coordinates such that in the next iteration
	// we can erase this marquee by redrawing it in XOR mode.
	p_last_x = last_x;
	p_last_y = last_y;

	// Restore the previous state of these attributes
	if (colorLogicOp[0])
		glEnable (GL_COLOR_LOGIC_OP);
	else
		glDisable (GL_COLOR_LOGIC_OP);

	if (depthTest[0])
		glEnable (GL_DEPTH_TEST);
	else
		glDisable (GL_DEPTH_TEST);

	if (lineStipple[0])
		glEnable( GL_LINE_STIPPLE );
	else
		glDisable( GL_LINE_STIPPLE );
#endif

	return MS::kSuccess;		

}
MStatus SelectRingContext1::doRelease( MEvent &event )
{
	// Get the mouse release position
	event.getPosition( releaseX, releaseY );

	// Didn't select a single point
	if( abs(pressX - releaseX) > 1 || abs(pressY - releaseY) > 1 )
	{
		MGlobal::displayWarning( "Click on a single edge" );
		return MS::kFailure;
	}
	
	// Set the selection surface area
	int halfClickBoxSize = clickBoxSize / 2;
	pressX -= halfClickBoxSize;
	pressY -= halfClickBoxSize;
	releaseX = pressX + clickBoxSize;
	releaseY = pressY + clickBoxSize;
	 
	/*
	// Record previous selection state
	prevSelMode = MGlobal::selectionMode();
	prevCompMask = MGlobal::componentSelectionMask();
	*/

	// Get the current selection
	MSelectionList curSel;
	MGlobal::getActiveSelectionList( curSel );

	//MGlobal::displayInfo( MString("Dim: ") + start_x + " " + start_y + " " + last_x + " " + last_y );
	
	// Change to object selection mode
	MGlobal::setSelectionMode( MGlobal::kSelectObjectMode );
	MGlobal::setComponentSelectionMask( MSelectionMask( MSelectionMask::kSelectObjectsMask ) );

	// Select the object under the selection area
	MGlobal::selectFromScreen( pressX, pressY, releaseX, releaseY, MGlobal::kReplaceList);
	MGlobal::executeCommand( "hilite" );
	
	// Change selection mode to mesh edges
	MGlobal::setSelectionMode( MGlobal::kSelectComponentMode );
	MGlobal::setComponentSelectionMask( MSelectionMask( MSelectionMask::kSelectMeshEdges ) );
	
	// Select the edges
	MGlobal::selectFromScreen( pressX, pressY, releaseX, releaseY, MGlobal::kReplaceList );
								   
	// Get the list of selected edges
	MSelectionList origEdgesSel;
	MGlobal::getActiveSelectionList( origEdgesSel );	
	
	MSelectionList newEdgesSel;
	MDagPath dagPath;
	MObject component;	
	
	// Only use the first edge in the selection
	MItSelectionList selIter( origEdgesSel, MFn::kMeshEdgeComponent );
	if( !selIter.isDone() )
	{
		selIter.getDagPath( dagPath, component );
		
		MIntArray faces;
		MItMeshEdge edgeIter( dagPath, component );
		
		MIntArray edgesVisited, facesVisited;
		int edgeIndex, faceIndex;
		int prevIndex;
		unsigned int i;
		bool finished = false;
		while( !finished )
		{
			edgeIndex = edgeIter.index();
			edgesVisited.append( edgeIndex );
			
			// Create an edge component the current edge
			MFnSingleIndexedComponent indexedCompFn;
			MObject newComponent = indexedCompFn.create( MFn::kMeshEdgeComponent );
			indexedCompFn.addElement( edgeIndex );
			newEdgesSel.add( dagPath, newComponent );
			
			//MGlobal::displayInfo( MString("ADDING: ") + edgeIter.index() );
			
			edgeIter.getConnectedFaces( faces );
			faceIndex = faces[0];
			if( faces.length() > 1 )
			{
				// Select the face that hasn't already been visited
				for( i=0; i < facesVisited.length(); i++ )
				{
					if( faceIndex == facesVisited[i] )
					{
						faceIndex = faces[1];
						break;
					}
				}
			}
				
			//MGlobal::displayInfo( MString("FACE: ") + faceIndex );
			facesVisited.append( faceIndex );
			
			MItMeshPolygon polyIter( dagPath );
		
			polyIter.setIndex( faceIndex, prevIndex );
		
			//MGlobal::displayInfo( MString( "faces: " ) + faces[0] + " " + faces[1] );
		
			MIntArray edges;
			polyIter.getEdges( edges );
		
			// Determine the face-relative index of the current
			// edge
			unsigned int edgeFaceIndex = 0;
			for( i=0; i < edges.length(); i++ )
			{
				if( edges[i] == edgeIter.index() )
				{
					edgeFaceIndex = i;
					break;
				}
			}
			
			// Determine the edge that is opposite the current edge
			edgeIndex = edges[ (edgeFaceIndex + (edges.length() / 2) ) % edges.length() ];
			
			//int index = edgeIter.index();
			//MGlobal::displayInfo( MString( "sel edge index: " ) + index + " next edge: " + edgeIndex );	
			
			// Set the current edge to the opposite edge
			edgeIter.setIndex( edgeIndex, prevIndex );	

			// Determine if the edge has already been visited
			for( i=0; i < edgesVisited.length(); i++ )
			{
				if( edgeIndex == edgesVisited[i] )
				{
					finished = true;
					break;
				}							
			}
		}
	}
	
	// Set the active selection to the one previous to edge loop selection
	MGlobal::setActiveSelectionList( curSel, MGlobal::kReplaceList);

	// Update this selection based on the list adjustment setting
	MGlobal::selectCommand( newEdgesSel, listAdjust );

	return MS::kSuccess;		
}
Exemplo n.º 29
0
MStatus moveContext::doDrag( MEvent & event )
{
	MStatus stat;
	stat = MPxSelectionContext::doDrag( event );

	// If we are not in selecting mode (i.e. an object has been selected)
	// then do the translation.
	//
	if ( !isSelecting() ) {
		event.getPosition( endPos_x, endPos_y );
		MPoint endW, startW;
		MVector vec;
		view.viewToWorld( startPos_x, startPos_y, startW, vec );
		view.viewToWorld( endPos_x, endPos_y, endW, vec );
		downButton = event.mouseButton();

		// We reset the the move vector each time a drag event occurs 
		// and then recalculate it based on the start position. 
		//
		cmd->undoIt();

		switch( currWin )
		{
			case TOP:
				switch ( downButton )
				{
					case MEvent::kMiddleMouse :
						cmd->setVector( endW.x - startW.x, 0.0, 0.0 );
						break;
					case MEvent::kLeftMouse :
					default:
						cmd->setVector( endW.x - startW.x, 0.0,
											   endW.z - startW.z );
						break;
				}
				break;	

			case FRONT:
				switch ( downButton )
				{
					case MEvent::kMiddleMouse :
						cmd->setVector( endW.x - startW.x, 0.0, 0.0 );
						break;
					case MEvent::kLeftMouse :
					default:
						cmd->setVector( endW.x - startW.x,
											   endW.y - startW.y, 0.0 );
						break;
				}
				break;	

			case SIDE:
				switch ( downButton )
				{
					case MEvent::kMiddleMouse :
						cmd->setVector( 0.0, 0.0, endW.z - startW.z );
						break;
					case MEvent::kLeftMouse :
					default:
						cmd->setVector( 0.0, endW.y - startW.y,
											   endW.z - startW.z );
						break;
				}
				break;	

			case PERSP:
				break;
		}

		stat = cmd->redoIt();
		view.refresh( true );
	}
	return stat;
}
MStatus HairToolContext::doPress( MEvent& event )
 {
	// if we have a left mouse click
	if(event.mouseButton() == MEvent::kLeftMouse)
	{
		//Our Viewer
		m_View = M3dView::active3dView();

		//Get Screen click position
		event.getPosition( m_storage[0], m_storage[1] );
		screenPoints = vector<vec2>();
		screenPoints.push_back(vec2(m_storage[0], m_storage[1]));
		//char buffer[200];
		//sprintf(buffer, "print \"%i, %i\\n\"", m_storage[0], m_storage[1]);
		//MGlobal::executeCommand(buffer);

		//Camera stuff
		MPoint origin = MPoint();
		MVector direction = MVector();
		m_View.viewToWorld(m_storage[0], m_storage[1], origin, direction);

		//Iterate through meshes in scene
		bool intersection = false;
		MPointArray points =  MPointArray();
		MIntArray polygonIds =  MIntArray();
		MItDag dagIter = MItDag(MItDag::kBreadthFirst, MFn::kInvalid);
		for( ; !dagIter.isDone(); dagIter.next() ){
			MDagPath dagPath;
			dagIter.getPath(dagPath);
			MFnDagNode dagNode( dagPath);

			//Object cannot be intermediate, it must be a mesh
			if( dagNode.isIntermediateObject() ) continue;
			if( !dagPath.hasFn(MFn::kMesh) ) continue;
			if( dagPath.hasFn(MFn::kTransform) ) continue;

			MGlobal::executeCommand(MString("print \"node is a mesh \\n\""));

			//MFnMesh mesh = MFnMesh(dagPath);
			MFnMesh mesh(dagPath);
			points =  MPointArray();
			polygonIds =  MIntArray();
			intersection = mesh.intersect(origin, direction, points, 1e-010, MSpace::kWorld, &polygonIds);
			
			if(intersection){
				break;
			}
		}
		
		if(intersection){
			intersectionFound = true;

			MDagPath dagPath;
			dagIter.getPath(dagPath);
			// MFnMesh mesh = MFnMesh(dagPath);
			MFnMesh mesh(dagPath);

			//Polygon Normal
			MVector polygonNormal;
			mesh.getPolygonNormal(polygonIds[0], polygonNormal, MSpace::kWorld);
			if(polygonNormal.normal().angle(direction.normal()) < 20.0f){
				//polygonNormal = mesh.get
			}

			//Camera Right
			m_View.getCamera(dagPath);
			MFnCamera camera(dagPath);
			MVector cameraRight = camera.rightDirection(MSpace::kWorld);
			
			//Resulting Plane
			//Point
			point = points[0];
			//Normal
			normal = cameraRight^polygonNormal;

			//pushback point
			splinePoints = vector<MPoint>();
			splinePoints.push_back(MPoint(points[0].x, points[0].y, points[0].z, points[0].w));

			/*//Calculate Tvalue
			tValue = (points[0].x - origin.x)/direction.x;*/
			
		}
		else{
			intersectionFound = false;
			MGlobal::executeCommand("print \" No Intersection \\n\"");
		}

		// yay!
		return MS::kSuccess;
	}

	// just let the base class handle the event*/
	return MPxContext::doPress(event);
 }