Ejemplo n.º 1
0
void DiaGridView::OnInitialUpdate()
{
	// Call the base class OnInitialUpdate. This call is
	// essential for grid specific intialization (In
	// contrast to GXInit which performs application specific
	// intialization)
	CGXGridView::OnInitialUpdate();

	// Disable Undo mechanism for the following commands.
	// Objective Grid has a built in Undo/Redo  architecture
	// that can be disabled/enabled with this call.
	// We disable it here so that users are not able to
	// rollback changes that we make in code.
	GetParam()->EnableUndo(FALSE);	

  CMFCDiaDoc* pDoc = GetDocument();

  ASSERT_VALID(pDoc);
  if (!pDoc)
    return;
  m_entities = pDoc->getDrawEntities();

	SetRowCount(0);
	SetColCount(5);

	SetValueRange(CGXRange(0, 1), "figure type");
	SetValueRange(CGXRange(0, 2), "center x");
	SetValueRange(CGXRange(0, 3), "center y");
	SetValueRange(CGXRange(0, 4), "line type");
	SetValueRange(CGXRange(0, 5), "line color");

	// Re-enable undo mechanism
	GetParam()->EnableUndo(TRUE);
}
Ejemplo n.º 2
0
CString CRGXMainWndGrid::ShowPawnTicketNumbers(/*CString sHtun*/ long AsId)
{
	long lRows = 0;
	m_lLainojaKpl = 0;
	m_dLainojaYhtEuro = 0;
	m_lAktiivisiaKpl = 0;
	m_lLunastetutKpl = 0;
	m_dAktLainojaYhtEuro = 0;

	char buf[20];
	CString strResult;
	CString stmp = "";
	CString sAsId = "";
		//TRACE(" --- ShowPawnTicketNumbers\n");
	//BOOL bLock = LockUpdate();
	clear();
	setGridReadOnly(FALSE);
	try
	{
		//pLainaRS->Close();
		/*pLainaRS->m_strFilter.Format("LA_AS_HTun='"
			+ sHtun
			+ "' order by LA_Nr");*/
		sAsId.Format("%ld", AsId);
		pLainaRS->m_strFilter.Format("LA_AS_ID="
			+ sAsId
			+ " order by LA_Tila, LA_Nr");
		TRACE("...where %s\n", pLainaRS->m_strFilter);
		pLainaRS->Open();

		while (!pLainaRS->IsEOF())
		{
			lRows++;
			m_lLainojaKpl++;
			SetRowCount(lRows);

			SetValueRange(CGXRange(lRows, 1), pLainaRS->m_LA_Nr);
			SetValueRange(CGXRange(lRows, 2), pLainaRS->m_LA_LainanNimi);
			
			// --- lainan perustamispäivä ----
			sprintf(buf, "%s", pLainaRS->m_LA_AlkupPv.Format("%d.%m.%Y"));
			SetValueRange(CGXRange(lRows, 3), buf);
			//
			// --- Eräpäivä ---
			sprintf(buf, "%s", pLainaRS->m_LA_EraPv.Format("%d.%m.%Y"));
			SetValueRange(CGXRange(lRows, 4), buf);
			//
			// --- Lainan tila ---
			SetValueRange(CGXRange(lRows, 5), pLainaRS->m_LA_Tila);
			if (pLainaRS->m_LA_Tila == "L")		// lunastettu -> sininen
			{
				m_lLunastetutKpl++;
				SetStyleRange(CGXRange(lRows, 1, lRows, 16),
								CGXStyle().SetInterior(RGB(128,255,255))
								);
			}
			else if (pLainaRS->m_LA_Tila == "A")  // uudistettu -> vihreä ?
			{
				m_lAktiivisiaKpl++;
				m_dAktLainojaYhtEuro = m_dAktLainojaYhtEuro + pLainaRS->m_LA_Laina;
				SetStyleRange(CGXRange(lRows, 1, lRows, 16),
								CGXStyle().SetInterior(RGB(64,255,192))
								);
			}
			else if (pLainaRS->m_LA_Tila == "H")  // huutokaupassa -> orange ?
			{
				SetStyleRange(CGXRange(lRows, 1, lRows, 16),
								CGXStyle().SetInterior(RGB(255,128,128))
								);
			}
			else if (pLainaRS->m_LA_Tila == "M")  // myyty huutokaupassa -> light gray ?
			{
				SetStyleRange(CGXRange(lRows, 1, lRows, 16),
								CGXStyle().SetInterior(RGB(192,192,192))
								);
			}

			stmp.Format("%7.2f", pLainaRS->m_LA_VakSumma);
			SetValueRange(CGXRange(lRows, 6), stmp);
			stmp.Format("%7.2f", pLainaRS->m_LA_Laina);
			m_dLainojaYhtEuro = m_dLainojaYhtEuro + pLainaRS->m_LA_Laina;
			SetValueRange(CGXRange(lRows, 7), stmp);


			//
			// --- Odotuspäivä ---
			if(!pLainaRS->IsFieldNull(&pLainaRS->m_LA_OdotusPv))
				sprintf(buf, "%s", pLainaRS->m_LA_OdotusPv.Format("%d.%m.%Y"));
			else
				sprintf(buf, "");
			SetValueRange(CGXRange(lRows, 8), buf);


			// --- Viite ---
			sprintf(buf, "%s", theApp.buildReferenceNumberFor(pLainaRS->m_LA_Nr));
			SetValueRange(CGXRange(lRows, 9), buf);



			stmp.Format("%7.1f", pLainaRS->m_LA_Korko);
			SetValueRange(CGXRange(lRows, 10), stmp);
			SetValueRange(CGXRange(lRows, 11), pLainaRS->m_LA_Kielto);

			if (!pLainaRS->IsFieldNull(&pLainaRS->m_LA_KieltoRajaPv))
			{
				SetStyleRange(CGXRange(lRows, 1, lRows, 17),
								CGXStyle().SetInterior(RGB(255,0,0)) // red
								);
			}
			stmp.Format("%7.1f", pLainaRS->m_LA_SaVakMaksuPr);
			SetValueRange(CGXRange(lRows, 12), stmp);
			SetValueRange(CGXRange(lRows, 13), "0");
			stmp.Format("%7.2f", pLainaRS->m_LA_YlimSaMaksu);
			SetValueRange(CGXRange(lRows, 14), stmp);

			SetValueRange(CGXRange(lRows, 15), pLainaRS->m_LA_Liitteet);
			SetValueRange(CGXRange(lRows, 16), pLainaRS->m_LA_Huom);
			SetValueRange(CGXRange(lRows, 17), pLainaRS->m_LA_Varasto);

			if (pLainaRS->m_LA_EraPv < CTime::GetCurrentTime() &&
				!(pLainaRS->m_LA_Tila == "M" || pLainaRS->m_LA_Tila == "L"))
			{
				SetStyleRange(CGXRange(lRows, 4, lRows, 4),
								CGXStyle().SetInterior(RGB(250,141,69)) // rusk.punainen
								);
			}
			
			SetRowHeight(lRows,lRows,30); // Rivikork
			pLainaRS->MoveNext();
		}
	}
	catch (CDBException* e)
	{
		AfxMessageBox(e->m_strError);
		e->Delete();

	}
	pLainaRS->Close();
	//LockUpdate(bLock);
	Redraw();
	//
	setGridReadOnly(TRUE);
	
	if (lRows >= 1)
	{
		SetCurrentCell(1,0);
		strResult = GetValueRowCol(1,1);
		this->FindRow(atol(strResult));
	}
	else
	{
		SetCurrentCell(0,0);
		strResult = "";
	}

	this->resetWaitDateParam();

	//TRACE("Viimeisin lainanumero = %s\n", strResult);
	return strResult;
}
Ejemplo n.º 3
0
void CRGXMainWndGrid::updateLoanRowInfo(long loanNr)
{
	CString stmp = "";
	char buf[20];
	setGridReadOnly(FALSE);
	
	for (int i = 1; i <= int(this->GetRowCount()); i++)
	{
		if (atol(this->GetValueRowCol(i, 1)) == loanNr)
		{
			TRACE("Lainan rivi = %ld\n", i);
			break;
		}
	}
	try
	{
		pLainaRS->m_strFilter.Format("LA_Nr = %ld", loanNr);
		pLainaRS->Open();

		if (!pLainaRS->IsEOF())
		{
		
			SetValueRange(CGXRange(i, 1), pLainaRS->m_LA_Nr);
			SetValueRange(CGXRange(i, 2), pLainaRS->m_LA_LainanNimi);
			
			// --- lainan perustamispäivä ----
			sprintf(buf, "%s", pLainaRS->m_LA_AlkupPv.Format("%d.%m.%Y"));
			SetValueRange(CGXRange(i, 3), buf);
			//
			// --- Eräpäivä ---
			sprintf(buf, "%s", pLainaRS->m_LA_EraPv.Format("%d.%m.%Y"));
			SetValueRange(CGXRange(i, 4), buf);
			//
			// --- Lainan tila ---
			SetValueRange(CGXRange(i, 5), pLainaRS->m_LA_Tila);
			if (pLainaRS->m_LA_Tila == "L")		// lunastettu -> sininen
			{
				SetStyleRange(CGXRange(i, 1, i, 16),
								CGXStyle().SetInterior(RGB(128,255,255))
								);
			}
			else if (pLainaRS->m_LA_Tila == "A")  // uudistettu -> vihreä ?
			{
				SetStyleRange(CGXRange(i, 1, i, 16),
								CGXStyle().SetInterior(RGB(64,255,192))
								);
			}
			else if (pLainaRS->m_LA_Tila == "H")  // huutokaupassa -> orange ?
			{
				SetStyleRange(CGXRange(i, 1, i, 16),
								CGXStyle().SetInterior(RGB(255,128,128))
								);
			}
			else if (pLainaRS->m_LA_Tila == "M")  // myyty huutokaupassa -> light gray ?
			{
				SetStyleRange(CGXRange(i, 1, i, 16),
								CGXStyle().SetInterior(RGB(192,192,192))
								);
			}

			stmp.Format("%7.2f", pLainaRS->m_LA_VakSumma);
			SetValueRange(CGXRange(i, 6), stmp);
			stmp.Format("%7.2f", pLainaRS->m_LA_Laina);
			SetValueRange(CGXRange(i, 7), stmp);


			//
			// --- Odotuspäivä ---
			if(!pLainaRS->IsFieldNull(&pLainaRS->m_LA_OdotusPv))
				sprintf(buf, "%s", pLainaRS->m_LA_OdotusPv.Format("%d.%m.%Y"));
			else
				sprintf(buf, "");
			SetValueRange(CGXRange(i, 8), buf);


			// --- Viite ---
			sprintf(buf, "%s", theApp.buildReferenceNumberFor(pLainaRS->m_LA_Nr));
			SetValueRange(CGXRange(i, 9), buf);



			stmp.Format("%7.1f", pLainaRS->m_LA_Korko);
			SetValueRange(CGXRange(i, 10), stmp);
			SetValueRange(CGXRange(i, 11), pLainaRS->m_LA_Kielto);

			if (!pLainaRS->IsFieldNull(&pLainaRS->m_LA_KieltoRajaPv))
			{
				SetStyleRange(CGXRange(i, 1, i, 17),
								CGXStyle().SetInterior(RGB(255,0,0)) // red
								);
			}
			stmp.Format("%7.1f", pLainaRS->m_LA_SaVakMaksuPr);
			SetValueRange(CGXRange(i, 12), stmp);
			SetValueRange(CGXRange(i, 13), "0");
			stmp.Format("%7.2f", pLainaRS->m_LA_YlimSaMaksu);
			SetValueRange(CGXRange(i, 14), stmp);

			SetValueRange(CGXRange(i, 15), pLainaRS->m_LA_Liitteet);
			SetValueRange(CGXRange(i, 16), pLainaRS->m_LA_Huom);
			SetValueRange(CGXRange(i, 17), pLainaRS->m_LA_Varasto);

			if (pLainaRS->m_LA_EraPv < CTime::GetCurrentTime() &&
				!(pLainaRS->m_LA_Tila == "M" || pLainaRS->m_LA_Tila == "L"))
			{
				SetStyleRange(CGXRange(i, 4, i, 4),
								CGXStyle().SetInterior(RGB(250,141,69)) // rusk.punainen
								);
			}
			
			SetRowHeight(i,i,30); // Rivikork
		}
	}
	catch (CDBException* e)
	{
		AfxMessageBox(e->m_strError);
		e->Delete();

	}
	pLainaRS->Close();
	//LockUpdate(bLock);
	Redraw();
	//
	setGridReadOnly(TRUE);
}
Ejemplo n.º 4
0
bool Exporter::exportImageFormat(ImageDataObject & image, const QString & fileName)
{
    QString ext = QFileInfo(fileName).suffix().toLower();

    vtkSmartPointer<vtkImageWriter> writer;

    if (ext == "png")
    {
        writer = vtkSmartPointer<vtkPNGWriter>::New();
    }
    else if (ext == "jpg" || ext == "jpeg")
    {
        writer = vtkSmartPointer<vtkJPEGWriter>::New();
    }
    else if (ext == "bmp")
    {
        writer = vtkSmartPointer<vtkBMPWriter>::New();
    }

    if (!writer)
    {
        return false;
    }

    const auto scalars = image.dataSet()->GetPointData()->GetScalars();
    if (!scalars)
    {
        return false;
    }

    const auto components = scalars->GetNumberOfComponents();
    if (components != 1 && components != 3 && components != 4)
    {
        return false;
    }

    if (scalars->GetDataType() == VTK_UNSIGNED_CHAR)
    {
        writer->SetInputData(image.dataSet());
    }
    else
    {
        auto toUChar = vtkSmartPointer<ImageMapToColors>::New();
        toUChar->SetInputData(image.dataSet());

        auto lut = vtkSmartPointer<vtkLookupTable>::New();
        lut->SetNumberOfTableValues(0xFF);
        lut->SetHueRange(0, 0);
        lut->SetSaturationRange(0, 0);
        lut->SetValueRange(0, 1);

        ValueRange<> totalRange;
            
        for (int c = 0; c < components; ++c)
        {
            ValueRange<> range;
            scalars->GetRange(range.data(), c);
            totalRange.add(range);
        }

        toUChar->SetOutputFormat(
            components == 3 ? VTK_RGB :
            (components == 4 ? VTK_RGBA :
                VTK_LUMINANCE));

        toUChar->SetLookupTable(lut);

        writer->SetInputConnection(toUChar->GetOutputPort());
    }

    writer->SetFileName(fileName.toUtf8().data());
    writer->Write();

    return true;
}
Ejemplo n.º 5
0
void CRGXDeskLogRows::fillGrid(CTime date, long desk)
{
	long rowcount = 0;
	SetRowCount(rowcount);
	clear();
	CString s;
	s.Format("%s", date.Format("%d.%m.%Y@%H:%M.%S"));
	TRACE("%s\n", s);

	CTime tx(1990,1,1,0,0,0);  // alkuarvo vuonna miekka ja kypärä -> listalle tulee siis kaikki kassalokitap.
	//CTime tx(2001,9,8,16,45,0);
	CTimeSpan t1days(1,0,0,0);
	CTime ty(1990,1,1,0,0,0);
	ty = date + t1days; // loppuaika on 1 vrk suurempi kuin annettu päivämäärä

	if (desk == -1)
	{
		m_pKLRS->m_strFilter.Format("");
	}
	else
	{
		m_pKLRS->m_strFilter.Format("KL_KS_Tunnus = %ld", desk);
		
	}
	if (date != NULL)
	{
		tx = date;
	}
	s.Format("%s", tx.Format("%d.%m.%Y@%H:%M.%S"));
	TRACE("%s\n", s);
	
	SetReadOnly(FALSE);
	try
	{
		//TRACE("Tapahtumalogi: '%s'\n", m_pKLRS->m_strFilter);
		m_pKLRS->m_strSort = "KL_Aika desc"; // desc / asc
		m_pKLRS->Open();

		while(!m_pKLRS->IsEOF())
		{
			if (m_pKLRS->m_KL_Aika < tx || m_pKLRS->m_KL_Aika > ty)
			{
				m_pKLRS->MoveNext();
				continue;
			}
			rowcount++;
			SetRowCount(rowcount);
			//
			// --- kassa ---
			s.Format("%ld", m_pKLRS->m_KL_KS_Tunnus);
			SetValueRange(CGXRange(rowcount, 1), s);
			//
			// --- TapAika ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Aika))
			{
				s.Format("%s", m_pKLRS->m_KL_Aika.Format("%d.%m.%Y@%H:%M.%S"));
			}
			SetValueRange(CGXRange(rowcount, 2), s);
			//
			// --- arviomiehen tunnus ---
			SetValueRange(CGXRange(rowcount, 3), m_pKLRS->m_KL_AM_Nimikirjaimet);
			//
			// --- lainan # jos ei sitten tyhjä ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_LainaNr))
			{
				s.Format("%ld", m_pKLRS->m_KL_LainaNr);
			}
			SetValueRange(CGXRange(rowcount, 4), s);
			//
			// --- tapahtuman tyyppi ---
			SetValueRange(CGXRange(rowcount, 5), m_pKLRS->m_KL_TapahtumanTyyppi);
			//
			// --- selite ----
			SetValueRange(CGXRange(rowcount, 6), m_pKLRS->m_KL_Selite);
			//
			// --- lainan summa ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Summa))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Summa);
			}
			SetValueRange(CGXRange(rowcount, 7), s);
			//
			// --- vanha lainasumma ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_VanhaLaina))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_VanhaLaina);
			}
			SetValueRange(CGXRange(rowcount, 8), s);
			//
			// --- uusi lainasumma ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_UusiLaina))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_UusiLaina);
			}
			SetValueRange(CGXRange(rowcount, 9), s);
			//
			// --- väri --
			if (m_pKLRS->m_KL_TapahtumanTyyppi == "U")
			{
				SetStyleRange(CGXRange(rowcount, 1, rowcount, 16),
								CGXStyle().SetInterior(RGB(152,234,128))
								);
			}
			if (m_pKLRS->m_KL_TapahtumanTyyppi == "L")
			{
				SetStyleRange(CGXRange(rowcount, 1, rowcount, 16),
								CGXStyle().SetInterior(RGB(139,222,205)) // vaalean sininen
								);
			}
			if (m_pKLRS->m_KL_TapahtumanTyyppi == "D")
			{
				SetStyleRange(CGXRange(rowcount, 8, rowcount, 9),
								CGXStyle().SetInterior(RGB(255,255,192))
								);
			}
			if (m_pKLRS->m_KL_TapahtumanTyyppi == "H" ||
				m_pKLRS->m_KL_TapahtumanTyyppi == "C" ||
				m_pKLRS->m_KL_TapahtumanTyyppi == "E" ||
				m_pKLRS->m_KL_TapahtumanTyyppi == "E" ||
				m_pKLRS->m_KL_TapahtumanTyyppi == "W")
			{
				SetStyleRange(CGXRange(rowcount, 1, rowcount, 16),
								CGXStyle().SetInterior(RGB(255,200,255)) // violetti/pun
								);
			}
			//
			// --- korot ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Korot))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Korot);
			}
			SetValueRange(CGXRange(rowcount, 10), s);
			//
			// --- shv-maksut ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_SHVMaksut))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_SHVMaksut);
			}
			SetValueRange(CGXRange(rowcount, 11), s);
			//
			// --- toimitus-maksut ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Toimitusmaksut))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Toimitusmaksut);
			}
			SetValueRange(CGXRange(rowcount, 12), s);
			//
			// --- pyöristys ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Pyoristys))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Pyoristys);
			}
			SetValueRange(CGXRange(rowcount, 13), s);
			//
			// --- maksettava ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Maksettava))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Maksettava);
			}
			SetValueRange(CGXRange(rowcount, 14), s);
			//
			// --- Alijäämä ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Alijaama))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Alijaama);
			}
			SetValueRange(CGXRange(rowcount, 15), s);
			//
			// --- Ylijäämä ---
			s = "-";
			if (!m_pKLRS->IsFieldNull(&m_pKLRS->m_KL_Ylijaama))
			{
				s.Format("%7.2f", m_pKLRS->m_KL_Ylijaama);
			}
			SetValueRange(CGXRange(rowcount, 16), s);
			
			m_pKLRS->MoveNext();
		}

		m_pKLRS->Close();
	}
	catch (CDBException* e)
	{
		AfxMessageBox(e->m_strError);
		e->Delete();
		m_pKLRS->Close();
	}
	SetReadOnly(TRUE);
}