int
main
	(
	int		argc,
	char*	argv[]
	)
{
	ParseTextOptions(&argc, argv);

	JXApplication* app = new JXApplication(&argc, argv, "testj2dplot", kDefaultStringData);
	assert( app != NULL );

	Test2DPlotDirector* dataDir = new Test2DPlotDirector(app);
	assert( dataDir != NULL );
	TestData(dataDir);

	Test2DPlotDirector* logDataDir = new Test2DPlotDirector(app);
	assert( logDataDir != NULL );
	TestLogData(logDataDir);

	Test2DPlotDirector* vectorDir = new Test2DPlotDirector(app);
	assert( vectorDir != NULL );
	TestVector(vectorDir);

	logDataDir->Activate();
	dataDir->Activate();
	vectorDir->Activate();
	app->Run();
	return 0;
}
Example #2
0
int ParseThread::parseAction ( const QString& _filepath )
{
    ex::XmlSerializeNode loadNode;
    loadNode.loadFromFile ( qPrintable(_filepath) );
    TestData* testData = ex_new TestData();
    EX_SERIALIZE( &loadNode, testData->getClassName(), *testData );

    // if this is a valid action element
    if ( testData->ID() != -1 && testData->tag() != ex::string_t::null ) {
        ElementItem* item = new ElementItem();
        item->setText ( 0, QString::number(testData->ID()) ); 
        item->setCheckState ( 0, Qt::Unchecked ); 
        item->setFlags ( item->flags() & ~Qt::ItemIsUserCheckable ); 
        item->setText ( 1, QString::fromUtf8(testData->tag().c_str()) ); 
        item->setPropObj ( ex::SmartPtr<ex::PropertyObject>(testData) ); 

        // it is possible we abort the programme with thread still running.
        if ( m_treeWidget ) {
            m_treeWidget->addTopLevelItem (item);
            return 0;
        }
        else {
            return 1; // need break the thread
        }
    }

    return -1;
}
int main(void)
{
    double global_maximum=0;
    TrainingData store[1000];
    size_t count=0;
    size_t* data_count=&count;
    double weightlist[2];

    global_maximum=ReadData(store,data_count,global_maximum);
    TrainNeuron(store,data_count,weightlist,global_maximum);
    TestData(weightlist,global_maximum);
    return(0);
}
Example #4
0
// Test case: usage on class types.
void QtlVariableTest::testClass()
{
    typedef QtlVariable<TestData> TestVariable;

    QVERIFY(TestData::instanceCount() == 0);
    {
        TestVariable v1;
        QVERIFY(!v1.set());
        QTLVERIFY_THROW(v1.value().v(), QtlUninitializedException);
        QCOMPARE(TestData::instanceCount(), 0);

        TestVariable v2(v1);
        QVERIFY(!v2.set());
        QCOMPARE(TestData::instanceCount(), 0);

        v2 = TestData(1);
        QVERIFY(v2.set());
        QCOMPARE(v2.value().v(), 1);
        QCOMPARE(TestData::instanceCount(), 1);

        TestVariable v3(v2);
        QVERIFY(v3.set());
        QCOMPARE(TestData::instanceCount(), 2);

        TestVariable v4(TestData(2));
        QVERIFY(v4.set());
        QCOMPARE(TestData::instanceCount(), 3);

        v4 = v1;
        QVERIFY(!v4.set());
        QCOMPARE(TestData::instanceCount(), 2);

        v4 = v2;
        QVERIFY(v4.set());
        QCOMPARE(TestData::instanceCount(), 3);

        v4.reset();
        QVERIFY(!v4.set());
        QCOMPARE(TestData::instanceCount(), 2);

        v4.reset();
        QVERIFY(!v4.set());
        QCOMPARE(TestData::instanceCount(), 2);

        v1 = TestData(1);
        QCOMPARE(TestData::instanceCount(), 3);
        v2.reset();
        QCOMPARE(TestData::instanceCount(), 2);
        QVERIFY(v1.set());
        QVERIFY(!v2.set());
        QCOMPARE(v1.value().v(), 1);
        QCOMPARE(v1.value(TestData(2)).v(), 1);
        QCOMPARE(v2.value(TestData(2)).v(), 2);
        QCOMPARE(TestData::instanceCount(), 2);

        v1 = TestData(1);
        QCOMPARE(TestData::instanceCount(), 2);
        v2 = TestData(1);
        QCOMPARE(TestData::instanceCount(), 3);
        v3 = TestData(3);
        QCOMPARE(TestData::instanceCount(), 3);
        v4.reset();
        QCOMPARE(TestData::instanceCount(), 3);
        TestVariable v5;
        QCOMPARE(TestData::instanceCount(), 3);
        QVERIFY(v1.set());
        QVERIFY(v2.set());
        QVERIFY(v3.set());
        QVERIFY(!v4.set());
        QVERIFY(!v5.set());
        QVERIFY(v1 == v2);
        QVERIFY(v1 != v3);
        QVERIFY(v1 != v4);
        QVERIFY(v4 != v5);
        QCOMPARE(v1.value().v(), 1);
        QVERIFY(v1 == TestData(1));
        QVERIFY(v1 != TestData(2));
        QVERIFY(v4 != TestData(1));
        QCOMPARE(TestData::instanceCount(), 3);
    }
    // Check that the destructor of variable properly destroys the contained object
    QCOMPARE(TestData::instanceCount(), 0);
}
Example #5
0
void CScanDlg::OnBnClickedBtnScan()
{
#ifdef TEST_TIP_SHOW
	CScanMgrDlg* pTmpDlg = (CScanMgrDlg*)GetParent();
	pTmpDlg->ShowChildDlg(3);
	return;
#endif
	int           sel = m_comboScanner.GetCurSel();
	TW_INT16      index = (TW_INT16)m_comboScanner.GetItemData(sel);
	pTW_IDENTITY  pID = NULL;

	_nScanStatus_ = 0;
	if (!_bLogin_)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "未登录, 无法扫描");
		dlg.DoModal();
		return;
	}
	if (_pCurrExam_->nModel == 0 && !_pModel_)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "当前考试无模板信息");
		dlg.DoModal();
		return;
	}

	int nMustScanNum = 0;		//必须扫描的试卷数量,在高厉害模式时生效,保存试卷时,检查扫描的数量是否与此数量一致,不一致不能提交,只能重扫
	if (g_nHighSevereMode && _pCurrExam_->nModel == 0)	//手阅模式不显示扫描数量对话框
	{
		int nDefScanCounts = 0;
		char* ret;
		ret = new char[20];
		ret[0] = '\0';
		if (ReadRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "defScanCounts", ret) == 0)
		{
			nDefScanCounts = atoi(ret);
		}
		SAFE_RELEASE_ARRY(ret);
		g_nDefStudentsInKC = nDefScanCounts > 0 ? nDefScanCounts : 30;

		//高厉害考试模式
		CSetScanNumDlg dlg(g_nDefStudentsInKC);
		if (dlg.DoModal() != IDOK)
			return;
		nMustScanNum = dlg.m_nScanNum;

		char szRet[20] = { 0 };
		sprintf_s(szRet, "%d", nMustScanNum);
		WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "defScanCounts", szRet);
	}

	if (_nScanAnswerModel_ == 1)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(1, 1, "当前处于扫描 客观题(Omr) 答案模式!");
		dlg.DoModal();
	}
	else if (_nScanAnswerModel_ == 2)
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(1, 1, "当前处于扫描 主观题 答案模式!");
		dlg.DoModal();
	}
	
	USES_CONVERSION;
	char szPicTmpPath[MAX_PATH] = { 0 };
	sprintf_s(szPicTmpPath, "%sPaper\\Tmp", T2A(g_strCurrentPath));

	std::string strUtfPath = CMyCodeConvert::Gb2312ToUtf8(szPicTmpPath);
	try
	{
		Poco::File tmpPath(strUtfPath);
		if (tmpPath.exists())
			tmpPath.remove(true);

		Poco::File tmpPath1(strUtfPath);
		tmpPath1.createDirectories();
	}
	catch (Poco::Exception& exc)
	{
		std::string strLog = "删除临时文件夹失败(" + exc.message() + "): ";
		strLog.append(szPicTmpPath);
		g_pLogger->information(strLog);
	}

	m_strCurrPicSavePath = szPicTmpPath;

#ifdef Test_Data
	TestData();
	if (g_nHighSevereMode)	_pCurrPapersInfo_->nMustScanNum = nMustScanNum;
	return;
#endif

	//获取扫描参数
	int nScanSize = 1;				//1-A4		//TWSS_A4LETTER-a4, TWSS_A3-a3, TWSS_NONE-自定义
	int nScanType = 2;				//0-黑白,1-灰度,2-彩色
	int nScanDpi = 200;				//dpi: 72, 150, 200, 300
	int nAutoCut = 1;
	if (_pModel_)
	{
		nScanSize = _pModel_->nScanSize;
		nScanType = _pModel_->nScanType;
		nScanDpi = _pModel_->nScanDpi;
		nAutoCut = _pModel_->nAutoCut;

		m_nModelPicNums = _pModel_->nPicNum;

		//扫描主观题答案时,模板图像数值1
		if(_nScanAnswerModel_ == 2) m_nModelPicNums = 1;
	}
	else  //手阅
	{
		m_nModelPicNums = _nPicNum4Ty_;
	}

	bool bShowScanSrcUI = g_bShowScanSrcUI ? true : m_bAdvancedScan;			//显示高级扫描界面


	_nDoubleScan_ = m_comboDuplex.GetCurSel();
	int nDuplex = m_comboDuplex.GetCurSel();		//单双面,0-单面,1-双面
	int nSize = TWSS_NONE;							//1-A4		//TWSS_A4LETTER-a4, TWSS_A3-a3, TWSS_NONE-自定义
	if (nScanSize == 1)
		nSize = TWSS_A4LETTER;
	else if (nScanSize == 2)
		nSize = TWSS_A3;
	else
		nSize = TWSS_NONE;
	
	int nNum = 0;
	if (nDuplex == 0)
	{
		nNum = m_nCurrentScanCount * m_nModelPicNums;
	}
	else
	{
		int nModelPics = m_nModelPicNums;
		if (nModelPics % 2)
			nModelPics++;

		nNum = m_nCurrentScanCount * nModelPics;
	}
	if (nNum == 0)
		nNum = -1;
	
	CScanMgrDlg* pDlg = (CScanMgrDlg*)GetParent();
	if (NULL != (pID = pDlg->GetScanSrc(index)))
	{
		SAFE_RELEASE(_pCurrPapersInfo_);
		_pCurrPapersInfo_ = new PAPERSINFO();

		if (g_nHighSevereMode)	_pCurrPapersInfo_->nMustScanNum = nMustScanNum;
		
		_nScanStatus_ = 1;
		pST_SCANCTRL pScanCtrl = new ST_SCANCTRL();
		pScanCtrl->nScannerId = pID->Id;
		pScanCtrl->nScanCount = nNum;			//nNum
		pScanCtrl->nScanDuplexenable = nDuplex;
		pScanCtrl->nScanPixelType = nScanType;
		pScanCtrl->nScanResolution = nScanDpi;
		pScanCtrl->nScanSize = nSize;
		pScanCtrl->bShowUI = bShowScanSrcUI;	//bShowScanSrcUI;
		pScanCtrl->nAutoCut = nAutoCut;

		pDlg->m_scanThread.ResetGlobalVal();
		pDlg->m_scanThread.setNotifyDlg(pDlg);
		pDlg->m_scanThread.setModelInfo(m_nModelPicNums, m_strCurrPicSavePath);
		pDlg->m_scanThread.resetData();
		pDlg->ResetChildDlg();
		pDlg->m_scanThread.PostThreadMessage(MSG_START_SCAN, pID->Id, (LPARAM)pScanCtrl);

		pDlg->ShowChildDlg(3);
	}
	else
	{
		CNewMessageBox	dlg;
		dlg.setShowInfo(2, 1, "获取扫描源失败");
		dlg.DoModal();
	}

	char szRet[20] = { 0 };
	sprintf_s(szRet, "%d", sel);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanSrc", szRet);
	memset(szRet, 0, 20);
	sprintf_s(szRet, "%d", nDuplex);
	WriteRegKey(HKEY_CURRENT_USER, "Software\\EasyTNT\\AppKey", REG_SZ, "scanDuplex", szRet);
}