Esempio n. 1
0
TEST_F(CoordinateTransformableDataObject_test, PersistentCoordsSpec_ImageData)
{
    auto imageDataSet = vtkSmartPointer<vtkImageData>::New();
    imageDataSet->SetExtent(0, 1, 2, 4, 0, 0);
    imageDataSet->AllocateScalars(VTK_FLOAT, 1);
    
    ImageDataObject dataObject("image", *imageDataSet);

    const auto coordsSpec = ReferencedCoordinateSystemSpecification(
        CoordinateSystemType::geographic,
        "testGeoSystem",
        "testMetricSystem",
        "",
        { 100, 200 }, { 0.2, 0.3 });

    dataObject.specifyCoordinateSystem(coordsSpec);

    const auto fileName = QDir(TestEnvironment::testDirPath()).filePath("PersistentCoordsSpec.vti");

    ASSERT_TRUE(Exporter::exportData(dataObject, fileName));
    auto readDataObject = Loader::readFile<CoordinateTransformableDataObject>(fileName);
    ASSERT_TRUE(readDataObject);

    ASSERT_EQ(coordsSpec, readDataObject->coordinateSystem());
}
void CSysApAnimKeySndControl::ConstructL( RWindowGroup* aParent )
{
    CreateWindowL(aParent);
    SetExtent(TPoint(0,0),TSize(0,0));
    Window().SetShadowDisabled(ETrue);
    Window().Activate();
}
Esempio n. 3
0
void CSliderControl::ShrinkRects(TRect aRect,TInt aDir)
	{
	SetExtent(aRect.iTl,aRect.Size());
	CCoeControlArray::TCursor cursor = Components().Begin();
	CCoeControl* ctrl = NULL;
	TInt i=0;
	TRect r;
	while ((ctrl = cursor.Control<CCoeControl>()) != NULL)
	    {
		if (aDir==EDirectionHorizontal)
			{
			TInt w=aRect.Size().iWidth/Components().Count();
			TInt h=aRect.Size().iHeight;
			r=TRect(i*w,0,(i+1)*w,aRect.Height());
			}
		else if (aDir==EDirectionVertical)
			{
			TInt w=aRect.Size().iWidth;
			TInt h=aRect.Size().iHeight/Components().Count();
			r=TRect(0,h*i,aRect.Width(),h*(i+1));
			}		
		ctrl->SetRect(r);
	    cursor.Next();
	    i++;
	    }
	}
Esempio n. 4
0
void SpectDisplay::OnZoom(int command)
{//===============================
   static float zoomtab[] = {0.25,0.3536,0.5,0.7071,1,1.14142};
	int f1, f2, frame;
	int x,y;
	int height,width;

	GetClientSize(&width,&height);
	CalcScrolledPosition(0,0,&x,&y);

	// centre on a visible selected frame, or if none keep the centred frame centred
	f1 = int(-y/(FRAME_HEIGHT*zoomy));
	f2 = int((-y+height)/(FRAME_HEIGHT*zoomy));
	for(frame=f1; frame<=f2 && frame<spectseq->numframes; frame++)
	{
		if(spectseq->frames[frame]->selected) break;
	}
	if(frame > f2)
		frame = int((-y+height/2)/(FRAME_HEIGHT*zoomy));  // keep centred frame

	switch(command)
	{
	case T_ZOOMIN:
		if(zoom < 5) zoom++;
		break;
	case T_ZOOMOUT:
		if(zoom > 0) zoom--;
		break;
	}

	zoomx = zoomy = zoomtab[zoom];
	SetExtent();
	ScrollToFrame(frame,1);
	Refresh();
}  // end of OnZoom
Esempio n. 5
0
void ExtenStack::Undo()
{
	m_Pos--;
	if(m_Pos > -1)
	{
		OGREnvelope Env = m_EnvelopeArray[m_Pos];
		SetExtent(Env);
	}
}
Esempio n. 6
0
void ExtenStack::Redo()
{
	m_Pos++;
	if(m_Pos < m_EnvelopeArray.size())
	{
		OGREnvelope Env = m_EnvelopeArray[m_Pos];
		SetExtent(Env);
	}
}
Esempio n. 7
0
	bool GetPreviewRequest::Create(rude::CGI& cgi)
	{
		SetVersion(cgi["version"]);
		SetSourceName(cgi["sourceName"]);
		SetDataSetName(cgi["dataSetName"]);
		SetWidth(cgi["width"]);
		SetHeight(cgi["height"]);
		SetExtent(cgi["bbox"]);
		return true;
	}
Esempio n. 8
0
bool Dialog::CreateFromXML(const char* idd){
	ScopedPointer<File> fh = gUiRender->OpenFile(idd);
	if(!fh) return false;
	char* xml = (char*)fh->ReadWholeFile();
	int tmpInt;
	bool result = true;
	
	try {
		ticpp::Document doc;
		doc.Parse(xml);

		ticpp::Element* root = doc.FirstChildElement("Root_Element");
		if(root->GetAttribute("ID", &tmpInt))			SetID(tmpInt);
		if(root->GetAttribute("X", &tmpInt))			SetPositionX(tmpInt);
		if(root->GetAttribute("Y", &tmpInt))			SetPositionY(tmpInt);
		if(root->GetAttribute("WIDTH", &tmpInt))		SetSizeX(tmpInt);
		if(root->GetAttribute("HEIGHT", &tmpInt))		SetSizeY(tmpInt);
		if(root->GetAttribute("MODAL", &tmpInt))		SetModal(tmpInt);
		if(root->GetAttribute("SHOWSID", &tmpInt))		SetShowSoundID(tmpInt);
		if(root->GetAttribute("HIDESID", &tmpInt))		SetHideSoundID(tmpInt);
		if(root->GetAttribute("EXTENT", &tmpInt))		SetExtent(tmpInt);
		if(root->GetAttribute("DEFAULT_X", &tmpInt))	SetDefaultPositionX(tmpInt);
		if(root->GetAttribute("DEFAULT_Y", &tmpInt))	SetDefaultPositionY(tmpInt);
		if(root->GetAttribute("ADJUST_X", &tmpInt))		SetDefaultAdjustPositionX(tmpInt);
		if(root->GetAttribute("ADJUST_Y", &tmpInt))		SetDefaultAdjustPositionY(tmpInt);
		if(root->GetAttribute("DEFAULT_VISIBLE", &tmpInt)) SetDefaultVisible(tmpInt);
		SetName(root->GetAttribute("NAME").c_str());
		
		for(ticpp::Element* child = root->FirstChildElement(false); child; child = child->NextSiblingElement(false)){
			if(child->Value() == "CAPTION"){
				mCaption = (Caption*)CreateControlFromXML(child, this);
			}else if(child->Value() == "RADIOBUTTON"){
				RadioButton* btn = (RadioButton*)CreateControlFromXML(child, this);
				if(int id = btn->RadioBoxID()){
					RadioBox* box = (RadioBox*)GetControlByID(id);
					if(box && box->ControlType() == CT_RADIOBOX)
						box->AddButton(btn);
				}

				AddChild(btn);
			}else{
				AddChild(CreateControlFromXML(child, this));
			}
		}

	}catch(ticpp::Exception& ex){
		LOG("TinyXML Exception %s", ex.what());
		result = false;
	}

	OnCreated();

	delete [] xml;
	return result;
}
//-----------------------------------------------------
void CTestRectGc::ConstructL(TPoint aPt, TSize aSize, TRgb aPenColor, TRgb aBrushColor, CGraphicsContext::TBrushStyle aBrushStyle)
    {    
    SetPenColor(aPenColor);
    SetBrushColor(aBrushColor);
    
    SetBrushStyle(aBrushStyle);
    SetDrawType(EDrawRect);
    SetExtent(aPt, aSize);
   
   	iFrameNo = g_FrameStart+=5; //Offset frame start for next control
   	g_FrameStart %= KNumAnimFrames;			
   }
Esempio n. 10
0
	bool CreateMapRequest::Create(rude::CGI& cgi)
	{
		char str[AUGE_NAME_MAX];
		WebContext* pWebContext = augeGetWebContextInstance();

		auge_web_parameter_encoding(cgi["name"], str, AUGE_NAME_MAX, pWebContext->IsIE());
		SetName(str);
		SetExtent(cgi["extent"]);
		SetSRID(cgi["srid"]);
		SetVersion(cgi["version"]);
		return true;
	}
Esempio n. 11
0
TEST_F(ArrayChangeInformationFilter_test, vtkAssignAttribute_CorrectNumberOfComponentsPassedDownstream)
{
    inAttr->SetNumberOfComponents(3);
    inAttr->SetNumberOfTuples(17);
    for (vtkIdType i = 0; i < inAttr->GetNumberOfValues(); ++i)
    {
        inAttr->SetValue(i, static_cast<float>(i));
    }
    auto inImage = vtkSmartPointer<vtkImageData>::New();
    inImage->GetPointData()->SetScalars(inAttr);
    inImage->SetExtent(0, 0, 2, 18, 3, 3);

    auto infoSource = vtkSmartPointer<InformationSource>::New();
    infoSource->SetOutput(inImage);

    vtkDataObject::SetActiveAttributeInfo(infoSource->GetOutInfo(),
        vtkDataObject::FIELD_ASSOCIATION_POINTS,
        vtkDataSetAttributes::SCALARS,
        inAttr->GetName(),
        inAttr->GetDataType(),
        inAttr->GetNumberOfComponents(),
        static_cast<int>(inAttr->GetNumberOfTuples()));

    filter->SetAttributeLocation(ArrayChangeInformationFilter::POINT_DATA);
    filter->SetAttributeType(vtkDataSetAttributes::SCALARS);
    filter->SetInputConnection(infoSource->GetOutputPort());
    filter->EnableRenameOff();
    filter->EnableSetUnitOff();

    auto assignToVectors = vtkSmartPointer<vtkAssignAttribute>::New();
    assignToVectors->SetInputConnection(filter->GetOutputPort());
    assignToVectors->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS,
        vtkAssignAttribute::POINT_DATA);

    auto reassignScalars = vtkSmartPointer<vtkAssignAttribute>::New();
    reassignScalars->SetInputConnection(assignToVectors->GetOutputPort());
    reassignScalars->Assign(vtkDataSetAttributes::VECTORS, vtkDataSetAttributes::SCALARS,
        vtkAssignAttribute::POINT_DATA);

    auto normalize = vtkSmartPointer<vtkImageNormalize>::New();
    normalize->SetInputConnection(reassignScalars->GetOutputPort());
    normalize->SetEnableSMP(false);
    normalize->SetNumberOfThreads(1);

    // before patching (VTK 7.1+) vtkAssignAttribute, this would cause segmentation faults
    normalize->Update();
    auto outImg = normalize->GetOutput();
    auto outScalars = outImg->GetPointData()->GetScalars();

    ASSERT_EQ(inAttr->GetNumberOfComponents(), outScalars->GetNumberOfComponents());
    ASSERT_EQ(inAttr->GetNumberOfTuples(), outScalars->GetNumberOfTuples());
}
Esempio n. 12
0
void ExtenStack::Do(OGREnvelope NewEnv)
{
	m_Pos++;
	if(m_Pos == m_EnvelopeArray.size())
		m_EnvelopeArray.push_back(NewEnv);
	else
	{
		m_EnvelopeArray[m_Pos] = NewEnv;
		m_EnvelopeArray.erase(m_EnvelopeArray.begin() + m_Pos + 1, m_EnvelopeArray.end());
	}

	SetExtent(NewEnv);
}
Esempio n. 13
0
void UI2DView::Set (DBRegion region)

	{
	int value, sliderSize;
	double freeLength, dVal;
	DBRegion dataEXT = (UIDataset ())->Extent ();

	SetExtent (region);
	SetActiveExtent (ViewEXT);

	sliderSize = (int) ((ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X) * 100.0 /
							  (dataEXT.UpperRight.X - dataEXT.LowerLeft.X));
	sliderSize = sliderSize < 100 ? sliderSize : 100;
	sliderSize = sliderSize > 	 1 ? sliderSize :   1;
	freeLength = (dataEXT.UpperRight.X - dataEXT.LowerLeft.X) - (ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X);
	if (freeLength == (double) 0.0) value = 0;
	else
		{
		value = (int) ((ViewEXT.LowerLeft.X - dataEXT.LowerLeft.X) * (100.0 - sliderSize) / freeLength);
		value = value < 100 - sliderSize ? value : 100 - sliderSize;
		value = value > 0 ? value : 0;
		}
	XmScrollBarSetValues (HorScrollBarW,value,sliderSize,(int) 0x0L,sliderSize,false);

	sliderSize = (int) ((ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y) * 100.0 /
							  (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y));
	sliderSize = sliderSize < 100 ? sliderSize : 100;
	sliderSize = sliderSize > 	 1 ? sliderSize :   1;

	freeLength = (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y) - (ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y);
	if (freeLength == (double) 0.0) value = 0;
	else
		{
		value = (int) ((dataEXT.UpperRight.Y - ViewEXT.UpperRight.Y) * (100.0 - sliderSize) / freeLength);
		value = value < 100 - sliderSize ? value : 100 - sliderSize;
		value = value > 0 ? value : 0;
		}
	XmScrollBarSetValues (VerScrollBarW,value,sliderSize,(int) 0x0L,sliderSize,false);

	dVal = (ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X) / (dataEXT.UpperRight.X - dataEXT.LowerLeft.X) <
			 (ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y) / (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y) ?
			 (ViewEXT.UpperRight.X - ViewEXT.LowerLeft.X) / (dataEXT.UpperRight.X - dataEXT.LowerLeft.X) :
			 (ViewEXT.UpperRight.Y - ViewEXT.LowerLeft.Y) / (dataEXT.UpperRight.Y - dataEXT.LowerLeft.Y);
	value = (int) (dVal * 100.0);
	value = value < 100 ? value : 100;
	value = value > 0 ? value : 0;

	XmScaleSetValue (ScaleW,value);
	Draw ();
	}
Esempio n. 14
0
TEST_F(ArrayChangeInformationFilter_test, PassVectorInformation)
{
    inAttr->SetNumberOfComponents(3);
    inAttr->SetNumberOfTuples(17);
    auto inImage = vtkSmartPointer<vtkImageData>::New();
    inImage->GetPointData()->SetVectors(inAttr);
    inImage->SetExtent(0, 0, 2, 18, 3, 3);

    auto infoSource = vtkSmartPointer<InformationSource>::New();
    infoSource->SetOutput(inImage);

    vtkDataObject::SetActiveAttributeInfo(infoSource->GetOutInfo(),
        vtkDataObject::FIELD_ASSOCIATION_POINTS,
        vtkDataSetAttributes::VECTORS,
        inAttr->GetName(),
        inAttr->GetDataType(),
        inAttr->GetNumberOfComponents(),
        static_cast<int>(inAttr->GetNumberOfTuples()));

    filter->SetAttributeLocation(ArrayChangeInformationFilter::POINT_DATA);
    filter->SetAttributeType(vtkDataSetAttributes::VECTORS);
    filter->SetInputConnection(infoSource->GetOutputPort());
    filter->EnableRenameOff();
    filter->EnableSetUnitOff();

    auto getInfo = vtkSmartPointer<InformationSink>::New();
    getInfo->SetInputConnection(filter->GetOutputPort());

    getInfo->UpdateInformation();

    auto outInfo = vtkDataObject::GetActiveFieldInformation(getInfo->GetInInfo(),
        vtkDataObject::FIELD_ASSOCIATION_POINTS,
        vtkDataSetAttributes::VECTORS);

    ASSERT_TRUE(outInfo);

    ASSERT_TRUE(outInfo->Has(vtkDataObject::FIELD_NUMBER_OF_COMPONENTS()));
    ASSERT_EQ(inAttr->GetNumberOfComponents(), outInfo->Get(vtkDataObject::FIELD_NUMBER_OF_COMPONENTS()));

    ASSERT_TRUE(outInfo->Has(vtkDataObject::FIELD_NUMBER_OF_TUPLES()));
    ASSERT_EQ(inAttr->GetNumberOfTuples(), outInfo->Get(vtkDataObject::FIELD_NUMBER_OF_TUPLES()));

    ASSERT_TRUE(outInfo->Has(vtkDataObject::FIELD_NAME()));
    ASSERT_STREQ(inAttr->GetName(), outInfo->Get(vtkDataObject::FIELD_NAME()));

    ASSERT_TRUE(outInfo->Has(vtkDataObject::FIELD_ARRAY_TYPE()));
    ASSERT_EQ(inAttr->GetDataType(), outInfo->Get(vtkDataObject::FIELD_ARRAY_TYPE()));
}
Esempio n. 15
0
void CTstControl::ConstructL()
	{
	RWsSession& windowServerSession=iCoeEnv->WsSession();
	windowServerSession.SetAutoFlush(ETrue);
	CreateWindowL();
	EnableDragEvents();
	ClaimPointerGrab();
	RDrawableWindow& window=*DrawableWindow();
	window.SetOrdinalPosition(0);
	window.SetShadowHeight(3);
	CWsScreenDevice& screenDevice=*iCoeEnv->ScreenDevice();
	const TSize screenSize(screenDevice.SizeInPixels());
	SetExtent(TPoint(20, 20), TSize(screenSize.iWidth-40, screenSize.iHeight-40));
	iEikonEnv->AddDialogLikeControlToStackL(this);
	iAppServer=CTstAppServer::NewL();
	ActivateL();
	}
Esempio n. 16
0
    STDMETHOD(OnPosRectChange)(LPCRECT lprcPosRect)
    {
		HRESULT hr = E_UNEXPECTED;
		hr = S_OK;
		if (lprcPosRect && memcmp(&m_rcPos, lprcPosRect, sizeof(m_rcPos)) != 0 )
		{
			if (m_spInPlaceObject != NULL )
			{
				memcpy(&m_rcPos, lprcPosRect, sizeof(m_rcPos));
				hr = m_spInPlaceObject->SetObjectRects(&m_rcPos, &m_rcPos);
			}
			if ( SUCCEEDED(hr) )
			{
				hr = SetExtent(m_rcPos.right - m_rcPos.left, m_rcPos.bottom - m_rcPos.top);
			}
		}
		return hr;
    }
Esempio n. 17
0
// Define a constructor for my canvas
SpectDisplay::SpectDisplay(wxWindow *parent, const wxPoint& pos, const wxSize& size, SpectSeq *spect)
        : wxScrolledWindow(parent, -1, pos, size,
                           wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE)
{
   wxString filename;

//	SetCursor(wxCursor(wxCURSOR_PENCIL));
	SetBackgroundColour(* wxWHITE);

	zoom = 2;
	zoomx = 0.5;
	zoomy = 0.5;

	savepath = _T("");
	spectseq = spect;
	sframe = 0;
	pk_num = 1;

	SetExtent();

}  // end of SpectDisplay::SpectDisplay
Esempio n. 18
0
TEST_F(MatricesToVtk_Grid3D_test, read_points_from_vtkImageData)
{
    auto image = vtkSmartPointer<vtkImageData>::New();
    image->SetExtent(0, 2, 0, 3, 0, 2);
    image->SetSpacing(0.1, 0.1, 0.1);
    image->SetOrigin(-1.0, -2.0, -3.0);

    io::ReadDataSet readDataSet;
    readDataSet.type = io::DataSetType::vectorGrid3D;
    auto & data = readDataSet.data;

    const vtkIdType numPoints = image->GetNumberOfPoints();
    // xyz (tested) + 3-component vector (not tested here)
    data.resize(6, std::vector<io::t_FP>(static_cast<size_t>(numPoints)));
    for (vtkIdType i = 0; i < numPoints; ++i)
    {
        const auto stdI = static_cast<size_t>(i);
        vtkVector3d point;
        image->GetPoint(i, point.GetData());
        data[0u][stdI] = point.GetX();
        data[1u][stdI] = point.GetY();
        data[2u][stdI] = point.GetZ();
    }

    auto parsedImage = MatricesToVtk::loadGrid3D("TestingGrid3D", { readDataSet });
    ASSERT_TRUE(parsedImage);
    ASSERT_TRUE(parsedImage->dataSet());
    ASSERT_EQ(numPoints, parsedImage->dataSet()->GetNumberOfPoints());
    for (vtkIdType i = 0; i < numPoints; ++i)
    {
        vtkVector3d pRef, pParsed;
        image->GetPoint(i, pRef.GetData());
        parsedImage->dataSet()->GetPoint(i, pParsed.GetData());
        ASSERT_DOUBLE_EQ(pRef.GetX(), pRef.GetX());
        ASSERT_DOUBLE_EQ(pRef.GetY(), pRef.GetY());
        ASSERT_DOUBLE_EQ(pRef.GetZ(), pRef.GetZ());
    }
}
Esempio n. 19
0
void CAknInputBlock::ConstructL()
	{
	CreateWindowL();
	SetExtent(TPoint(0,0), TSize(0,0));
	ActivateL();
	iAppUi->AddToStackL(this, ECoeStackPriorityDialog);

    iCba = CEikButtonGroupContainer::NewL(
        CEikButtonGroupContainer::ECba,
        CEikButtonGroupContainer::EHorizontal,
        this,
        R_AVKON_SOFTKEYS_EMPTY);
    
    iCba->ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition(ECoeWinPriorityNeverAtFront);
    
    static_cast<CEikCba*>( iCba->ButtonGroup() )->SetButtonGroupFlags(
        iCba->ButtonGroup()->ButtonGroupFlags() | EAknCBAFlagRespondWhenInvisible );
    
    //Set the msk command to consume the EKeyOk event.  
    TBuf<5> tmp(_L(""));    
    iCba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, KBlockCBAMSKEmptyID, tmp );
    iCba->MakeVisible( EFalse );
    iCba->SetBoundingRect(TRect(iEikonEnv->ScreenDevice()->SizeInPixels()));
	}
Esempio n. 20
0
void SpectDisplay::OnKey(wxKeyEvent& event)
{//====================================
	int key;
	int display=0;  // 1=change one peak 2=one frame, 3=all
	int direction=0;
	int x_inc;
	int y_inc;
	int  i;
	int field=0xff;
	int keyfr;
	int control;
	int number;
	double value;
	SpectFrame *sf;
	peak_t *pk;
//	static short pk_inc1[N_PEAKS] = {2,2,2,5,5,5,5,5,5};
	static short pk_inc1[N_PEAKS] = {4,4,4,8,8,8,8,8,8};
	static short pk_inc2[N_PEAKS] = {8,8,20,20,20,20,25,25,25};

	sf = spectseq->frames[sframe];
	pk = &sf->peaks[pk_num];
	key = event.GetKeyCode();
	control = event.ControlDown();
	if(control && isalnum(key)) key |= 0x1000;

	if(event.ShiftDown())
	{
		x_inc = pk_inc1[pk_num];
		y_inc = 0x40;
	}
	else
	{
		x_inc = pk_inc2[pk_num];
		y_inc = 0x100;
	}

	switch(key)
	{
	case WXK_NEXT:
		if(sframe < spectseq->numframes-1)
		{
			formantdlg->GetValues(spectseq, sframe);
			spectseq->SelectAll(0);
			sframe++;
			spectseq->frames[sframe]->selected = 1;
			display = 3;
		}
		break;

	case WXK_PRIOR:
		if(sframe > 0)
		{
			formantdlg->GetValues(spectseq, sframe);
			spectseq->SelectAll(0);
			sframe--;
			spectseq->frames[sframe]->selected = 1;
			display = 3;
		}
		break;


	case 'Z':
		if(pk_num > 0)
		{
			pk_num--;
			display = 2;
		}
		break;

	case 'X':
		if(pk_num < N_PEAKS-1)
		{
			pk_num++;
			display = 2;
		}
		break;

	case WXK_RIGHT:
		pk->pkfreq = pk->pkfreq - (pk->pkfreq % x_inc) + x_inc;
		if(pk->pkfreq >= MAX_DISPLAY_FREQ)
			pk->pkfreq = MAX_DISPLAY_FREQ;
		display = 1;
		direction = 1;
		field = 1;
		break;

	case WXK_LEFT:
		pk->pkfreq = pk->pkfreq - (pk->pkfreq % x_inc) - x_inc;
		if(pk->pkfreq < 50)
			pk->pkfreq = 50;
		display = 1;
		direction = -1;
		field = 1;
		break;

	case WXK_UP:
		pk->pkheight = pk->pkheight - (pk->pkheight % y_inc) + y_inc;
		if(pk->pkheight >= 0x7fff)
			pk->pkheight = 0x7fff;
		display = 1;
		field = 2;
		SetKeyframe(sf,1);
		break;

	case WXK_DOWN:
		pk->pkheight = pk->pkheight - (pk->pkheight % y_inc) - y_inc;
		if(pk->pkheight <= 0)
		{
			pk->pkheight = 0;
			keyfr = 0;  // but only if all the other peaks are zero
			for(i=0; i<N_PEAKS; i++)
			{
				if(sf->peaks[i].pkheight > 0)
					keyfr = 1;
			}
			SetKeyframe(sf,keyfr);
		}

		display = 1;
		field = 2;
		break;

	case ',':   // width--
		if(event.ControlDown())
		{
			// CTRL, rotate, make right slope steeper
			if(pk_num < 3)
			{
				pk->pkright-= 5;
				pk->pkwidth += 5;
			}
		}
		else
		{
			pk->pkright -= 10;
			pk->pkwidth -= 10;
			if(pk->pkright < 0)
				pk->pkright = 0;
			if(pk->pkwidth < 0)
				pk->pkwidth = 0;
		}
		field = 4;
		display = 1;
		break;

	case '.':   // width++
		if(event.ControlDown())
		{
			// CTRL: rotate, make left slope steeper
			if(pk_num < 3)
			{
				pk->pkright += 5;
				pk->pkwidth -= 5;
			}
		}
		else
		{
			pk->pkright += 10;
			pk->pkwidth += 10;
		}
		field = 4;
		display = 1;
		break;

	case '<':   // width--
		pk->pkright -= 2;
		pk->pkwidth -= 2;
		if(pk->pkwidth < 0)
			pk->pkwidth = 0;
		display = 1;
		field = 4;
		break;

	case '>':   // width++
		pk->pkright += 2;
		pk->pkwidth += 2;
		display = 1;
		field = 4;
		break;

	case '[':   // width--
		pk->pkright -= 1;
		if(pk->pkright < 0)
			pk->pkright = 0;
		display = 1;
		field = 4;
		break;

	case ']':   // width++
		pk->pkright += 1;
		display = 1;
		field = 4;
		break;

	case '/':  // make left=right
		i = pk->pkwidth + pk->pkright;
		pk->pkwidth = pk->pkright = i/2;
		display = 1;
		field = 4;
		break;

	case 0x1041:   // CTRL-A
		spectseq->SelectAll(1);
		Refresh();
		break;

	case 0x1042:  // CTRL-B
		// toggle bass reduction
		spectseq->bass_reduction ^= 1;
		Refresh();
		break;
		
	case 0x1043:   // CTRL-C
		spectseq->ClipboardCopy();
		break;

	case 0x1044:   // CTRL-D
		// copy peaks down from previous/next keyframe
		if(event.ShiftDown())
			spectseq->CopyDown(sframe,1);
		else
			spectseq->CopyDown(sframe,-1);
		SetKeyframe(sf,1);
      display = 2;
		break;

	case 0x1047:   // CTRL-G  toggle grid
		spectseq->grid ^= 1;
		Refresh();
		break;

	case 0x1049:   // CTRL-I  interpolate between two frames
		spectseq->InterpolateAdjacent();
		display = 2;
		break;

	case 0x104b:   // CTRL-K
//		spectseq->SetKlattDefaults();
//		display = 3;
		break;

	case 0x104d:   // CTRL-M
		sf->ToggleMarker(1);
      display = 2;
		break;

	case 0x104e:   // CTRL-N
		number = wxGetNumberFromUser(_T("Toggle Marker"),_T("Marker"),_T(""),1,0,7);
		sf->ToggleMarker(number);
      display = 2;
		break;

	case 0x104f:   // CTRL-O
		spectseq->ConstructVowel();
		break;

	case 0x1051:   // CTRL-Q
		if(event.ShiftDown())
			spectseq->InterpolatePeaks(0);  // remove interpolation
		else
			spectseq->InterpolatePeaks(1);  // show interpolation
		display = 3;
		break;

	case 0x1052:   // CTRL-R
		value = sf->GetRms(spectseq->amplitude);
		break;

	case 0x1053:   // CTRL-S
		Save(savepath);
		break;

	case 0x1056:   // CTRL-V
		if(event.ShiftDown())
		{
			// insert frames from the clipboard
			sframe = spectseq->ClipboardInsert(sframe);
			SetExtent();
			display = 3;
			pitchgraph->Refresh();
			break;
		}

		// overwrite just the peaks
		if(clipboard_spect == NULL)
			break;
		i = 0;
		while((i < clipboard_spect->numframes) && ((sframe+i) < spectseq->numframes))
		{
			spectseq->frames[sframe+i]->CopyPeaks(clipboard_spect->frames[i]);
			i++;
		}
		display = 3;
		break;

	case 0x1058:   // CTRL-X
		spectseq->ClipboardCopy();
		spectseq->DeleteSelected();
		SetExtent();
		sframe = 0;
		display = 3;
		pitchgraph->Refresh();
		break;

	case 0x105a:   // CTRK-Z
		sf->ZeroPeaks();
		SetKeyframe(sf,0);
		display = 2;
		break;

	case WXK_F10:
		sf->ApplyVoiceMods();
		display = 2;
		break;

	case WXK_F2:
		// make and play sequence
		ReadDialogValues();
		spectseq->MakeWave(0,spectseq->numframes-1,voicedlg->pitchenv);
		break;

	case WXK_F1:
		// make and play selected
		ReadDialogValues();
		sf->MakeWaveF(0,voicedlg->pitchenv,spectseq->amplitude,spectseq->duration);
		break;
	case WXK_F3:
		// make and play selected
		ReadDialogValues();
		sf->MakeWaveF(1,voicedlg->pitchenv,spectseq->amplitude,spectseq->duration);
		break;

	default:
		if(key>='0' && key<='9')
		{
			i = key-'0';
			if(event.ControlDown())
			{
				if(i==0) i=10;
				PlayChild(i-1,voicedlg->pitchenv);
			}
			else
			{
				// select peak number
				if((pk_num = i) >= N_PEAKS) pk_num = N_PEAKS-1;
			}
			display=2;
		}
		event.Skip();
		break;
	}

	if(display)
	{
		pk_select = pk_num;
		sf = spectseq->frames[sframe];
		pk = &sf->peaks[pk_num];

		if(pk->pkwidth < 50) pk->pkwidth = 50; // min. width
		if(pk->pkright < 50) pk->pkright = 50;

		// ensure minimum separation between peaks & prevent crossover
		if(direction > 0)
		{
			for(i=pk_num+1; i<N_PEAKS; i++)
			{
				if(sf->peaks[i].pkfreq < sf->peaks[i-1].pkfreq + 100)
					sf->peaks[i].pkfreq = sf->peaks[i-1].pkfreq + 100;
			}
		}
		else
		if(direction < 0)
		{
			for(i=pk_num-1; i>=0; i--)
			{
				if(sf->peaks[i].pkfreq > sf->peaks[i+1].pkfreq - 100)
					sf->peaks[i].pkfreq = sf->peaks[i+1].pkfreq - 100;
			}
		}

		if(display==3)
      {
		   formantdlg->ShowFrame(spectseq,sframe,pk_num,0xff);
			Refresh();
		}
		else
		{
			// only one frame needs to be redrawn
			formantdlg->ShowFrame(spectseq,sframe,pk_num,field);
			RefreshFrame(sframe);
		}

		if(sframe >= 0)
		{
			if(ScrollToFrame(sframe,0))
				Refresh();   // shouldn't need this, but we have redraw problems
		}

	}
}  // end of SpectDisplay::OnKey
Esempio n. 21
0
void wxGISMapView::SetFullExtent(void)
{
	SetExtent(GetFullExtent());
}